jpa,尝试从实体创建表,未找到类ExpressionVisitor

时间:2015-11-11 23:20:46

标签: java jpa eclipselink wildfly wildfly-8

我在eclipse中从实体创建表时遇到了一些麻烦。 这个项目最初是在windows上的eclipse上,我从mysql表创建实体并将其导入到项目中。一切都很好。昨天我决定从windows切换到ubuntu,因此我只是备份了eclipse项目,以为我可以从实体创建表格。

所以当我右键点击项目时 - > JPA工具 - >从实体创建表,

我收到以下错误:

  

线程中的异常" main"本地异常堆栈:       异常[EclipseLink-30005](Eclipse Persistence Services - 2.6.0.v20140809-296a69f):org.eclipse.persistence.exceptions.PersistenceUnitLoadingException       异常描述:使用ClassLoader搜索持久性归档时抛出异常:org.eclipse.persistence.dynamic.DynamicClassLoader@6eceb130       内部异常:javax.persistence.PersistenceException:异常[EclipseLink-28018](Eclipse Persistence Services - 2.6.0.v20140809-296a69f):org.eclipse.persistence.exceptions.EntityManagerSetupException       异常说明:PersistenceUnit [my-pu]的预部署失败。       内部异常: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)       在org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:179)       在javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)       在org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.buildEntityManagerFactory(Main.java:94)       在org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.execute(Main.java:80)       在org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.main(Main.java:68)       引发者:javax.persistence.PersistenceException:异常[EclipseLink-28018](Eclipse Persistence Services - 2.6.0.v20140809-296a69f):org.eclipse.persistence.exceptions.EntityManagerSetupException       异常说明:PersistenceUnit [my-pu]的预部署失败。       内部异常:java.lang.NoClassDefFoundError:org / eclipse / persistence / jpa / jpql / parser / ExpressionVisitor       at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createPredeployFailedPersistenceException(EntityManagerSetupImpl.java:1973)       在org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1964)       在org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.callPredeploy(JPAInitializer.java:98)       在org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:96)       ......还有5个       引起:异常[EclipseLink-28018](Eclipse Persistence Services - 2.6.0.v20140809-296a69f):org.eclipse.persistence.exceptions.EntityManagerSetupException       异常说明:PersistenceUnit [my-pu]的预部署失败。       内部异常:java.lang.NoClassDefFoundError:org / eclipse / persistence / jpa / jpql / parser / ExpressionVisitor       at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:231)       ......还有9个       引起:java.lang.NoClassDefFoundError:org / eclipse / persistence / jpa / jpql / parser / ExpressionVisitor       at org.eclipse.persistence.internal.jpa.metadata.queries.NamedQueryMetadata.addJPAQuery(NamedQueryMetadata.java:105)       在org.eclipse.persistence.internal.jpa.metadata.queries.NamedQueryMetadata.process(NamedQueryMetadata.java:192)       在org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processQueries(MetadataProject.java:1630)       在org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.addNamedQueries(MetadataProcessor.java:148)       at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1915)       ......还有7个       引起: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个

Wildfly默认使用hibernate作为JPA提供程序,我确实将它切换到EclipseLink。

2 个答案:

答案 0 :(得分:1)

我将目标库更改为properties->中的用户定义库。 JPA。

然后我跟着这个啧啧:https://www.youtube.com/watch?v=wjCCQSJVtVQ

基本上:

<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> 

然后我切换回旧的persistence.xml

答案 1 :(得分:0)

您需要在persistence.xml中将提供程序添加到持久性单元 并确保eclipse链接jar在Wildfly类路径中

<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

查看更多https://docs.jboss.org/author/display/WFLY8/JPA+Reference+Guide#JPAReferenceGuide-UpdateyourPersistence.xmlforHibernate4.3.0