Note that there are some explanatory texts on larger screens.

plurals
  1. POpre configured netbeans project with NoSuchMethodError hibernate and spring conflict
    text
    copied!<p>so I'm trying to get my Java Application to connect to SQL Server 2012 through the <a href="http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&amp;id=11774" rel="nofollow noreferrer"> Microsoft JDBC Driver 4.0 for SQL Server</a>, and everything seems to be going well but hibernate just keeps coming back with <code>NullExceptions</code> and won't execute anything within the <code>try/catch</code> (hence the <code>NullException</code>), I have absolutely no idea why. Here is the <a href="http://pastebin.com/4tVppVj3" rel="nofollow noreferrer">pastebin</a> from netbeans console (<code>e.getMessage()</code>) running hibernate (for the purposes of this question, I am using an example table called <code>prime_table</code>).</p> <p>In the pastebin log, you'll notice ...</p> <blockquote> <p>Feb 11, 2013 5:21:04 PM org.hibernate.cfg.Configuration doConfigure INFO: Configured SessionFactory: null</p> </blockquote> <p>any ideas on why this is occuring? (I'm not sure, but it may be relevant to the overall stack trace).</p> <p><strong>Other logs <em>(During JSP build)</em></strong></p> <ul> <li><a href="http://pastebin.com/YZPLtF2h" rel="nofollow noreferrer">Netbeans (run)</a></li> <li><a href="http://pastebin.com/UpPTETXh" rel="nofollow noreferrer">Apache tomcat</a></li> <li><a href="http://pastebin.com/HG6CQP18" rel="nofollow noreferrer">Apache tomcat log</a></li> <li><a href="http://pastebin.com/yq6WDUJd" rel="nofollow noreferrer">Sql server ERRORLOG.log</a></li> <li><strong><a href="http://pastebin.com/kd7Ssykr" rel="nofollow noreferrer">Hibernate throwable stacktrace</a> (Update 2/14/2013)</strong></li> </ul> <p><em>All logs will be available up until Mid/Late March 2013</em></p> <p><strong>Resources, I've been reading</strong></p> <ul> <li><a href="http://anshuchoudhury.wordpress.com/category/j2ee/hibernate/hibernate-tutorial-example/" rel="nofollow noreferrer">Hibernate Example</a></li> <li><a href="http://www.coderanch.com/t/559936/ORM/databases/Null-Pointer-Exception-session-flush" rel="nofollow noreferrer">[Help] Null Pointer Exception in session.flush() Hibernate</a></li> <li><a href="http://www.coderanch.com/t/215322/ORM/databases/hibernate-cfg-xml" rel="nofollow noreferrer">hibernate.cfg.xml not found</a></li> <li><a href="https://stackoverflow.com/questions/3315941/hibernate-map-java-long-to-mysql-bigint-error">hibernate map java Long to MySQL BIGINT error</a></li> </ul> <p><strong>Pre Configured Netbeans Project Setup <a href="http://iforce.co.nz/i/o5e1aouu.ruz.png" rel="nofollow noreferrer"><code>commandline: tree /f</code></a></strong></p> <p><a href="http://iforce.co.nz/i/llroxgez.s5s.png" rel="nofollow noreferrer">netbeans http://iforce.co.nz/i/llroxgez.s5s.png</a></p> <p><strong>Hibernate.cfg.xml</strong> (Added <code>"hibernate.cache.provider_class"</code> as suggested by <a href="https://stackoverflow.com/users/27649/hari">Hari</a>)</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt; &lt;hibernate-configuration&gt; &lt;session-factory&gt; &lt;property name="hibernate.cache.provider_class"&gt;org.hibernate.cache.HashtableCacheProvider&lt;/property&gt; &lt;property name="hibernate.connection.driver_class"&gt;com.microsoft.sqlserver.jdbc.SQLServerDriver&lt;/property&gt; &lt;property name="hibernate.connection.url"&gt;jdbc:sqlserver://Michael-PC:1433;databaseName=PrimeDB&lt;/property&gt; &lt;property name="hibernate.connection.username"&gt;sa&lt;/property&gt; &lt;property name="hibernate.connection.password"&gt;online12&lt;/property&gt; &lt;property name="hibernate.connection.pool_size"&gt;10&lt;/property&gt; &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.SQLServerDialect&lt;/property&gt; &lt;property name="hibernate.show_sql"&gt;true&lt;/property&gt; &lt;property name="hibernate.hbm2ddl.auto"&gt;update&lt;/property&gt; &lt;!-- Data Mappings --&gt; &lt;mapping resource="prime.hbm.xml"/&gt; &lt;/session-factory&gt; &lt;/hibernate-configuration&gt; </code></pre> <p><strong>Prime</strong></p> <pre><code>public class Prime { private long prime; public void setPrime(long nPrime){ this.prime = nPrime; } public long getPrime(){ return this.prime; } } </code></pre> <p><strong>prime.hbm.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt; &lt;hibernate-mapping&gt; &lt;class name="nz.co.xyleap.db.Prime" table="prime_table"&gt; &lt;id name="prime" type="long" column="prime" /&gt; &lt;/class&gt; &lt;/hibernate-mapping&gt; </code></pre> <p><strong>Prime Table</strong></p> <pre><code>CREATE TABLE prime_table ( [prime] bigint PRIMARY KEY NOT NULL, ) </code></pre> <p><strong>Session function or <code>FirstExample.java</code></strong></p> <pre><code>public class FirstExample { public static void main(String[] args) { FirstExample ex = new FirstExample(); ex.session(); } public void session() { Session session = null; try { // This step will read hibernate.cfg.xml and prepare hibernate for use SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); session = sessionFactory.openSession(); session.beginTransaction(); //Create new instance of Contact and set values in it by reading them from form object System.out.println("inserting record 13"); Prime p = new Prime(); p.setPrime(13); session.save(p); System.out.println("Done"); } catch (Exception e) { System.out.println(e.getMessage()); } finally { // Actual contact insertion will happen at this step session.flush(); session.close(); } } } </code></pre> <p>As far as I know everything should be correct, and I should be able to insert records from Java Hibernate to my SQL database. But for some reason I can't :-/</p> <p>UPDATE : Hibernate on its own, runs fine. But in conjunction with Spring, these errors occur. (More information in comments).</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