When I have started my Spring MVC project I have got exception below:
javax.servlet.ServletException: Servlet.init() for servlet appServlet threw exception
And the most important thing is the root cause:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'sessionFactory' defined in ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]:
Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError:
org/hibernate/cfg/EJB3DTDEntityResolver
I have looked up this class: http://docs.jboss.org/hibernate/orm/3.5/api/org/hibernate/cfg/EJB3DTDEntityResolver.html and here http://search.maven.org/#search%7Cga%7C1%7Cfc%3Aorg.hibernate.cfg.EJB3DTDEntityResolver
And I have found out that it is part of hibernate-annotations. But I have some Hibernate dependecies in my POM.xml
file:
<!-- Hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.1.4.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.5.6-Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.3.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>4.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-envers</artifactId>
<version>4.1.4.Final</version>
</dependency>
I don't know what's wrong with my project. In general this exception have occured when I have declared this in my Servlet Dispatcher:
<!-- Hibernate session factory -->
<beans:bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<beans:property name="dataSource">
<beans:ref bean="dataSource" />
</beans:property>
<beans:property name="hibernateProperties">
<beans:props>
<beans:prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</beans:prop>
<beans:prop key="hibernate.show_sql">true</beans:prop>
</beans:props>
</beans:property>
<beans:property name="annotatedClasses">
<beans:list>
<beans:value>hutter.pl.dao.Users</beans:value>
</beans:list>
</beans:property>
</beans:bean>
<beans:bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<beans:property name="sessionFactory" ref="sessionFactory" />
</beans:bean>
<!-- Hibernate session factory end -->
Could you give me some advices?