【问题标题】:Tomcat + OpenJPATomcat + OpenJPA
【发布时间】:2016-06-02 11:38:44
【问题描述】:

我正在尝试将应用程序从 WLP 迁移到 Tomcat,在尝试部署 war 时,出现以下异常

org.apache.openjpa.persistence.ArgumentException:此配置不允许运行时优化,但以下列出的类型在构建时或类加载时未使用 javaagent 增强:

我尝试添加 javaagent 以启用运行时加载 JAVA_OPTS=%JAVA_OPTS% -javaagent:"$CATALINA_HOME/lib/openjpa-2.X.jar

here 中所述,但没有成功。

任何建议或观点。

【问题讨论】:

  • 尝试添加:-
  • 您确定需要“运行时优化”,也就是编织。 J2EE 容器需要该功能,在 J2SE 环境中您需要 JavaAgent。通常编织用于发出字节码以扩展在 ManyToOne/OneToOne 中使用的类,因此可以延迟获取这些类。除非您禁用共享缓存,或者拥有大量数据,否则可能根本不需要此类优化。

标签: tomcat openjpa


【解决方案1】:

我总是建议使用编译时优化。这是 JPA 实现为 jpa 增强类文件自动生成 JPA 函数的任务。

ScopedEntityManager utility project in Github 中查看此 build.xml。

<?xml version="1.0" encoding="UTF-8"?>
<project name="jpaexample" default="build" basedir=".">
   ...clip...
    <target name="compile" depends="clean" description="Compile classes">
        <mkdir dir="${classes}"/>
        <javac srcdir="${src}" destdir="${classes}" target="1.7" source="1.7" encoding="ISO-8859-1" 
            debug="true" debuglevel="lines,source" includeantruntime="false"
            excludes="" >
            <classpath refid="libs" />
        </javac>
        <antcall target="jpaenhance" />
    </target>


    <target name="jpaenhance" description="Preprocess entity classes, enhance for JPA use">
        <path id="jpa.enhancement.classpath">
            <pathelement location="${classes}" />
            <fileset dir="./webapp/WEB-INF/lib">
                <include name="*.jar" />
                <exclude name="${name}.jar" />
            </fileset>
        </path>

        <taskdef name="openjpac" classname="org.apache.openjpa.ant.PCEnhancerTask">
            <classpath refid="jpa.enhancement.classpath" />
        </taskdef>  
        <openjpac>
            <classpath refid="jpa.enhancement.classpath" />
            <config propertiesFile="./webapp/WEB-INF/classes/META-INF/persistence.xml" />           
        </openjpac>
    </target>
   ...clip...
</project>

【讨论】:

    猜你喜欢
    • 2013-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多