Asimov Technologies
J2EE, JEE, PHP
Frank D. Martínez’s Blog
Software & Fun
Welcome to my technical blog. Here you can find my opinions and proposals over many software development things, mainly on open source projects.
Example: Seam 2.0 + Wicket 1.3 + Netbeans 6.0 + Glassfish V2
One of the more exciting features of JBoss Seam 2.0 is that it is decoupled of JSF. Here is a sample project using Seam 2.0 with Apache Wicket instead of JSF. And additionally it is a Netbeans 6.0 project and is configured to deploy into Glassfish V2.
Project architecture image (click it to enlarge) :
Project Tree image (click it to enlarge) :
Explanation of the numerated marks in the images above:
1. static html, css, javascript, images, and so forth
2. Seam configuration files:
- components.xml see: reference
- pages.xml see: reference
3. JPA based data model (Annotated persistent pojos)
4. EJB 3.0 Layer. Business logic goes here. Access to the EntityManager, Other EJBs, JNDI Resources, Web Services, etc …
5. Wicket pages. All Wicket java code goes here.
- To get seam support in a wicket page it must be a subclass of SeamWebPage.
- To get seam support in your application it must be a subclass of SeamWebApplication.
6. Wicket html code goes here. The package tree must be consistent with (5)
7. JUnit tests packages…
8. Ant build script
- clean : Clear all compiled classes, jars, ears, etc…
- ear : Generate the deployable ear.
- deploy : Deploy the ear to the glassfish v2 autodeploy dir.
- undeploy : Removes the ear from the glassfish v2 autodeploy dir.
Download: Project with all dependencies
Instructions:
1. Install Netbeans 6.0 with JEE support: http://www.netbeans.org/
2. Download de example project: download
3. Unzip it where you want.
4. Edit the private.properties file in the project root and set the glassfish.home property to your Glassfish installation dir.
5. Open the project with Netbeans
6. Start Glassfish
7. Right click on the build.xml - execute task - deploy
8. Point your browser to http://localhost:8080/wicket-seam/
You can get more specific documentation from Apache and RedHat sites:
- Apache Wicket home page: http://wicket.apache.org/
- JBoss Seam home page: http://labs.jboss.org/jbossseam/
Wicket-Seam Integration
There is the first version of Wicket-Seam integration module.
- Download it form the svn repository: https://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff/trunk/
- Build it from source: with maven 2: mvn -Dmaven.test.skip=true package
- Or download the binary: wicket-seam-1.3.0-SNAPSHOT.jar
There is a basic example here: wicket-seam-project It is a netbeans 6.0 project configured to deploy to Glassfish V2. This example contains all required dependencies. IMPORTANT: Before use it you must set the glassfish.home property in the private.properties file.
The general architecture of the example project is this:
Seam 1.2.1.GA + Netbeans 5.5.1 + Glassfish v2-b58c
I have developed a Seam Application in netbeans and deployed it to glassfish-v2-b58c. I have written my own build script and a netbeans project hack to get it working with code completion and default IDE actions. There is the code and instructions to use it for developing seam applications in netbeans 5.5.1 for the glassfish server.
Download: Empty Seam Project for Netbeans
-
Unzip the project.
-
Open the file build.xml and replace the string @@PROJECT_NAME@@ with your project name. (i.e. MyApp).
-
Open the file private.properties and replace the string @@GLASSFISH_HOME@@ with the real absolute path to the installed Glassfish. (i.e. /opt/glassfish).
-
Open the file project.properties and replace the string @@EAR_NAME@@ with your ear name. (i.e. Myapp.ear).
-
Open the file resources/META-INF/application.xml and replace the string @@WEB_ROOT@@ with your web root. (i.e. myapp).
-
Open the file resources/META-INF/persistence.xml and replace the string @@DATASOURCE@@ with your datasource name. (i.e. jdbc/myDataSource). You can create a datasource using the glassfish Admin Console.
-
Open the file resources/WEB-INF/components.xml and replace the string @@EAR_NAME@@ with your ear name. (i.e. Myapp). Important! Without the .ear extension.
-
Open the file nbproject/project.xml and replace the string @@PROJECT_NAME@@ with your project name. (i.e. MyApp).
-
Open the project with Netbeans 5.5.1
- Important: copy the file jboss-cache-jdk50.jar from jboss server to GLASSFISH_HOME/domains/domain1/lib/ext
This project structure was tested in GNU/Linux with glassfish-v2-b58c, postgresql 8.2 and Jboss Seam 1.2.1.GA.
To get it working you need to develop at least one Service EJB and One Controller (Backing bean) EJB and declare them in web.xml using <ejb-local-ref>.
The project structure suggest the following basic architecture:
Or this is also a good choice:
This site contains personal opinions about many things and does not intend to be normative in any aspect.
Java, J2EE, J2SE, JEE, Are trademarks of Sun Microsystems Inc.
