gpt4 book ai didi

java - 无法在未指定 LoadTimeWeaver 的情况下应用类转换器

转载 作者:行者123 更新时间:2023-11-28 23:33:49 25 4
gpt4 key购买 nike

有一个带有实体和 daos (openjpa) 的 jar 模块,以及一个使用 spring 将它们连接到 Controller 的 web 模块。 jar 模块中的测试运行良好,但是当尝试在 web 模块中使用 daos 时,出现此错误:

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

在构建 openjpa-maven-plugin 时进行增强。

Web模块根据jar模块的持久化单元加载实体管理器:

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

问题是,我真的不明白这个错误。 Google 会返回 2007 年与 eclipse 链接相关的帖子,但没有太大帮助。

对我的问题到底是什么有任何解释吗?

最佳答案

问题是 OpenJPA 试图向 Spring 注册一个 ClassTransformer,无论出于何种原因,这对这种情况都是无效的。您没有提到您使用的是哪个版本的 OpenJPA,但我有点记得看到 OpenJPA 将吞下此异常的地方发生了变化,因为如果使用构建时间增强,它是良性的。

关于java - 无法在未指定 LoadTimeWeaver 的情况下应用类转换器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27031938/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com