Forum Home » Fuse Distributions » Fuse ESB

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

 

Permlink Replies: 13 - Last Post: Nov 18, 2011 11:52 AM Last Post By: nannou9
nannou9

Posts: 10
Registered: 04/06/11
java.lang.ClassNotFoundException: org.hibernate.MappingException not found
Posted: Oct 6, 2011 12:23 PM
  Click to reply to this thread Reply
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:

233 Resolved [ ] [ ] 60 JBoss Hibernate Annotations (3.4.0.GA)
Hosts: 235
235 Active [ ] [ ] 60 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

539 Resolved [ ] [ ] 60 JBoss Hibernate Annotations (3.4.0.GA)
Hosts: 541
541 Active [ ] [ ] 60 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
marmac

Posts: 4
Registered: 10/04/11
Re: java.lang.ClassNotFoundException: org.hibernate.MappingException not found
Posted: Oct 20, 2011 9:27 AM   in response to: nannou9 in response to: nannou9
  Click to reply to this thread Reply
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:
250 Active [ ] [ ] 60 JBoss Hibernate Common Annotations (3.3.0.ga)
251 Resolved [ ] [ ] 60 JBoss Hibernate Annotations (3.4.0.GA)
Hosts: 253
252 Resolved [ ] [ ] 60 JBoss Hibernate Entity Manager (3.4.0.GA)
Hosts: 253
253 Active [ ] [ ] 60 JBoss Hibernate Object-Relational Mapper (3.3.2.GA)
Fragments: 251,252
254 Active [ ] [ ] 60 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

nannou9

Posts: 10
Registered: 04/06/11
Re: java.lang.ClassNotFoundException: org.hibernate.MappingException not found
Posted: Oct 20, 2011 7:50 PM   in response to: marmac in response to: marmac
  Click to reply to this thread Reply
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
nannou9

Posts: 10
Registered: 04/06/11
Re: java.lang.ClassNotFoundException: org.hibernate.MappingException not found
Posted: Oct 31, 2011 2:12 PM   in response to: nannou9 in response to: nannou9
  Click to reply to this thread Reply
I have to sadly confirm that new version of fuse esb 4.4.1-fuse-01-06 have very same problem (bug?).
davsclaus

Posts: 1,893
Registered: 10/14/08
Re: java.lang.ClassNotFoundException: org.hibernate.MappingException not found
Posted: Nov 1, 2011 8:36 AM   in response to: nannou9 in response to: nannou9
  Click to reply to this thread Reply
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.
nannou9

Posts: 10
Registered: 04/06/11
Re: java.lang.ClassNotFoundException: org.hibernate.MappingException not found
Posted: Nov 2, 2011 8:58 PM   in response to: davsclaus in response to: davsclaus
  Click to reply to this thread Reply
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?

davsclaus

Posts: 1,893
Registered: 10/14/08
Re: java.lang.ClassNotFoundException: org.hibernate.MappingException not found
Posted: Nov 3, 2011 7:57 AM   in response to: nannou9 in response to: nannou9
  Click to reply to this thread Reply
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.
nannou9

Posts: 10
Registered: 04/06/11
Re: java.lang.ClassNotFoundException: org.hibernate.MappingException not found
Posted: Nov 3, 2011 12:03 PM   in response to: davsclaus in response to: davsclaus
  Click to reply to this thread Reply
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
davsclaus

Posts: 1,893
Registered: 10/14/08
Re: java.lang.ClassNotFoundException: org.hibernate.MappingException not found
Posted: Nov 3, 2011 1:49 PM   in response to: nannou9 in response to: nannou9
  Click to reply to this thread Reply
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.
marmac

Posts: 4
Registered: 10/04/11
Re: java.lang.ClassNotFoundException: org.hibernate.MappingException not found
Posted: Nov 4, 2011 2:24 PM   in response to: davsclaus in response to: davsclaus
  Click to reply to this thread Reply
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
davsclaus

Posts: 1,893
Registered: 10/14/08
Re: java.lang.ClassNotFoundException: org.hibernate.MappingException not found
Posted: Nov 4, 2011 2:52 PM   in response to: marmac in response to: marmac
  Click to reply to this thread Reply
Are you using Spring DM by any chance?
marmac

Posts: 4
Registered: 10/04/11
Re: java.lang.ClassNotFoundException: org.hibernate.MappingException not found
Posted: Nov 4, 2011 3:15 PM   in response to: davsclaus in response to: davsclaus
  Click to reply to this thread Reply
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 :-) we got a Subscription but in the mean while we sorted out a lot of issues.

Let me know if you need more info
davsclaus

Posts: 1,893
Registered: 10/14/08
Re: java.lang.ClassNotFoundException: org.hibernate.MappingException not found
Posted: Nov 4, 2011 3:47 PM   in response to: marmac in response to: marmac
  Click to reply to this thread Reply
If you for example define a XML file with Camel routes or <bean> definitons etc. then you can basically do this in either Spring DM or OSGi Blueprint.

Spring DM is just like plain Spring, so the namespace will have www.springframework.org in it.

Where as the namespace for OSGi blueprint is different, and the root tag AFAIR is <blueprint>

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
nannou9

Posts: 10
Registered: 04/06/11
Re: java.lang.ClassNotFoundException: org.hibernate.MappingException not found
Posted: Nov 18, 2011 11:52 AM   in response to: davsclaus in response to: davsclaus
  Click to reply to this thread Reply
I have sent a pm message to Claus with a solution: pom.xml that repacks hibernate bundles using maven-shade-plugin.

Greetings
Piotr Klimczak