Kiran
Kiran

Reputation: 193

Tomcat + OpenJPA

I am trying to migrate an application from WLP to Tomcat, when trying to deploy the war , I am getting the below exception

org.apache.openjpa.persistence.ArgumentException: This configuration disallows runtime optimization, but the following listed types were not enhanced at build time or at class load time with a javaagent:

I tried adding javaagent to enable runtime loading JAVA_OPTS=%JAVA_OPTS% -javaagent:"$CATALINA_HOME/lib/openjpa-2.X.jar

as mentioned in here but no success.

Any suggestion or points.

Upvotes: 0

Views: 641

Answers (1)

Whome
Whome

Reputation: 10400

I always suggest using a compile-time optimization. It's a task where JPA implementation auto-generates JPA functions for jpa enhanced class files.

See this build.xml in ScopedEntitymanager2 utility project in Github

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

Upvotes: 0

Related Questions