Tomcat + OpenJPA

时间:2016-06-02 11:38:44

标签: tomcat openjpa

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

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

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

here中所述,但没有成功。

任何建议或要点。

1 个答案:

答案 0 :(得分:0)

我总是建议使用编译时优化。这是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>