【问题标题】:how to specify dynamic class loader with eclipse link如何使用 Eclipse 链接指定动态类加载器
【发布时间】:2013-02-21 22:59:30
【问题描述】:

环境: Tomcat- web 服务器、eclipselink-2.4.1(Juno) JPA、Odata4j 我正在使用 Eclipse 链接进行 JPA(从表中生成动态实体)。 我的 persistence.xml 看起来像

<persistence-unit name="abcLink"
        transaction-type="RESOURCE_LOCAL">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <mapping-file>META-INF/eclipselink-orm.xml</mapping-file>           
        <properties>
            <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
            <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/netspectiveauthentication?zeroDateTimeBehavior=convertToNull"/>
            <property name="javax.persistence.jdbc.user" value="root" />
            <property name="javax.persistence.jdbc.password" value="" />
            <property name="eclipselink.ddl-generation" value="create-tables" />
            <property name="eclipselink.logging.level" value="INFO" />
            <property name="eclipselink.logging.exceptions" value="true" />     
        </properties>
    </persistence-unit> 

和 在提供者类中

String persistenceUnitName = "abcLink";      
          EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnitName,properties);
            emf.createEntityManager();                   
            return new JPAProducer(emf, "abcd", 20);

我将它用于 ODATA4j 实现,因此属性将通过覆盖获得 ODataProducer 创建函数 运行时出现以下错误

javax.persistence.PersistenceException: Exception [EclipseLink-28017] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Unable to predeploy PersistenceUnit [AuthenticationServiceEclipseMysqlLink] in invalid state [DeployFailed].
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28019] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Deployment of PersistenceUnit [AuthenticationServiceEclipseMysqlLink] failed. Close all factories for this PersistenceUnit.
Internal Exception: Exception [EclipseLink-7328] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.ValidationException
Exception Description: When using VIRTUAL access a DynamicClassLoader must be provided when creating the entity manager factory using the eclipselink property [eclipselink.classloader]. That is, createEntityManagerFactory(String persistenceUnitName, Map properties) and add a new DynamicClassLoader() to the Map properties.
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1226)
    at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:134)
    at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)

我认为错误很明显,但我想知道,如何通过属性提供动态类加载器。或任何其他方式来消除此错误。

【问题讨论】:

    标签: java jpa eclipselink odata4j


    【解决方案1】:

    看看this example,在main方法的开头。

    【讨论】:

    • 感谢您的样品。我在您的示例文件的帮助下设置了类加载器。之后我得到了一个在bugs.eclipse.org/bugs/show_bug.cgi?id=397283 中指定的错误。所以没有动态的进展。暂时停止动态,现在检查静态类。您能以任何方式建议我在哪里可以找到这些类型的示例。
    • Google :) 说真的,您应该找出包含重要关键字的错误消息的子字符串,然后用 Google 搜索该子字符串。例如:google.com/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-01-24
    • 1970-01-01
    • 2014-10-10
    • 2010-09-27
    • 2015-01-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多