Note that there are some explanatory texts on larger screens.

plurals
  1. POTomcat 7, Hibernate 3.6, PostgreSQL 9.2 | Maven java.lang.NoClassDefFoundError
    text
    copied!<p>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.</p> <p>Libraries before maven:</p> <ul> <li>hibernate3.jar (Hibernate 3.6.Final)</li> <li>log4j.jar (1.2.8)</li> <li>postgresql-9.2-1002.jdbc4.jar (PostgreSQL 9.2 JDBC4)</li> <li>commons-codec1.8.jar (Apache Commons Codec 1.8)</li> <li>commons-fileupload1-3.jar (Apache Commons Fileupload 1.3)</li> <li>Commons-lang3-3-1 (Apache Commons Lang3 3.1)</li> <li>cos.jar (O'Reilly 05Nov2005)</li> </ul> <p>After /Configure/Convert To Maven I added all the dependencys:</p> <pre><code>&lt;dependencies&gt; &lt;!-- hibernate framework --&gt; &lt;dependency&gt; &lt;groupId&gt;org.hibernate&lt;/groupId&gt; &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt; &lt;version&gt;3.6.10.Final&lt;/version&gt; &lt;/dependency&gt; &lt;!-- logging --&gt; &lt;dependency&gt; &lt;groupId&gt;org.slf4j&lt;/groupId&gt; &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt; &lt;version&gt;1.7.5&lt;/version&gt; &lt;/dependency&gt; &lt;!-- PostgreSQL-JDBC --&gt; &lt;dependency&gt; &lt;groupId&gt;org.postgresql&lt;/groupId&gt; &lt;artifactId&gt;postgresql&lt;/artifactId&gt; &lt;version&gt;9.2-1002-jdbc4&lt;/version&gt; &lt;/dependency&gt; &lt;!-- upload - O'reilly COS --&gt; &lt;dependency&gt; &lt;groupId&gt;servlets.com&lt;/groupId&gt; &lt;artifactId&gt;cos&lt;/artifactId&gt; &lt;version&gt;05Nov2002&lt;/version&gt; &lt;/dependency&gt; &lt;!-- Apache Commons --&gt; &lt;dependency&gt; &lt;groupId&gt;commons-codec&lt;/groupId&gt; &lt;artifactId&gt;commons-codec&lt;/artifactId&gt; &lt;version&gt;1.8&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;commons-fileupload&lt;/groupId&gt; &lt;artifactId&gt;commons-fileupload&lt;/artifactId&gt; &lt;version&gt;1.3&lt;/version&gt; &lt;/dependency&gt; &lt;/dependencies&gt; </code></pre> <p>to the project, but somehow always get an <strong>java.lang.NoClassDefFoundError</strong>:</p> <pre><code>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) </code></pre> <p>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):</p> <pre><code>protected List searchBatch(String hqlQuery, boolean close) { Session session = HibernateUtil.currentSession(); Transaction tx = session.beginTransaction(); </code></pre> <p>I tried different versions of all libraries but still didn't make any progress. I found out that the <strong>java.lang.NoClassDefFoundError</strong> 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.</p> <p>Here my .classpath:</p> <p><a href="http://i43.tinypic.com/2wovi82.jpg" rel="nofollow noreferrer">a class path http://i43.tinypic.com/2wovi82.jpg</a></p> <p>I am really desperate and hope someone might have an idea!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload