I'm having some troubles creating tables from entities in eclipse. This project was originally on eclipse on windows where I created entities from mysql tables and imported it to the project. Everything was working great. Yesterday I decided to switch from windows to ubuntu and thus I just made a back up of the eclipse project thinking I could create tables from the entities anyway.
So when I right click on the project -> JPA tools -> create tables from entities,
I get the following error :
Exception in thread "main" Local Exception Stack: Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.6.0.v20140809-296a69f): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: org.eclipse.persistence.dynamic.DynamicClassLoader@6eceb130 Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.6.0.v20140809-296a69f): org.eclipse.persistence.exceptions.EntityManagerSetupException Exception Description: Predeployment of PersistenceUnit [my-pu] failed. Internal Exception: java.lang.NoClassDefFoundError: org/eclipse/persistence/jpa/jpql/parser/ExpressionVisitor at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:127) at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:107) at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:179) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55) at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.buildEntityManagerFactory(Main.java:94) at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.execute(Main.java:80) at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.main(Main.java:68) Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.6.0.v20140809-296a69f): org.eclipse.persistence.exceptions.EntityManagerSetupException Exception Description: Predeployment of PersistenceUnit [my-pu] failed. Internal Exception: java.lang.NoClassDefFoundError: org/eclipse/persistence/jpa/jpql/parser/ExpressionVisitor at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createPredeployFailedPersistenceException(EntityManagerSetupImpl.java:1973) at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1964) at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.callPredeploy(JPAInitializer.java:98) at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:96) ... 5 more Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.6.0.v20140809-296a69f): org.eclipse.persistence.exceptions.EntityManagerSetupException Exception Description: Predeployment of PersistenceUnit [my-pu] failed. Internal Exception: java.lang.NoClassDefFoundError: org/eclipse/persistence/jpa/jpql/parser/ExpressionVisitor at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:231) ... 9 more Caused by: java.lang.NoClassDefFoundError: org/eclipse/persistence/jpa/jpql/parser/ExpressionVisitor at org.eclipse.persistence.internal.jpa.metadata.queries.NamedQueryMetadata.addJPAQuery(NamedQueryMetadata.java:105) at org.eclipse.persistence.internal.jpa.metadata.queries.NamedQueryMetadata.process(NamedQueryMetadata.java:192) at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processQueries(MetadataProject.java:1630) at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.addNamedQueries(MetadataProcessor.java:148) at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1915) ... 7 more Caused by: java.lang.ClassNotFoundException: org.eclipse.persistence.jpa.jpql.parser.ExpressionVisitor at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 12 more
Wildfly by default uses hibernate as JPA provider, I did switch it to EclipseLink.
I changed the target library to be the user defined library in properties-> jpa.
Then I followed this tut : https://www.youtube.com/watch?v=wjCCQSJVtVQ
basically :
<persistence-unit name="my-pu" transaction-type="RESOURCE_LOCAL">
<jta-data-source>java:/forumcsDS</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/forumcs"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.password" value="X"/>
<property name="eclipseLink.ddl-generation" value="drop-and-create-tables"/>
<property name="eclipseLink.ddl-generation.output-mode" value="database"/>
</properties>
</persistence-unit>
and then I switched back to the old persistence.xml