Last time I used seam was in a project that was setup using maven2 and running in a tomcat with embedded ejb container from JBoss. I thought that moving the application to JBoss server (4.2.1.GA) would be easy, I was wrong (probably because I never setup a JSF project before, especially one that uses seam).
My plan was to create an ear containing a jar (containing the model & service ejb3 beans), another jar (containing the action listener classes, which is stateless/stateful beans) and a war file. All the libraries will be put under lib directory inside the ear.
Problems I got (I forgot some details, I write this around 3 weeks after):
1. When deployed, the jars inside the lib directory can't be found.
2. I was desperate, so I put the jars back in each jars & war lib. Got ClassCastException somewhere, this was due to different classloader used to load the jar. So I define a classloader repository name in the configuration file (jboss specific), then I got another exception related to the listener configured for the web app... totally desperate.
3. Seam doesn't know my bean in the other jar file, should I include the jar in my war's lib? nope, don't want to.
The point is I want to use the same jars for all the three of my jars & war.
I just go to sleep, having enough headache and annoyance. The day after, going around the net, I found this interesting element I can use in the application.xml file, i.e. (available since JEE 5).
Problems solved! All my jars & war use the same libraries, Seam knows all my beans in my jars, no more ClassCastException, listener related exception and other strange things unbeknown to the world of mortals.
Here are my projects & configurations :
1 project containing the model & service beans. (1 jar)
1 project containing the jsf action listener beans (ejb3 stateless & stateful beans)
1 web application project
1 ear project
My ear looks like this :
- model.jar
- action.jar
- app.war
- lib (containing libraries, i.e. jboss-seam.jar, etc)
The key is in application.xml :
<module>
<ejb>model.jar</ejb>
</module>
<module>
<ejb>service.jar</ejb>
</module>
<module>
<web>
<web-uri>app.war</web-uri>
<context-root>app</context-root>
</web>
</module>
<library-directory>lib</library-directory>
At last, I can work happily ever after...... :)
Saturday, October 20, 2007
Subscribe to:
Post Comments (Atom)
1 comment:
Post a Comment