• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.lang.ClassNotFoundException: org.hibernate.MappingException

 
Greenhorn
Posts: 10
  • Number of slices to send:
    Optional 'thank-you' note:
I am trying to add ehcache to my project. I started with an older version of ehcache but was having problems, so I went with hibernate-ehcache-3.6.10. I have added the following properties to my config:



I added the libraries in Eclipse by righlt-clicking Referenced Libraries -> Build Path -> configure Build Path... -> Add JARs..., and then went to the Order and Export tab and added them as export and put them in order. And I have the following libraries in my classpath:



But when I try to run as an Eclipse Application, I get this exception:

eclipse.buildId=unknown
java.version=1.7.0_80
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments: -product MYPROJECT.product
Command-line arguments: -product MYPROJECT.product -data C:\Users\me\workspace_libs/../runtime-MYPROJECT.product -dev file:C:/Users/me/workspace_libs/.metadata/.plugins/org.eclipse.pde.core/MYPROJECT.product/dev.properties -os win32 -ws win32 -arch x86_64 -consoleLog

!ENTRY org.eclipse.osgi 4 0 2016-02-25 10:01:18.189
!MESSAGE Application error
!STACK 1
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [dataAccess-config.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/MappingException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:883)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:839)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
at com.company.myproject.controllers.ApplicationSettingsController.<init>(ApplicationSettingsController.java:39)
at com.company.myproject.controllers.ApplicationSettingsController.getInstance(ApplicationSettingsController.java:49)
at com.company.myproject.client.application.Application.start(Application.java:26)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
Caused by: java.lang.NoClassDefFoundError: org/hibernate/MappingException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2595)
at java.lang.Class.getConstructor0(Class.java:2895)
at java.lang.Class.getDeclaredConstructor(Class.java:2066)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:54)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:877)
... 29 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.MappingException cannot be found by MYPROJECT_1.0.0
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 35 more


No idea if its a configuration or a dependency error. Any help is appreciated. I have another post with a similar problem, but different library versions, and a different exception. I'll take whatever works.
Thanks.
 
Sheriff
Posts: 11604
178
  • Number of slices to send:
    Optional 'thank-you' note:
Seems you have posted exactly the same question on SO. Please BeForthrightWhenCrossPostingToOtherSites. Thanks!
 
Roel De Nijs
Sheriff
Posts: 11604
178
  • Number of slices to send:
    Optional 'thank-you' note:
First thing to verify: can you find the org.hibernate.MappingException class in one of your dependencies? If you can, is this jar part of your classpath?
 
Jason Trinity
Greenhorn
Posts: 10
  • Number of slices to send:
    Optional 'thank-you' note:

Roel De Nijs wrote:Seems you have posted exactly the same question on SO. Please BeForthrightWhenCrossPostingToOtherSites. Thanks!



Sorry, I just need this answered soon, since I've spent over a week trying to get this working. Would just adding something like (crosspost from Stackoverflow) on the title be enough, or is x-posting forbidden? I'm just trying to reach more people.
 
Jason Trinity
Greenhorn
Posts: 10
  • Number of slices to send:
    Optional 'thank-you' note:

Roel De Nijs wrote:First thing to verify: can you find the org.hibernate.MappingException class in one of your dependencies? If you can, is this jar part of your classpath?



hibernate-core-3.6.10.Final.jar has org.hibernate.MappingException.class, and it's in my classpath
 
Roel De Nijs
Sheriff
Posts: 11604
178
  • Number of slices to send:
    Optional 'thank-you' note:

Jason Trinity wrote:Would just adding something like (crosspost from Stackoverflow) on the title be enough, or is x-posting forbidden? I'm just trying to reach more people.


It's definitely not forbidden on CodeRanch. But be honest about it: e.g. at the bottom of your post, you could easily add something like "I have posted this question also on StackOverflow" together with the link of the question. Otherwise it could be possible that someone spends 2-3 hours of his/her precious free time to answer your question, while you have already got an answer/solution.
 
Roel De Nijs
Sheriff
Posts: 11604
178
  • Number of slices to send:
    Optional 'thank-you' note:

Jason Trinity wrote:hibernate-core-3.6.10.Final.jar has org.hibernate.MappingException.class, and it's in my classpath


Ok! So the class is definitely on the classpath. Now we have to wonder why it's not found during project startup. It seems you are using an Eclipse project to run your application. Is this intended? If it's not, try to use a simple Java application instead. Here you'll find an example to create the Hibernate Application in Eclipse IDE
 
Jason Trinity
Greenhorn
Posts: 10
  • Number of slices to send:
    Optional 'thank-you' note:
I just started working in this project a few weeks ago and its been running as an Eclipse Application for years. I don't know how much work would be to run it as a Java Application, but I can try.
 
Roel De Nijs
Sheriff
Posts: 11604
178
  • Number of slices to send:
    Optional 'thank-you' note:

Jason Trinity wrote:I just started working in this project a few weeks ago and its been running as an Eclipse Application for years. I don't know how much work would be to run it as a Java Application, but I can try.


Oh, it's an existing project! Then there's no need to try and run it as a Java application. I thought you were creating a project from scratch and I wanted to eliminate all unnecessary complexities until you had a working application. And then you could add the necessary complexities again one by one. But this doesn't apply in your situation.

And when did this error occurred for the first time? When you added hibernate-ehcache-3.6.10 to the classpath? Or when you added some specific ehcache config to your configuration files?

 
Jason Trinity
Greenhorn
Posts: 10
  • Number of slices to send:
    Optional 'thank-you' note:
I've done so much stuff that I can't even reproduce this issue when I checkout the project and try to modify it.

Here is a list of things I've done:

-The project already had hibernate. It had a hibernate3.jar that I figured out was hibernate-3.6.0-CR2. I replaced it with hibernate-core-3.6.10.Final.jar. The code ran fine.
-Added ehcache-core-2.4.3.jar and hibernate-ehcache-3.6.10.Final.jar, and the code worked fine.
-Added the following lines to the project's config file in the <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> bean, under <property name="hibernateProperties">



and I get the error java.lang.ClassNotFoundException: net.sf.ehcache.hibernate.EhCacheRegionFactory cannot be found

I still have a copy of the project with the original exception (java.lang.ClassNotFoundException: org.hibernate.MappingException not found), but I do not know why I cannot reproduce this error when I redo these steps.



Another question I had is which of these should I use?

<prop key="hibernate.cache.region.factory_class">net.sf.ehcache.hibernate.EhCacheRegionFactory</prop>
or
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
?

If I use the second property, I get the error java.lang.ClassNotFoundException: net.sf.ehcache.CacheException cannot be found


 
Roel De Nijs
Sheriff
Posts: 11604
178
  • Number of slices to send:
    Optional 'thank-you' note:

Jason Trinity wrote:-The project already had hibernate. It had a hibernate3.jar that I figured out was hibernate-3.6.0-CR2. I replaced it with hibernate-core-3.6.10.Final.jar. The code ran fine.
-Added ehcache-core-2.4.3.jar and hibernate-ehcache-3.6.10.Final.jar, and the code worked fine.
-Added the following lines to the project's config file in the <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> bean, under <property name="hibernateProperties">
...
and I get the error java.lang.ClassNotFoundException: net.sf.ehcache.hibernate.EhCacheRegionFactory cannot be found


Seems you already have made some progress

It seems you are using the appropriate properties and class names in your configuration, so I have no clue what's wrong. The EhCacheRegionFactory class is definitely in the ehcache-core-2.4.3.jar dependency. So I'm a bit wondered why this class can not be found. This tutorial provides an Hibernate EhCache Second Level Caching Example. It uses Hibernate 4, but also mentions the differences with Hibernate 3. So maybe you can go through this tutorial and see if you can spot any differences in your configuration. And this article also nicely explains how to configure Hibernate 4 with EhCache higher than 2.4.3, but also mentions how to configure EhCache for Hibernate 3. And finally on the EhCache website itself, you'll find also documentation how to configure it properly.

I think you don't need the hibernate-ehcache-3.6.10.Final.jar dependency, because it seems the ehcache-core-2.4.3.jar dependency already contains the necessary classes (see the net.sf.ehcache.hibernate package). But removing this dependency will probably not solve your issue.

Hope it helps!
Kind regards,
Roel
reply
    Bookmark Topic Watch Topic
  • New Topic
vceplus-200-125    | boson-200-125    | training-cissp    | actualtests-cissp    | techexams-cissp    | gratisexams-300-075    | pearsonitcertification-210-260    | examsboost-210-260    | examsforall-210-260    | dumps4free-210-260    | reddit-210-260    | cisexams-352-001    | itexamfox-352-001    | passguaranteed-352-001    | passeasily-352-001    | freeccnastudyguide-200-120    | gocertify-200-120    | passcerty-200-120    | certifyguide-70-980    | dumpscollection-70-980    | examcollection-70-534    | cbtnuggets-210-065    | examfiles-400-051    | passitdump-400-051    | pearsonitcertification-70-462    | anderseide-70-347    | thomas-70-533    | research-1V0-605    | topix-102-400    | certdepot-EX200    | pearsonit-640-916    | itproguru-70-533    | reddit-100-105    | channel9-70-346    | anderseide-70-346    | theiia-IIA-CIA-PART3    | certificationHP-hp0-s41    | pearsonitcertification-640-916    | anderMicrosoft-70-534    | cathMicrosoft-70-462    | examcollection-cca-500    | techexams-gcih    | mslearn-70-346    | measureup-70-486    | pass4sure-hp0-s41    | iiba-640-916    | itsecurity-sscp    | cbtnuggets-300-320    | blogged-70-486    | pass4sure-IIA-CIA-PART1    | cbtnuggets-100-101    | developerhandbook-70-486    | lpicisco-101    | mylearn-1V0-605    | tomsitpro-cism    | gnosis-101    | channel9Mic-70-534    | ipass-IIA-CIA-PART1    | forcerts-70-417    | tests-sy0-401    | ipasstheciaexam-IIA-CIA-PART3    | mostcisco-300-135    | buildazure-70-533    | cloudera-cca-500    | pdf4cert-2v0-621    | f5cisco-101    | gocertify-1z0-062    | quora-640-916    | micrcosoft-70-480    | brain2pass-70-417    | examcompass-sy0-401    | global-EX200    | iassc-ICGB    | vceplus-300-115    | quizlet-810-403    | cbtnuggets-70-697    | educationOracle-1Z0-434    | channel9-70-534    | officialcerts-400-051    | examsboost-IIA-CIA-PART1    | networktut-300-135    | teststarter-300-206    | pluralsight-70-486    | coding-70-486    | freeccna-100-101    | digitaltut-300-101    | iiba-CBAP    | virtuallymikebrown-640-916    | isaca-cism    | whizlabs-pmp    | techexams-70-980    | ciscopress-300-115    | techtarget-cism    | pearsonitcertification-300-070    | testking-2v0-621    | isacaNew-cism    | simplilearn-pmi-rmp    | simplilearn-pmp    | educationOracle-1z0-809    | education-1z0-809    | teachertube-1Z0-434    | villanovau-CBAP    | quora-300-206    | certifyguide-300-208    | cbtnuggets-100-105    | flydumps-70-417    | gratisexams-1V0-605    | ituonline-1z0-062    | techexams-cas-002    | simplilearn-70-534    | pluralsight-70-697    | theiia-IIA-CIA-PART1    | itexamtips-400-051    | pearsonitcertification-EX200    | pluralsight-70-480    | learn-hp0-s42    | giac-gpen    | mindhub-102-400    | coursesmsu-CBAP    | examsforall-2v0-621    | developerhandbook-70-487    | root-EX200    | coderanch-1z0-809    | getfreedumps-1z0-062    | comptia-cas-002    | quora-1z0-809    | boson-300-135    | killtest-2v0-621    | learncia-IIA-CIA-PART3    | computer-gcih    | universitycloudera-cca-500    | itexamrun-70-410    | certificationHPv2-hp0-s41    | certskills-100-105    | skipitnow-70-417    | gocertify-sy0-401    | prep4sure-70-417    | simplilearn-cisa    |
http://www.pmsas.pr.gov.br/wp-content/    | http://www.pmsas.pr.gov.br/wp-content/    |