Joshua Java

Posts Tagged ‘glassfish

2009 is coming to your way and it’s time to get ready on what technology lies ahead. Refactor, refactor and refactor is the theme for 2009. A whole new technology is coming your way and it’s good to take a sneak peek on what technology is worth evaluating to be used for our projects in 2009. The first half technology are the technologies that you should keep your eyes at while the next half are the technologies that you might want to start trying for your next project in 2009. So here are the lists for 2009:
Read the rest of this entry »

I’ve tried running my Seam apps on Glassfish 2.1 and it’s running very smooth and faster than before. This is a major improvement to Glassfish 2.0. Thanks for the hardwork done by the Glassfish team.

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:

  1. 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
  2. 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
  3. 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

  4. 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
  5. 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.dialect property into the database you use. You can find these dialects for various databases inside hibernate docs.
    • hibernate.transaction.manager_lookup_class into org.hibernate.transaction.SunONETransactionManagerLookup

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 🙂

For the last 4 days I’ve been working with application to be deployed on IBM Websphere 5.1. But Websphere seems to be so weird besides it is so resource consuming :(. Application that has error on runtime can not be started on WAS and if I’ve got error when I start the apps from the console, it just doesn’t give informative exception.
This is what I mean by not very informative:

[11/8/07 20:17:07:242 ICT] 29b9c03e WebGroup E SRVE0026E: [Servlet Error]-[]: java.lang.NullPointerException
at org.apache.jsp._error._jspService(_error.java:113)
at com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java:89)
...

So I went on finding other appserver that is lighter, can give informative exception and somewhat similar to WAS because the apps connects to a JNDI datasource. I went on for Glassfish since it’s quite similar to WAS. Though I like JBoss, but it has different naming to WAS which requires me to change the configuration back and forth.

Well it simply works and it’s much lighter than WAS both during startup and during runtime. I can figure out the problem because eventhough the apps has error, Glassfish still allows the apps to be started and when I hit the browser to run the apps it shows a very informative stacktrace.
This is what I mean by very informative:

java.lang.UnsupportedClassVersionError: PWC1651: Class com.foo.web.util.SessionCounter has unsupported major or minor version numbers, which are greater than those found in the Java Runtime Environment version 1.5.0_11
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:980)
...

Also it has a very nice look and feel 😉 And oh, best of all, it’s free, as I don’t have to spend alot of money for something that does not help my productivity.

Thanks Glassfish.