10 Replies Latest reply on Feb 12, 2009 8:00 PM by Franco Fernandes

    Websphere Hibernate problems

    Joseph Wroblewski Newbie

      I am trying to get my seam app running under websphere (initially developed using JBoss and it runs great).

      I am using Seam 2.1.1 GA and followed the directions in Chapter 38. Seam on IBM's Websphere (including changing the class loading order)

      When I started my application in websphere, I got ClassNotFound exceptions. It happened several times -- they were all Hibernat classes.  I read that websphere supports the openJPA provider natively and not Hibernate, so I thought I had to include all the Hibernate JARs in my ear file.

      When I did this, the ClassNotFound exceptions went away but then I get the following:

      Caused by: java.lang.ClassCastException: org.apache.openjpa.persistence.PersistenceProviderImpl
              at javax.persistence.Persistence.findAllProviders(Persistence.java:80)
              at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:49)

      I have been struggling with this for a few days. 

      Do I need to package Hibernate JARs in my app.  If not, why was I getting the ClassNotFound exceptions.

      Please help, I am running out of things to try.

        • 1. Re: Websphere Hibernate problems
          Franco Fernandes Novice

          I deployed successfully to WAS 6.1

          My guess is you did not include jboss-seam-2.1.1.GA\lib\persistence-api.jar

          Good luck.

          • 2. Re: Websphere Hibernate problems
            Joseph Wroblewski Newbie

            Thanks Franco.

            To clarify, should I include persistence-api.jar AND the Hibernate jars or include persistence-api.jar WITHOUT the Hibernate Jars.

            Also, I am assuming that I should include it in the lib directory of the EAR archive -- correct?


            • 3. Re: Websphere Hibernate problems
              Franco Fernandes Novice

              should I include persistence-api.jar AND the Hibernate jars


              I deployed an ear file, but with no actual EJB components - simple created a war, application.xml and packaged into an ear using an  ANT script.

              Not sure if you found these links.

              Install instructions from JBoss

              Reference Guide

              Follow this guide for EJB3

              Some things that I discovered -

              To check logs
              Application servers > appservername > Logging and Tracing > JVM Logs

              Custom properties are set at
              Application servers > appservername > Web container > Custom Properties

              • 4. Re: Websphere Hibernate problems
                Jason Gaudet Newbie

                I am having an issue deploying a Seam 2.1.1 pojo application on Websphere.  The error I receive is:

                  Caused by: java.lang.NoClassDefFoundError: net.sf.cglib.proxy.CallbackFilter

                However, the following dependency is being included in my Maven pom:


                I can see the jar under the class loader view form the WAS Console.  The application has been successfully installed to WAS CE (Geronimo) and JBoss 4.2.3.

                Any help is appreciated.

                • 5. Re: Websphere Hibernate problems
                  Franco Fernandes Novice


                  this link indicates you may be missing other files.

                  You can compare the jars list in the seam-jpa websphere dist to yours to see which ones might be missing.

                  BTW, what is your final target platform - WAS CE or Websphere or JBoss?

                  Good luck


                  • 6. Re: Websphere Hibernate problems
                    Jason Gaudet Newbie

                    Thanks for the quick response.  The final destination is Websphere Application Server.  Corporate Policy.

                    I have got past the cglib issue.  User error.  I had cglib set to provided scope in the Maven pom from when I was deploying to WAS CE.  I changed cglib to compile scope but must have got distracted and didn't regenerate the war before deploying to WAS.

                    I am now getting the following error:

                      java.lang.ClassCastException: org.apache.openjpa.persistence.PersistenceProviderImpl incompatible with    javax.persistence.spi.PersistenceProvider

                    This matches the exception cited by Joseph above.  I have configured Websphere to load classes with the application class loader first.  As shown in the Maven dependency tree below, Hibernate related jars have been included.

                    [INFO] +- org.jboss.seam:jboss-seam:jar:2.1.1.GA:compile
                    [INFO] +- org.jboss.seam:jboss-seam-ui:jar:2.1.1.GA:compile
                    [INFO] |  +- org.jboss.seam:jboss-seam:ejb:2.1.1.GA:compile
                    [INFO] |  +- org.jboss.seam:jboss-seam-jul:jar:2.1.1.GA:compile
                    [INFO] |  \- commons-beanutils:commons-beanutils:jar:1.7.0:compile
                    [INFO] +- org.jboss.el:jboss-el:jar:2.0.2-SNAPSHOT:compile
                    [INFO] |  \- javax.el:el-api:jar:1.0:compile
                    [INFO] +- javax.faces:jsf-api:jar:1.2_02:compile
                    [INFO] +- javax.faces:jsf-impl:jar:1.2-b19:compile
                    [INFO] +- com.sun.el:el-ri:jar:1.0:compile
                    [INFO] +- com.sun.facelets:jsf-facelets:jar:1.1.11:compile
                    [INFO] +- org.richfaces.ui:richfaces-ui:jar:3.2.1.GA:compile
                    [INFO] |  \- org.richfaces.framework:richfaces-impl:jar:3.2.1.GA:compile
                    [INFO] |     +- commons-digester:commons-digester:jar:1.8:compile
                    [INFO] |     \- org.richfaces.framework:richfaces-api:jar:3.2.1.GA:compile
                    [INFO] +- org.hibernate:hibernate-entitymanager:jar:3.3.2.GA:compile
                    [INFO] |  +- org.hibernate:hibernate:jar:3.2.6.ga:compile
                    [INFO] |  |  +- net.sf.ehcache:ehcache:jar:1.2.3:compile
                    [INFO] |  |  +- dom4j:dom4j:jar:1.6.1:compile
                    [INFO] |  |  \- antlr:antlr:jar:2.7.6:compile
                    [INFO] |  +- org.hibernate:hibernate-annotations:jar:3.3.1.GA:compile
                    [INFO] |  +- org.hibernate:hibernate-commons-annotations:jar:3.0.0.ga:compile
                    [INFO] |  +- org.hibernate:ejb3-persistence:jar:1.0.1.GA:compile
                    [INFO] |  +- commons-logging:commons-logging:jar:1.0.4:compile
                    [INFO] |  \- javassist:javassist:jar:3.4.GA:compile
                    [INFO] +- org.hibernate:hibernate-validator:jar:3.0.0.ga:compile
                    [INFO] +- org.hibernate:hibernate-search:jar:3.0.0.GA:compile
                    [INFO] |  \- org.apache.lucene:lucene-core:jar:2.2.0:compile
                    [INFO] +- javax.transaction:jta:jar:1.0.1B:compile
                    [INFO] +- asm:asm:jar:2.2.3:provided
                    [INFO] +- cglib:cglib-nodep:jar:2.1_3:compile
                    [INFO] +- com.h2database:h2:jar:1.0.79:compile
                    [INFO] +- c3p0:c3p0:jar:
                    [INFO] +- log4j:log4j:jar:1.2.14:compile
                    [INFO] +- commons-lang:commons-lang:jar:2.4:compile
                    [INFO] +- commons-collections:commons-collections:jar:3.2:compile

                    Does anything jump out at you?  What makes the exception particularly confusing is I am not using openjpa in the project.


                    • 7. Re: Websphere Hibernate problems
                      Franco Fernandes Novice

                      Yep, corporate policy here too. Trying to get our guys to switch to JBoss :)

                      Going to your problem, it seems like you have multiple jar files containing javax.persistence.* in your classpath. You might have a persistence.jar in the EJB3 feature pack and one in your app.

                      Start with clean logs if you can and after Websphere starts, see if you can spot the sucker.

                      Or if you can look at WAS start scripts, check out all entries for ws.ext.dirs
                      I think you have to remove the EJB3 persistence jar from your classpath - but my guess is that won't be easy - most likely Websphere might be using it for the admin console or other example apps.

                      • 8. Re: Websphere Hibernate problems
                        Peter Regnirit Newbie

                        Hi Franco,

                        Did you deploy successfully to WAS 6.1 with or without the EJB Feature Pack? Could you share with us the content of your persistence.xml and what jars you had in your lib packed with the application? I think it would be a great help to all of us! Thank you in advance!

                        • 9. Re: Websphere Hibernate problems
                          Peter Regnirit Newbie


                          Your problem can be resolved by removing the com.ibm.ws.jpa6.1.0.jar and the com.ibm.ws.ejb3jpa6.1.0.jar from the plugin folder of Websphere. Then your app will start up without problems (mine at least did).
                          But this is definitely not an elegant solution, it shouldn't work like this. I'm looking for a setting to defer OpenJPA (because even though I have PARENT_LAST set, it still loads OpenJPA, probably a classloader bug in WAS?)

                          @Franco: I have all the jars in my lib that are in websphere jpa example, plus the persistence-api (or the ejb3-persistence.jar from Hibernate) and it only works if I remove the OpenJPA jars from WAS.

                          Without the persistence-api, I get a NoSuchMethodException: org.hibernate.validator.ClassValidator.apply (org.hibernate.mapping.PersistentClass) error, even though I have correct version of hibernate-validator and annotations.jar. And the app starts correctly after a server restart (!), but doesn't start if I only stop/start the app. So I have 2 two ways to make my app work (1. removing OpenJPA jars, 2. server restart), but none are production ready. Can you please tell me if you have the EJB Feature Pack installed? And I would appreciate also if you could share with us your persistence.xml settings and the content of your lib.

                          Thank you,


                          • 10. Re: Websphere Hibernate problems
                            Franco Fernandes Novice

                            Sorry guys, just saw this an hour ago. I had to wait to hear back from my Websphere support guy - EJB3 is NOT installed on this server.

                            I agree with you Peter, definitely not elegant to remove the jar. I just wanted to help Jason get past his problem.

                            FYI for everyone - my issues were

                            my support guy never followed my instructions for setting the AJAX compatibility switches
                            -I resolved this using the admin console.

                            my application was not finding the JDBC with JNDI entry
                            -the application was initially deployed to a cluster. One of the servers was not configured properly to connect to my data source. We fixed it by mapping my application to the single server that was working.

                            Neways, here are the jars packaged in in my WEB-INF/lib



                            <?xml version="1.0" encoding="UTF-8"?>
                            <persistence xmlns="http://java.sun.com/xml/ns/persistence" 
                                         xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" 
                               <persistence-unit name="bookingDatabase" transaction-type="RESOURCE_LOCAL">
                                     <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>
                                     <property name="hibernate.show_sql" value="true"/>
                                     <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
                                     <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.WebSphereExtendedJTATransactionLookup"/>         

                            I found a post that talks about changing the default provider - give it a shot.

                            That is Big Blue for you - always making life hell for the Java world. just my 2 cents.