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:
jpaVendorAdaptor
to Hibernate.context-param
from applicationContext-jdbc.xml to applicationContext-jpa.xmlLaunched 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.
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!
Ok, here is what I did:
Checkout the petclinic sample:
svn co https://src.springframework.org/svn/spring-samples/petclinic/trunk/ petclinic
cd
into the petclinic directory
src/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 the applicationContext-jpa.xml
Modify the pom.xml
to bundle jta.jar in the war (as pointed out by @skaffman):
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>com.springsource.javax.transaction</artifactId>
<version>1.1.0</version>
<!--scope>test</scope-->
</dependency>
Build the war
mvn install
Deploy it to Tomcat
cp target/petclinic.war $TOMCAT_HOME/webapps
Browse
http://localhost:8080/petclinic
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With