无法检索“entityManagerFactory”使用杰罗尼莫
我刚刚开始学习Spring框架。我当前的目标是通过 Geronimo 服务器上的 JPA(TopLink** 提供程序)从我的 bean 访问数据库。但我无法克服获取entityManagerFactory 的问题。
我得到的异常:
java.lang.IllegalStateException: 类加载器 [org.apache.geronimo.kernel.config.MultiParentClassLoader] 不提供 'addTransformer(ClassFileTransformer)' 方法。指定自定义 LoadTimeWeaver 或启动您的 Java 带有Spring代理的虚拟机: -javaagent:spring-agent.jar
我访问它的方式:
<context:load-time-weaver />
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceXmlLocation" value="classpath:/META-INF/persistence.xml" />
</bean>
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<bean name="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<tx:annotation-driven />
如果有人可以在不使用“-javaagent:spring-agent.jar”选项的情况下帮助我,我将非常感激。
正在寻找解决方案。第一次尝试。
遵循“axtavt” 建议,我找到了为 Tomcat 上的 Web 应用程序指定特殊类加载器的示例。它使用 context.xml 文件来实现此目的。尽管我的 Geronimo 使用 Tomcat,但我没有成功实现 context.xml。正如接下来所说 手册context.xml<的替代方案Geronimo 的 /em> 是 geronimo-tomcat.xml,但它的语法不提供任何更改类加载器的可能性。我还需要帮助!
I have just started studying Spring framework. My current goal is to access database from my bean through JPA (TopLink** provider) on Geronimo server. But I can't overcome the problem of getting entityManagerFactory.
The exception I get:
java.lang.IllegalStateException:
ClassLoader
[org.apache.geronimo.kernel.config.MultiParentClassLoader]
does NOT provide an
'addTransformer(ClassFileTransformer)'
method. Specify a custom
LoadTimeWeaver or start your Java
virtual machine with Spring's agent:
-javaagent:spring-agent.jar
The way I access it:
<context:load-time-weaver />
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceXmlLocation" value="classpath:/META-INF/persistence.xml" />
</bean>
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<bean name="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<tx:annotation-driven />
I will be very grateful if anyone can help me without using "-javaagent:spring-agent.jar" option.
Searching a solution. First attempt.
Following "axtavt" advice, I found example of specifying special class loader for your web application on Tomcat. It uses context.xml file for that purpose. Although my Geronimo uses Tomcat, I didn't succeed implementing context.xml. As is said in the next
manual the alternative for context.xml for Geronimo is geronimo-tomcat.xml, but it's syntax doesn't provide any possibilities for changing classloader. I still need help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Toplink 需要加载时编织支持。
我想在 Geronimo 中可以通过使用META-INF/context.xml
并将仪器 jar 放入lib
文件夹中进行配置,就像在 Tomcat 中一样,请参阅 此处.编辑:所以,你的问题是 Toplink 需要类转换支持。当在 Spring 的配置中配置 Toplink 的实体管理器 (
LocalContainerEntityManagerFactoryBean
) 时,它会尝试使用 Spring 对类转换的支持 (
) ,但是 Spring 没有对 Geronimo 中的类转换提供内置支持。因此,您有 3 个选择:TransformerAgent.addTransformer()
)。Toplink requires a load-time weaving support.
I guess in Geronimo it can be configured by usingMETA-INF/context.xml
and putting instrumentation jar intolib
folder, as in Tomcat, see here.EDIT: So, your problem is that Toplink requires class transformation support. When Toplink's entity manager is configured in Spring's configuration (
LocalContainerEntityManagerFactoryBean
), it tries to use Spring's support for class transformation (<context:load-time-weaver />
), but Spring doesn't have a built-in support for class transformation in Geronimo. So, you have 3 options:TransformerAgent.addTransformer()
).