Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
JPAContainer with javax.persistence.PersistenceException: Exception [Eclips
HI, I am using JPAContainer to connect with MySQL database.
- I have included ConnectorJ with MySQL in the library and under the folder of WEB-INF/lib, please see attachment file.
- Anyone has the same problem and knows how to solve it?
- when I use the same code and persistence file in another project it works fine. but with this project it gives me
javax.persistence.PersistenceException: Exception [EclipseLink-4003] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Configuration error. Class [com.mysql.jdbc.Driver] not found.
- Here is my code
package com.example.displaydatabase;
import javax.persistence.PersistenceContext;
import javax.servlet.annotation.WebServlet;
import com.howinecafe.bean.MemberBean;
import com.vaadin.addon.jpacontainer.JPAContainer;
import com.vaadin.addon.jpacontainer.JPAContainerFactory;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Table;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
@PersistenceContext(name="persistence/em",unitName="MEMBERBEAN")
@SuppressWarnings("serial")
@Theme("displaydatabase")
public class DisplaydatabaseUI extends UI {
public static final String PERSISTENCE_UNIT = "MEMBERBEAN";
@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = DisplaydatabaseUI.class)
public static class Servlet extends VaadinServlet {
}
@Override
protected void init(VaadinRequest request) {
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);
JPAContainer<MemberBean> memberContainer = JPAContainerFactory.make(MemberBean.class,"MEMBERBEAN");
Table myTable = new Table("This is my Table",memberContainer);
myTable.setSelectable(true);
myTable.setImmediate(true);
layout.addComponent(myTable);
}
}
- Persistence File
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="MEMBERBEAN">
<provider>
org.eclipse.persistence.jpa.PersistenceProvider
</provider>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.jdbc.platform"
value="org.eclipse.persistence.platform.database.MySQLPlatform" />
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/howine_db"/>
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="1025ho" />
<property name="eclipselink.logging.level" value="FINE" />
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database"/>
</properties>
</persistence-unit>
</persistence>
Hi
I found the problem is I used import to add the mysql-connector-java-5.0.8-bin.jar file under the
WebContent\WEB-INF\lib which will not find com.mysql.jdbc.Driver class.
To Fix, just copy the entire mysql-connector-java-5.0.8-bin.jar and put under the WebContent\WEB-INF\lib
please see attachment fixed.jpg file.
James Ho: HI, I am using JPAContainer to connect with MySQL database.
- I have included ConnectorJ with MySQL in the library and under the folder of WEB-INF/lib, please see attachment file.
- Anyone has the same problem and knows how to solve it?
- when I use the same code and persistence file in another project it works fine. but with this project it gives me
javax.persistence.PersistenceException: Exception [EclipseLink-4003] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Configuration error. Class [com.mysql.jdbc.Driver] not found.
- Here is my code
package com.example.displaydatabase;
import javax.persistence.PersistenceContext;
import javax.servlet.annotation.WebServlet;import com.howinecafe.bean.MemberBean;
import com.vaadin.addon.jpacontainer.JPAContainer;
import com.vaadin.addon.jpacontainer.JPAContainerFactory;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Table;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;@PersistenceContext(name="persistence/em",unitName="MEMBERBEAN")
@SuppressWarnings("serial")
@Theme("displaydatabase")
public class DisplaydatabaseUI extends UI {
public static final String PERSISTENCE_UNIT = "MEMBERBEAN";
@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = DisplaydatabaseUI.class)
public static class Servlet extends VaadinServlet {
}@Override
protected void init(VaadinRequest request) {
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);
JPAContainer<MemberBean> memberContainer = JPAContainerFactory.make(MemberBean.class,"MEMBERBEAN");
Table myTable = new Table("This is my Table",memberContainer);
myTable.setSelectable(true);
myTable.setImmediate(true);
layout.addComponent(myTable);
}}
- Persistence File
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0"><persistence-unit name="MEMBERBEAN">
<provider>
org.eclipse.persistence.jpa.PersistenceProvider
</provider><exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.jdbc.platform"
value="org.eclipse.persistence.platform.database.MySQLPlatform" /><property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/howine_db"/>
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="1025ho" /><property name="eclipselink.logging.level" value="FINE" />
<property name="eclipselink.ddl-generation" value="create-tables" /><property name="eclipselink.ddl-generation.output-mode" value="database"/>
</properties>
</persistence-unit>
</persistence>