好吧,这可能应该是世界上最简单的事情,但我已经尝试了一整天,但仍然不起作用.. 非常感谢任何帮助!
编辑:有关正确的过程,请参阅 Pascal 的答案。
我的错误(因为我没有禁用 LoadTimeWeaving)过程供参考。:
我做了什么:
- 下载了 Tomcat 6.0.26 和 Tomcat 6.0.26。 Spring 3.0.1
- 从 https://src.springframework.org/svn/spring- 下载 PetClinic样品/宠物诊所
- 建造和建造部署 petclinic.war。使用默认的 JDBC 持久性运行良好。
- 编辑 webapps/WEB-INF/spring/applicationContext-jpa.xml 并将
jpaVendorAdaptor
设置为 Hibernate。
- 编辑了 webapps/WEB-INF/web.xml 并将
context-param
从 applicationContext-jdbc.xml 更改为 applicationContext-jpa.xml
- 将 Spring 3.0.1 发行版中的所有内容复制到 TOMCAT_HOME/lib。
-
启动了 tomcat。锯
原因:java.lang.IllegalStateException:ClassLoader [org.apache.catalina.loader.WebappClassLoader] 不提供“addTransformer(ClassFileTransformer)”方法。指定自定义的 LoadTimeWeaver 或使用 Spring 的代理启动 Java 虚拟机: -javaagent:spring-agent.jar
-
Uncommented line 在 webapps/META-INF/context.xml 中。
- 同样的错误。将该行添加到 TOMCAT_HOME/context.xml
-
部署无错误。但是,当我做某事时,它会发出错误消息
java.lang.NoClassDefFoundError:org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:39)处的javax/transaction/SystemException
11.按照 scaffman 的建议,将 javax.transaction 的范围从 test 更改为默认值(刚刚删除了 test)。
12.运行良好!!谢谢!
OK, this probably is supposed to be the easiest thing in the world, but I've been trying for the entire day, and it's still not working.. Any help is highly appreciated!
EDIT: For the correct procedure, please see Pascal's answer.
My wrong (since I did not disabled LoadTimeWeaving) procedure is left for reference..:
What I did:
- Downloaded Tomcat 6.0.26 & Spring 3.0.1
- Downloaded PetClinic from https://src.springframework.org/svn/spring-samples/petclinic
- Built & deployed petclinic.war. Ran fine with default JDBC persistence.
- Edited webapps/WEB-INF/spring/applicationContext-jpa.xml and set
jpaVendorAdaptor
to Hibernate.
- Edited webapps/WEB-INF/web.xml and changed
context-param
from applicationContext-jdbc.xml to applicationContext-jpa.xml
- Copied everything in the Spring 3.0.1 distribution to TOMCAT_HOME/lib.
-
Launched tomcat. Saw
Caused by: java.lang.IllegalStateException: ClassLoader [org.apache.catalina.loader.WebappClassLoader] 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
-
Uncommented line <Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"/>
in webapps/META-INF/context.xml.
- Same error. Added that line to TOMCAT_HOME/context.xml
-
Deployed without error. However, when I do something it will issue an error saying
java.lang.NoClassDefFoundError: javax/transaction/SystemException at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:39)
11.Changed scope of javax.transaction from test to default (just deleted test), as suggested by scaffman.
12.Runs fine!! Thank you!
发布评论
评论(2)
好的,这就是我所做的:
查看 petclinic 示例:
cd
进入 petclinic 目录src/ main/webapp/WEB-INF/spring/applicationContext-jpa.xml
使用 Hibernate:
(加载时编织器不应该与 Hibernate 一起使用,这是针对 Toplink 的)< /里>jpaVendorAdapter
(注释掉 Toplink 部分,取消注释 Hibernate 部分)src/main/webapp/WEB-INF/web.xml
以使用applicationContext-jpa.xml
修改
pom.xml
以在战争中捆绑jta.jar(正如@skaffman所指出的):构建战争
将其部署到 Tomcat
浏览
Ok, here is what I did:
Checkout the petclinic sample:
cd
into the petclinic directorysrc/main/webapp/WEB-INF/spring/applicationContext-jpa.xml
to use Hibernate:<context:load-time-weaver>
(load-time weaver SHOULD NOT be used with Hibernate, this is for Toplink)jpaVendorAdapter
(comment the Toplink part, uncomment the Hibernate part)src/main/webapp/WEB-INF/web.xml
to use theapplicationContext-jpa.xml
Modify the
pom.xml
to bundle jta.jar in the war (as pointed out by @skaffman):Build the war
Deploy it to Tomcat
Browse
看起来像 PetClinic 包装有问题:
http://forum.springsource.org/showthread。 php?t=85042
和
http://jira.springframework.org/browse/ SPR-6880
其中有针对
pom.xml
的修复Looks like a problem with PetClinic packaging:
http://forum.springsource.org/showthread.php?t=85042
and
http://jira.springframework.org/browse/SPR-6880
There's fix in there for the
pom.xml