I am trying to initialize a Hibernate session in my project-web-server. For that I am using a library I wrote project-data-model that is linked as dependency in maven:
project-web-server pom.xml:
<dependency>
<groupId>com.preoject.server</groupId>
<artifactId>project-data-model</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
HibernateSession.java
is therefore in project-data-model; this is how I use it in project-web-server:
public class ServerConfig implements ServletContextListener {
public void contextInitialized(ServletContextEvent event) {
try {
HibernateSession.initialize();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
public void contextDestroyed(ServletContextEvent event) {
// Do stuff on shutdown.
}
}
Even though I referenced the data model project as dependency I am getting a java.lang.NoClassDefFoundError
exception:
java.lang.NoClassDefFoundError: org/hibernate/Interceptor
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.google.appengine.tools.development.agent.runtime.RuntimeHelper.checkRestricted(RuntimeHelper.java:70)
at com.google.appengine.tools.development.agent.runtime.Runtime.checkRestricted(Runtime.java:65)
at com.project.datamodel.HibernateSession.initialize(HibernateSession.java:19)
at com.project.web.server.ServerConfig.contextInitialized(ServerConfig.java:14)
...
I can't figure out what I have to do here. The folder war/WEB-INF/lib
does not contain any Hibernate related libraries; could that be the problem? I'm not sure because I have added the Hibernate dependencies to the parent pom.xml:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.2.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>4.0.1.Final</version>
<classifier>tests</classifier>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.0.1.Final</version>
</dependency>