29 Haziran 2009 Pazartesi

a sample web based application

i am developping a homework web based application by using the following technologies:
  • apache tomcat 6.0.18, installed with Netbeans 6.5.1
  • toplink (with jpa annotations) for persistence, netbeans automatically creates jpa controller classes
  • jsf, using jsf framework of netbeans, netbeans automatically creates jsf classes and crud pages
  • derby database, coming bundled with netbeans and can be easily managed inside the ide
  • web services, jaxws, using netbeans facilities during development (actually independent from jpa part)
Steps for jpa part:
  1. create a web application with jsf framework added, select tomcat as server runtime.
  2. create a database from databases under services tab. (use that db in the following step) (http://www.netbeans.org/kb/60/ide/java-db.html may help)
  3. create a persistence unit, selecting toplink, the created db in the above step and drop and create as table generation strategy.
  4. create entity classes
  5. generate jsf faces from entity classes
  6. deploy and try from localhost something like that : http://localhost:8084/Registration/faces/welcomeJSF.jsp, do not forget to put faces in the address, that makes the faces servlet deal with that page.
  7. add derbyclient.jar manually (under /opt/sun/javadb/lib in my linux environment ) if you get the following error during run:

Exception [TOPLINK-4003] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Exception Description: Configuration error. Class [org.apache.derby.jdbc.ClientDriver] not found.


and deploy and try again!

my project is working :)

Steps for web service part:

  1. create the web service and deploy again.. if successful, you should see the wsdl at somewhere like that http://localhost:8084/Registration/RegistrationWS?wsdl, generated jpa controller classes can be used within web service operations.
  2. create an other web aplication project. this will be the client that makes use of all deployed web services.
  3. in the client web app, generate the web service client from wsdl.
  4. crate a .jsp file in which you call the web service. this can be done automatically by right clicking in jsp and selecting 'Web Services Client Resources -> Call Web Servicve Operation'
  5. deploy the client web app and test from localhost..

Edit on 20.15 : if you get the following error while generating jsf from entity classes,

Could not find Id property. Be sure the accessor method name matches the variable name.

just move the jpa annotations from variable declarations to accessor methods. That fixed the problem in my case. btw, i faced this problem in Windows Xp, but in OpenSuse everything was fine already..


2 yorum:

  1. i see, but this was just for a school project :)

    YanıtlaSil
  2. after moving jpa annotations from variable declarations to accessor methods it does not run on web server until reversing the process by moving them to their old places..

    YanıtlaSil