0

I was trying Spring + JPA + Hibernate on my local but I am getting below error. I tried to change exclude the version of dom4j(as mentioned here) but is of no use .

Here is Error

2018-01-03 02:01:40 ERROR DispatcherServlet:502 - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactoryBean' defined in ServletContext resource [/WEB-INF/configuration/recon-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/dom4j/io/STAXEventReader
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1078)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:857)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
    at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634).........

Below is the POM.xml enter image description here

And the Servlet.xml

enter image description here

I have tried to remove dom4j but it does not work and also changed hibernate version from 5.2.12 to 5.0.12 but looks like it does not work.

Thanks in advance for your suggestions .

Karn Kumar
  • 13
  • 1
  • 10
  • Looks like this problem: https://stackoverflow.com/questions/36222306/caused-by-java-lang-classnotfoundexception-org-dom4j-io-staxeventreader – Ralph Jan 02 '18 at 21:09
  • 1
    Possible duplicate of [Caused by: java.lang.ClassNotFoundException: org.dom4j.io.STAXEventReader](https://stackoverflow.com/questions/36222306/caused-by-java-lang-classnotfoundexception-org-dom4j-io-staxeventreader) – jny Jan 02 '18 at 21:34
  • @Ralph : I have tried to implement the solution given in link but it is not working. I have mentioned same in my question. – Karn Kumar Jan 03 '18 at 06:20
  • After further reducing hibernate version to 4.3.11.Final it is working it is working fine. Not sure why not working for 5.0 onward versions of Hibernate – Karn Kumar Jan 03 '18 at 07:47

1 Answers1

0

Here is the answear: Caused by: java.lang.ClassNotFoundException: org.dom4j.io.STAXEventReader Also your pom dependencies section looks way overcomplicated.

Kawior
  • 21
  • 1
  • Thanks for comment , but I had this link already mentioned in the question. Ultimately I have to degrade my Hibernate , Spring and Spring-jpa versions as below : 4.3.12.RELEASE 4.3.11.Final Spring-JPA1.5.2.RELEASE – Karn Kumar Jan 10 '18 at 13:06