Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[m2e-users] Fwd: Problem with web application migrated to Maven (Eclipse Kepler)

Hi all,

I have been trying to figure out this issue for quite some time now. I have converted a web application project into a Maven project. Everything seems to be functional, except one thing: enhancing the OpenJPA entities. Before, I was calling an enhance.xml with ant to do this. I have attached this file.

I have tried numerous things that I found:

http://openjpa.apache.org/enhancement-with-maven.html

Decompiling the persistence classes also shows me they are implementing PersistenceCapable so normally, they should be anhanced. When running a unit test however, I always get the same error:

org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is <openjpa-2.2.2-r422266:1468616 nonfatal user error> 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: "
xxx.monitoring.persistence.core.ProcessStepTemplate
xxx.monitoring.persistence.core.Setting
xxx.monitoring.persistence.core.ProcessStep
xxx.monitoring.persistence.core.User
xxx.monitoring.persistence.core.Process
xxx.monitoring.persistence.core.ProcessTypeTemplate
xxx.monitoring.persistence.core.UserRole".
    at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:428)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:372)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:417)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:255)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631)
    at multi.monitoring.business.impl.UserRoleServiceImpl$$EnhancerByCGLIB$$4dfda190.createUserRole(<generated>)
    at multi.monitoring.testbench.UserTest.userRole(UserTest.java:56)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
    at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
    at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: <openjpa-2.2.2-r422266:1468616 nonfatal user error> 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: "
xxx.monitoring.persistence.core.ProcessStepTemplate
xxx.monitoring.persistence.core.Setting
xxx.monitoring.persistence.core.ProcessStep
xxx.monitoring.persistence.core.User
xxx.monitoring.persistence.core.Process
xxx.monitoring.persistence.core.ProcessTypeTemplate
xxx.monitoring.persistence.core.UserRole".
    at org.apache.openjpa.enhance.ManagedClassSubclasser.prepareUnenhancedClasses(ManagedClassSubclasser.java:115)
    at org.apache.openjpa.kernel.AbstractBrokerFactory.loadPersistentTypes(AbstractBrokerFactory.java:314)
    at org.apache.openjpa.kernel.AbstractBrokerFactory.initializeBroker(AbstractBrokerFactory.java:238)
    at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:212)
    at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:156)
    at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:227)
    at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:154)
    at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:60)
    at org.springframework.orm.jpa.JpaTransactionManager.createEntityManagerForTransaction(JpaTransactionManager.java:445)
    at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:367)
    ... 36 more

I am running out of options. I have also followed the steps sent by Anthony Fryer previously:

    Run Eclipse and Install m2e connectors
        Go to Windows->Preferences
        Expand the "Maven" node and click on "Discovery"
        Click on the "Open Catalog" button
        Check the following connectors...
            buildhelper
            m2e-wtp
        Click Finish and follow prompts to complete the install
        Restart eclipse
        Run eclipse and install the following plugin to allow eclipse to perform openjpa enhancement of the entity beans.
            Go to Help->Install New Software...
            Work with: âhttps://github.com/hwellmann/m2eclipse-extras/raw/master/p2/
            Select "Omadac m2e Extensions"->"m2e Connector for OpenJPA".
        Install the following m2e configurators (âhttp://docs.jboss.org/tools/whatsnew/maven/maven-news-4.1.0.Alpha1.html)...
            Go to Help->Install New Software...
            Work with: âhttp://download.eclipse.org/m2e-wtp/releases/juno/
            Select the JPA, JAXRS and JSF configurators for installation.


But how can I use this m2e Connector for OpenJPA? So far, I still get the same issue.

If anyone can send me in the right direction, that would be really helpful.

Thanks.



<project name="jpa_enhance_builder">
	<path id="enhance.cp">
	        <pathelement location="${basedir}${file.separator}/build/classes"/>

	        <fileset dir="${basedir}${file.separator}${openjpa.libs}">
	            <include name="**/*.jar"/>
	        </fileset>
	</path>
	<property name="cp" refid="enhance.cp"/>
	
	<target name="openjpa.libs.check" unless="openjpa.libs">
		<fail message="Please set -Dopenjpa.libs in your builder configuration!"/>
	</target>
	<target name="build.dir.check" unless="build.dir">
		<fail message="Please set -Dbuild.dir in your builder configuration!"/>
	</target>

		
	<target name="enhance" depends="openjpa.libs.check, build.dir.check">
		<echo message="${cp}"/>
		<taskdef name="openjpac" classname="org.apache.openjpa.ant.PCEnhancerTask">
			<classpath refid="enhance.cp"/>
		</taskdef>
		<openjpac>
			<classpath refid="enhance.cp"/>
			<config propertiesFile = "${basedir}/src/META-INF/persistence.xml"/>
			<fileset dir="build">
			                <include name="**core/*.class" />
			            </fileset> 
		</openjpac>
		<echo message="Enhancing complete."/> 
	</target>
	

	
</project>
<project xmlns="http://maven.apache.org/POM/4.0.0"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd";>
	<modelVersion>4.0.0</modelVersion>
	<groupId>bpmonitoring</groupId>
	<artifactId>bpmonitoring</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>war</packaging>

	<repositories>
		<repository>
			<id>java.net</id>
			<url>http://download.java.net/maven/2</url>
		</repository>
	</repositories>

	<build>
		<sourceDirectory>src</sourceDirectory>
		<resources>
			<resource>
				<directory>src</directory>
				<excludes>
					<exclude>**/*.java</exclude>
				</excludes>
			</resource>
			<resource>
				<directory>resources</directory>
				<excludes>
					<exclude>**/*.java</exclude>
				</excludes>
			</resource>
		</resources>
		<plugin>
			<groupId>org.apache.openjpa</groupId>
			<artifactId>openjpa-maven-plugin</artifactId>
			<version>2.2.0</version>
			<configuration>
				<includes>**/core/*.class</includes>
				<addDefaultConstructor>true</addDefaultConstructor>
				<enforcePropertyRestrictions>true</enforcePropertyRestrictions>
			</configuration>
			<executions>
				<execution>
					<id>enhancer</id>
					<phase>process-classes</phase>
					<goals>
						<goal>enhance</goal>
					</goals>
				</execution>
			</executions>
			<dependencies>
				<dependency>
					<groupId>org.apache.openjpa</groupId>
					<artifactId>openjpa</artifactId>
					<!-- set the version to be the same as the level in your runtime -->
					<version>2.2.2</version>
				</dependency>
			</dependencies>
		</plugin>

	</build>

	<dependencies>
		<!--Spring framework -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
			<version>3.2.3.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
			<version>3.2.3.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context-support</artifactId>
			<version>3.2.3.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-beans</artifactId>
			<version>3.2.3.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-test</artifactId>
			<version>3.2.3.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-web</artifactId>
			<version>3.2.3.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-webmvc</artifactId>
			<version>3.2.3.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-tx</artifactId>
			<version>3.2.3.RELEASE</version>
		</dependency>
		<!--Spring security -->
		<dependency>
			<groupId>org.springframework.security</groupId>
			<artifactId>spring-security-web</artifactId>
			<version>3.1.4.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.security</groupId>
			<artifactId>spring-security-core</artifactId>
			<version>3.1.4.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.security</groupId>
			<artifactId>spring-security-config</artifactId>
			<version>3.1.4.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.security</groupId>
			<artifactId>spring-security-taglibs</artifactId>
			<version>3.1.4.RELEASE</version>
			<scope>compile</scope>
		</dependency>
		<!--Object-to-Relation-Mapping (ORM) integration with Hibernate, JPA, and 
			iBatis.(depends on spring-core, spring-beans, spring-context, spring-tx) 
			Define this if you need ORM (org.springframework.orm.*) -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-orm</artifactId>
			<version>3.2.3.RELEASE</version>
		</dependency>
		<!--Persistence objects -->
		<dependency>
			<groupId>org.apache.openjpa</groupId>
			<artifactId>openjpa</artifactId>
			<version>2.2.2</version>
		</dependency>
		<!--Validation -->
		<dependency>
			<groupId>javax.validation</groupId>
			<artifactId>validation-api</artifactId>
			<version>1.1.0.Final</version>
		</dependency>
		<dependency>
			<groupId>com.google.code.google-collections</groupId>
			<artifactId>google-collect</artifactId>
			<version>snapshot-20071022</version>
		</dependency>
		<dependency>
			<groupId>org.apache.bval</groupId>
			<artifactId>org.apache.bval.bundle</artifactId>
			<version>0.5</version>
		</dependency>
		<!--Web services -->
		<dependency>
			<groupId>org.apache.axis</groupId>
			<artifactId>axis</artifactId>
			<version>1.4</version>
		</dependency>
		<dependency>
			<groupId>commons-discovery</groupId>
			<artifactId>commons-discovery</artifactId>
			<version>0.2</version>
		</dependency>
		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-io</artifactId>
			<version>1.3.2</version>
		</dependency>
		<dependency>
			<groupId>wsdl4j</groupId>
			<artifactId>wsdl4j</artifactId>
			<version>1.6.2</version>
		</dependency>
		<dependency>
			<groupId>org.apache.tomcat</groupId>
			<artifactId>jsp-api</artifactId>
			<version>6.0.32</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>javax.xml</groupId>
			<artifactId>jaxrpc-api</artifactId>
			<version>1.1</version>
		</dependency>
		<dependency>
			<groupId>com.sun.xml.stream.buffer</groupId>
			<artifactId>streambuffer</artifactId>
			<version>1.5.3</version>
		</dependency>
		<dependency>
			<groupId>com.sun.xml.ws</groupId>
			<artifactId>jaxws-tools</artifactId>
			<version>2.2.8</version>
		</dependency>
		<dependency>
			<groupId>com.sun.xml.ws</groupId>
			<artifactId>jaxws-rt</artifactId>
			<version>2.2.7</version>
		</dependency>
		<dependency>
			<groupId>org.jvnet.jax-ws-commons.spring</groupId>
			<artifactId>jaxws-spring</artifactId>
			<version>1.8</version>
			<exclusions>
				<exclusion>
					<groupId>javax.servlet</groupId>
					<artifactId>servlet-api</artifactId>
				</exclusion>
				<exclusion>
					<groupId>org.springframework</groupId>
					<artifactId>spring</artifactId>
				</exclusion>
				<exclusion>
					<groupId>org.springframework</groupId>
					<artifactId>spring-core</artifactId>
				</exclusion>
				<exclusion>
					<groupId>org.springframework</groupId>
					<artifactId>spring-context</artifactId>
				</exclusion>
				<exclusion>
					<groupId>com.sun.xml.stream.buffer</groupId>
					<artifactId>streambuffer</artifactId>
				</exclusion>
				<exclusion>
					<groupId>org.jvnet.staxex</groupId>
					<artifactId>stax-ex</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<!--Other -->
		<dependency>
			<groupId>jstl</groupId>
			<artifactId>jstl</artifactId>
			<version>1.2</version>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.11</version>
		</dependency>
		<!--DB -->
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>5.1.25</version>
		</dependency>
		<dependency>
			<groupId>org.hsqldb</groupId>
			<artifactId>hsqldb</artifactId>
			<version>1.8.0.10</version>
		</dependency>
	</dependencies>


</project>

Back to the top