Note that there are some explanatory texts on larger screens.

plurals
  1. POClassNotFoundException: derby ClientDriver (Spring MVC + Hibernate JPA)
    primarykey
    data
    text
    <p>I'm learning Spring MVC, and tried to connect to a database with hibernate. The MVC part worked, and in a separate project, I also could connect and work with the Derby database. But when I tried to put the two together, I failed.</p> <p>root cause:</p> <pre><code>java.lang.NoClassDefFoundError: org/apache/derby/jdbc/ClientDriver hu.pikk.controller.PikkController.test(PikkController.java:42) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:606) org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219 </code></pre> <p>I don't understand why this is, because I put in the maven file the derby dependency:</p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;org.apache.derby&lt;/groupId&gt; &lt;artifactId&gt;derby&lt;/artifactId&gt; &lt;version&gt;10.10.1.1&lt;/version&gt; &lt;/dependency&gt; </code></pre> <p>And I also put the derbyclient.jar file to my classpath:</p> <pre><code>..Java\jdk1.7.0_45\db\lib\derbyclient.jar </code></pre> <p>If anyone has any ideas, why it cannot find the class, I would be pleased to know! I tried to search google and stackoverflow for similar errors, but none of the answers were useful.</p> <p>I tried to create an entitymanager in my controller class in different ways:</p> <p><code></p> <pre><code>@RequestMapping(value={"/","/test"},method = RequestMethod.GET) public String test(ModelMap model) { try { DriverManager.registerDriver(new org.apache.derby.jdbc.ClientDriver()); } catch (SQLException e) { e.printStackTrace(); } ClientDriver driver = new ClientDriver(); // factory = Persistence.createEntityManagerFactory("punit"); //Specified JDBC Driver org.apache.derby.jdbc.ClientDriver could not be loaded // manager = factory.createEntityManager(); // HibernatePersistence hp = new HibernatePersistence(); // factory = hp.createEntityManagerFactory("persistence.xml",null); if(factory!=null){ manager = factory.createEntityManager(); }else{ System.out.println( "### FACTORY IS NULL ### "); } //manager.getTransaction().begin(); //Employee first = manager.find(Employee.class, 1); //manager.getTransaction().commit(); //model.addAttribute("employee", first); if(manager==null){ model.addAttribute("message", "Persistence manager is NULL"); }else{ model.addAttribute("message", "Persistence manager is not NULL! Hurray!"); } return "test"; } </code></pre> <p></code></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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