Cannot apply class transformer without LoadTimeWeaver specified

8.6k Views Asked by At

Have a jar module with entities and daos (openjpa) and a web module which wires those up to controllers with spring. Tests in the jar module run fine but when trying to use daos in the web module, getting this error:

[2014-11-20 15:12:00,692] - openjpa.Runtime An error occurred while registering a ClassTransformer with PersistenceUnitInfo: name 'analytics-persistence-unit', root URL [file:/C:/work/tools/tomcat/webapps/events/WEB-INF/lib/analytics-1.0-SNAPSHOT.jar]. The error is logged along with this warning. Load-time class transformation will not be available. 
java.lang.reflect.UndeclaredThrowableException
    at com.sun.proxy.$Proxy13.addTransformer(Unknown Source)
    at org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:168)
    at org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:62)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:288)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:973)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:750)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    at com.qbe.asia.ebusiness.system.event.EbizEventObserver.<init>(EbizEventObserver.java:38)
    at com.qbe.asia.ebusiness.system.event.ServletContextListenerImpl.contextInitialized(ServletContextListenerImpl.java:23)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4887)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1654)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager$Jpa2PersistenceUnitInfoDecorator.invoke(DefaultPersistenceUnitManager.java:617)
    ... 34 more
Caused by: java.lang.IllegalStateException: Cannot apply class transformer without LoadTimeWeaver specified
    at org.springframework.orm.jpa.persistenceunit.SpringPersistenceUnitInfo.addTransformer(SpringPersistenceUnitInfo.java:109)

persistence unit looks like this:

<persistence-unit name="analytics-persistence-unit" transaction-type="RESOURCE_LOCAL">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<!--non-jta-data-source>analyticsDS</non-jta-data-source-->
<properties>
    <property name="openjpa.ConnectionUserName" value="SA"/>
    <property name="openjpa.ConnectionPassword" value=""/>
    <property name="openjpa.ConnectionURL" value="jdbc:hsqldb:file:~/hsqldb/reports"/>
    <property name="openjpa.ConnectionDriverName" value="org.hsqldb.jdbcDriver"/>

    <property name="openjpa.DynamicEnhancementAgent" value="false"/>
    <property name="openjpa.RuntimeUnenhancedClasses" value="unsupported"/>
    <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema"/>
    <property name="openjpa.Log" value="log4j"/>
    <property name="openjpa.ConnectionFactoryProperties" value="PrettyPrint=true, PrettyPrintLineLength=72, PrintParameters=true, MaxActive=10, MaxIdle=5, MinIdle=2, MaxWait=60000"/>
</properties>

On build openjpa-maven-plugin does enhancements.

Web module loads entity manager based on jar module's persistence unit:

<bean id="analytics-em-factory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="persistenceUnitName" value="analytics-persistence-unit" />
    <property name="packagesToScan" value="com.qbe.asia.analytics.model" />
</bean>

The problem is, I don't really understand the error. Google returns posts related to eclipse Link from 2007 which doesn't help much.

Any explanation of what my problem really is?

1

There are 1 best solutions below

0
On

The problem is that OpenJPA tries to register a ClassTransformer with Spring and for whatever reason that isn't valid for this case. You don't mention what version of OpenJPA you're using, but I somewhat recall seeing a change that went in where OpenJPA will swallow this exception as it is benign if using build time enhancement.