Reputation: 49
I am working on a bigger project, that needs to get maven'd. So far I have successfully tested the project by including all the required .jar files in the WEB-INF/lib.
Libraries before maven:
After /Configure/Convert To Maven I added all the dependencys:
<dependencies>
<!-- hibernate framework -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.6.10.Final</version>
</dependency>
<!-- logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.5</version>
</dependency>
<!-- PostgreSQL-JDBC -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.2-1002-jdbc4</version>
</dependency>
<!-- upload - O'reilly COS -->
<dependency>
<groupId>servlets.com</groupId>
<artifactId>cos</artifactId>
<version>05Nov2002</version>
</dependency>
<!-- Apache Commons -->
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
to the project, but somehow always get an java.lang.NoClassDefFoundError:
java.lang.NoClassDefFoundError: Could not initialize class business.HibernateUtil
business.HibernateEngine.searchBatch(HibernateEngine.java:168)
business.HibernateEngine.searchBatch(HibernateEngine.java:163)
business.PersonAdmin.searchUser(PersonAdmin.java:222)
ui.login2.doGet(login2.java:161)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
Both classes within the package business (HibernateUtil and HibernateEngine) set up the session used in the programme. Here it crashes in HibernateEngine (Line 167-169):
protected List searchBatch(String hqlQuery, boolean close) {
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
I tried different versions of all libraries but still didn't make any progress. I found out that the java.lang.NoClassDefFoundError is often caused by multiple imported identical libraries. Could it be that it has something to do with the hibernate-core import? I checked its maven repository, but somehow i dont find any double libraries.
Here my .classpath:
I am really desperate and hope someone might have an idea!
Upvotes: 0
Views: 1110
Reputation: 623
Take a look at this post: Hibernate java.lang.NoClassDefFoundError: org/hibernate/util/DTDEntityResolver
They removed 'hibernate-tools' and added 'hibernate-core'.
Upvotes: 1