-
1. Re: Hibernate classes are unavailable at WEB tier
jaikiran Dec 8, 2011 2:37 AM (in response to archimagealex)Alexander Mitenko wrote:
Metawidget's library realization for default action Class.forName( "....PersistentBag" ) fails in the web tier when hibernate-core-4.0.0.CR2.jar is available in the app server!
I'm guessing it's not using the correct classloader. Class.forName has overloaded methods, make sure you are using the correct one. You could also post the relevant code and the exception stacktrace.
-
2. Re: Hibernate classes are unavailable at WEB tier
archimagealex Dec 8, 2011 4:28 AM (in response to jaikiran)Hi, Jaikiran!
Here is output of toString() for every used class loaders:
Metawidget 1:
19:20:28,034 INFO [stdout] (http--127.0.0.1-8080-1) Current thread classloader: ModuleClassLoader for Module "deployment.nfcs-1.0.0.ear.web-1.0.0.war:main" from Service Module Loader
Metawidget 2:
19:20:28,034 INFO [stdout] (http--127.0.0.1-8080-1) ClassUtils class classloader: ModuleClassLoader for Module "deployment.nfcs-1.0.0.ear.web-1.0.0.war:main" from Service Module Loader
Our trick, that forces project to work:
19:20:28,034 INFO [stdout] (http--127.0.0.1-8080-1) nfcs.model.User classloader: ModuleClassLoader for Module "deployment.nfcs-1.0.0.ear:main" from Service Module Loader
But, war project is embedded into ear and deployed, of course, together by standard file deployment mechanism. Why they use different classloaders?
Regards,
Alexander
-
3. Re: Hibernate classes are unavailable at WEB tier
smarlow Dec 8, 2011 6:59 AM (in response to archimagealex)Alexander,
Have you tried recreating with the latest nightly build? You can download from here.
Scott
-
4. Re: Hibernate classes are unavailable at WEB tier
archimagealex Dec 8, 2011 8:21 AM (in response to smarlow)Scott,
Have you tried recreating with the latest nightly build? You can download from here.
Yes, I tested latest build, but result is same as with 7.0.2
Alexander
-
5. Re: Hibernate classes are unavailable at WEB tier
smarlow Dec 8, 2011 9:27 AM (in response to archimagealex)If your using the native Hibernate api, you need to add a dependency on the Hibernate module. There are a few ways to do that, one way is shown here (search for "Native Hibernate use").
-
6. Re: Hibernate classes are unavailable at WEB tier
archimagealex Dec 8, 2011 3:34 PM (in response to smarlow)Scott,
There are no obvious reasons to use native Hibernate in WEB tier, isn't it? Then I do not used it!
I use my own entities to transfer data into EJB tier to use a container managed space for CRUD operations with EntityManager and no any Hibernate calls at any tier.
Thanks for Yours opinion, but it is not for my case.
Alexander.
-
7. Re: Hibernate classes are unavailable at WEB tier
smarlow Dec 8, 2011 4:01 PM (in response to archimagealex)1 of 1 people found this helpfulAlexander,
You did mention using JPA but sometimes people use that term to refer to the Hibernate native api. We currently inject the Hibernate module dependency in the same place as the persistence unit definition.
This documentation explains more and gives some possible workarounds when you run into problems. You probably could try adding a META-INF/MANIFEST.MF entry (for the org.hibernate module) to your war. The entry would contain:
Dependencies: org.hibernate
See if that helps workaround the issue.
Scott
-
8. Re: Hibernate classes are unavailable at WEB tier
archimagealex Dec 9, 2011 1:46 AM (in response to smarlow)Scott,
Your workaround is works for me! Thanks.
Alexander.