Deploying Seam POJO apps on Glassfish
Posted on: January 29, 2008
- In: Java
- Leave a Comment
Alot of people wondered whether Seam can be deployed on other appserver other than JBoss AS. Well indeed it can. Now I’m going to show how to deploy Seam on Glassfish in a very simple way without you having to modify your project stub that is created with seam-gen. So in the future you only have to modify your persistence.xml, other than that you can deploy the same seam apps you deploy on JBossAS. Note that this only works with Seam POJO apps and doesn’t work with Seam EJB3 apps mainly because Glassfish requires you to write the EJB3 reference on your web.xml. So it’s not Seam fault! As this blog entry is written I am using Seam 2.x and Glassfish 2.
Here’s what you need to do:
- Copy these libraries into
$GLASSFISH_HOME/domains/$DOMAIN_NAME/lib/ext:- javassist
- dom4j
- hibernate-validator
- commons-logging
- cglib-nodep
- eclipse-jdt-core. In seam distribution this is packaged as core.jar
- antlr
- log4j
- Your database JDBC driver. I use mysql, so I would copy mysql-connector-java here
- Copy these libraries into
$GLASSFISH_HOME/lib: Here we will use Hibernate as the persistence layer and will override toplink which is the default persistence layer from Glassfish because Seam does not yet support Toplink as the persistence layer for Seam POJO apps.- jboss-archive-browsing
- jboss-common-core
- hibernate core. The core library
- hibernate-annotations
- hibernate-commons-annotations
- hibernate-entitymanager
- hibernate-validator
- Create your connection pool and datasource from Glassfish admin console. Create it from these menu from inside of your admin console:
- Resources > JDBC > Connection Pools
- Resources > JDBC > JDBC Resources
- Open up your
persistence.xml. If your project is created with seam-gen this will be located inside$PROJECT_HOME/resources/META-INF/. And then edit these lines:- element into the datasource you’ve created on previous step
hibernate.dialectproperty into the database you use. You can find these dialects for various databases inside hibernate docs.hibernate.transaction.manager_lookup_classintoorg.hibernate.transaction.SunONETransactionManagerLookup
Note: These libraries is bundled with seam distribution so you don’t have download it separately.
FAQ: We copied these libraries into two different folders because Glassfish has a very unique classloader and becaus we want to override Toplink which is located inside $GLASSFISH_HOME/lib
Now the next time you create and deploy another project to the same Glassfish server, you only need to do step 3 and 4. Good luck



Recent Comments