13 Replies Latest reply on Nov 18, 2011 6:52 AM by nannou9_piotr

    java.lang.ClassNotFoundException: org.hibernate.MappingException not found

    nannou9_piotr

      Hi All!

       

      Today i have faced a problem, which seems to be specific to FUSE ESB only.

       

      The problem shows as:

      java.lang.ClassNotFoundException: org.hibernate.MappingException not found by com.springsource.org.hibernate.annotations

      and it is all around exporting "org.hibernate" by 2 bundles:

       

      JBoss Hibernate Annotations (3.4.0.GA)

                                             Hosts: 235

      JBoss Hibernate Object-Relational Mapper (3.3.2.GA)

                                             Fragments: 233,234

       

      I believe that the problem occurs because of "org.hibernate" being exported by 2 bundles (host and it's fragment):

       

      exports | grep "org.hibernate;"

         233 org.hibernate; version=3.4.0.GA        

         235 org.hibernate; version=3.3.2.GA        

         235 org.hibernate; version=3.4.0.GA

       

      Then i have noticed that same feature installed on my 1 month old servicemix build (from trunk) works perfect, as well as newly builded one (checked out from trunk today).

      Exports looks a little different on SMX builded from trunk:

       

      exports | grep "org.hibernate;"

         541 org.hibernate; version=3.3.2.GA        

         541 org.hibernate; version=3.4.0.GA

       

      JBoss Hibernate Annotations (3.4.0.GA)

                                             Hosts: 541

      JBoss Hibernate Object-Relational Mapper (3.3.2.GA)

                                             Fragments: 539,540

       

      Unfortunately i do not have time for looking for a bug inside FUSE ESB. So now it is your turn.

      If you need more informations, then give me a sign...

       

      Piotr Klimczak

        • 1. Re: java.lang.ClassNotFoundException: org.hibernate.MappingException not found
          marcomac

          Hi

          I faced the same issue on FUSE ESB 4.4.1-fuse-00-08.

           

          It's a blocking issue for us at the moment is there any work around?

           

           

          Here my situation:

          JBoss Hibernate Common Annotations (3.3.0.ga)

          JBoss Hibernate Annotations (3.4.0.GA)

                                                 Hosts: 253

          JBoss Hibernate Entity Manager (3.4.0.GA)

                                                 Hosts: 253

          JBoss Hibernate Object-Relational Mapper (3.3.2.GA)

                                                 Fragments: 251,252

          Spring ORM (3.0.5.RELEASE)

           

           

          karaf@root> exports | grep "org.hibernate;"

             251 org.hibernate; version=3.4.0.GA        

             253 org.hibernate; version=3.3.2.GA        

             253 org.hibernate; version=3.4.0.GA 

           

           

           

          it would be appreciate any help on this point.

          Best regards

          Marco

           

          Edited by: marmac on Oct 20, 2011 9:28 AM

          • 2. Re: java.lang.ClassNotFoundException: org.hibernate.MappingException not found
            nannou9_piotr

            Simple download apache servicemix trunk, then build your own ESB using mvn -Pfastbuild. After about 20m you will get working ServiceMix. This is my solution which is working perfect for me.

             

            I know that best would be to find the bug and solve the problem, but I do not have time for now.

             

            Hope that this problem will be solved soon. If not, then maybe one day i will find more time than just few minutes for Apache and Fusesource

            • 3. Re: java.lang.ClassNotFoundException: org.hibernate.MappingException not found
              nannou9_piotr

              I have to sadly confirm that new version of fuse esb 4.4.1-fuse-01-06 have very same problem (bug?).

              • 4. Re: java.lang.ClassNotFoundException: org.hibernate.MappingException not found
                davsclaus

                Its not Fuse ESB problem per see.

                Its Hibernate not being OSGi compliant.

                 

                OpenJPA is OSGi compliant, JPA1/2 spec compliant, and much ligher and faster than Hibernate.

                • 5. Re: java.lang.ClassNotFoundException: org.hibernate.MappingException not found
                  nannou9_piotr

                  You are right Claus... but the thing is, that the problem occurs using jpa-hibernate feature which is fuse specific.

                  So, maybe it would be a good idea to use maven-shade-plugin to repack all hibernate bundles into one "super" bundle?

                   

                  So repack:

                    org.hibernate/com.springsource.org.hibernate.annotations.common/3.3.0.ga

                    org.hibernate/com.springsource.org.hibernate.annotations/3.4.0.GA

                    org.hibernate/com.springsource.org.hibernate.ejb/3.4.0.GA

                    org.hibernate/com.springsource.org.hibernate/3.3.2.GA

                  into for example

                    com.fusesource/org.hibernate/3.3.2.GA

                   

                  Another idea is to switch to hibernate 4, which seems to be better organized (in osgi meaning).

                   

                  Let's say that you will pick the solution that would be best (in your opinion) and i will do my best to bring it to reality?

                   

                  The thing is that I need a working solution in about 1 month as i am about to start production use of a solution based on hibernate jpa soon.

                   

                   

                  What do You think?

                  • 6. Re: java.lang.ClassNotFoundException: org.hibernate.MappingException not found
                    davsclaus

                    If you have a FuseSource subscription then I suggest to use that channel to get help with the hibernate and to help meet your deadline.

                     

                    Hibernate is LGPL licensed so its much harder to officially support it from 3rd parties.

                     

                    Yes Hibernate 4.0 may be better OSGi compliant. At least JBoss AS 7 is heading in the OSGi direction, so I guess JBoss would want to make using Hibernate possible.

                    • 7. Re: java.lang.ClassNotFoundException: org.hibernate.MappingException not found
                      nannou9_piotr

                      Unfortunately my company do not have FuseSource subscription yet. We are about to buy it at the beginning of 2012 (which is too late according to my deadline but the final decision was not mine).

                       

                      So are there any plans to use hibernate 4.0 by jpa-hibernate feature?

                      As i said i can help you doing this improvement, but you have to tell me how to contribute the code to Fusesource? As you probably know i am an Apache contributor already, but Apache foundation does not support jpa-hibernate feature. So where can i create an improvement task and upload the code?

                       

                      Greetings,

                      Piotr Klimczak

                      • 8. Re: java.lang.ClassNotFoundException: org.hibernate.MappingException not found
                        davsclaus

                        You can send me a private mail. And I can help get in touch with someone, so we can look into what we can do to help you with that hibernate issue.

                         

                        Just mind that getting Hibernate 3.x to work in OSGi is hard. And if you use class based proxy using ASM or the likes, its even harder. And as well those TX annotations.

                         

                        BTW Are you using Blueprint or Spring DM? The latter also have some issues in terms of classloading etc. Blueprint is much better.

                         

                        My mail is claus dot ibsen AT fusesource DOT com.

                        • 9. Re: java.lang.ClassNotFoundException: org.hibernate.MappingException not found
                          marcomac

                          Hi

                          I've posted before that I had the same problem and actually it seems a problem of Hibernate.

                          What we figure out is uninstall the two bundles

                          251 Resolved 60 JBoss Hibernate Annotations (3.4.0.GA)

                          Hosts: 253

                          252 Resolved 60 JBoss Hibernate Entity Manager (3.4.0.GA)

                           

                          and redo a

                          features:install jpa-hibernate

                           

                          this seems fixing the issues in a way that we can access the db and the ClassNotFoundException seems going away.

                           

                          I know that is not a clear solution but at least works.

                          In the meanwhile I'm looking at Open JPA but I didn't find yet an example with spring.

                           

                          I've seen that C. Moullard has posted an example with camel-aries but not yet seen it properly.

                           

                          Is there a plan to fix this Hibernate issue on next releases? I've the time constraint indicated above by some other people.

                           

                          Regards

                          Marco

                          • 10. Re: java.lang.ClassNotFoundException: org.hibernate.MappingException not found
                            davsclaus

                            Are you using Spring DM by any chance?

                            • 11. Re: java.lang.ClassNotFoundException: org.hibernate.MappingException not found
                              marcomac

                              Hi

                              I'm not using Spring DM, just service mix 4.4.1-fuse-01-06 with Camel 2.8.0-fuse-01-06.

                               

                              Basically we have two modules

                              - one the WS interface with CXF 2.4.2-fuse-01-06 that calls the DAO.

                              - one that make the DAO with Hibernate, originally it was an OSGI module deployed by itself in the 4.3.1 (not fuse) but in the 4.4.1-fuse-01-06 we needed to import in the WS module because I couldn't deploy it anymore. We got this exception (subject of this post) and I solved with that trick.

                               

                              We moved from 4.3.1 to 4.4.1-fuse-xx-yy because of the services on the same port. that are available under .../cxf/ only from the 4.4.1. Where there was even the issues related to Servlet 3.0 e 2.5 with Jetty ;-). That I solved.:-)

                               

                              so at the moment I'm planning to change to OpenJPA and next week somebody of Progress will pass by but in the mean while we sorted out a lot of issues.

                               

                              Let me know if you need more info

                              • 12. Re: java.lang.ClassNotFoundException: org.hibernate.MappingException not found
                                davsclaus

                                If you for example define a XML file with Camel routes or

                                 

                                For example as this example from Apache Camel

                                https://svn.apache.org/repos/asf/camel/trunk/examples/camel-example-cxf-blueprint/src/main/resources/OSGI-INF/blueprint/camel-context.xml

                                • 13. Re: java.lang.ClassNotFoundException: org.hibernate.MappingException not found
                                  nannou9_piotr

                                  I have sent a pm message to Claus with a solution: pom.xml that repacks hibernate bundles using maven-shade-plugin.

                                   

                                  Greetings

                                  Piotr Klimczak