Spring/Tomcat/Hibernate/Maven "Cannot find class" problem
I've got lots of moving parts and I'm not sure what area is giving me problems. I think it is a Spring/Tomcat class loader issue so I'll start here.
I have a web app that access JPA objects via Hibernate. The project is built using Maven and uses Spring for configuration. My JPA objects are built in a different maven module and and it included as a dependency in my main project. It is included correctly in the built war file in WEB-INF/lib. When deploying the application to tcServer it isn't able to find the JPA objects. I'm getting an error:
Code:
Caused by: java.lang.IllegalArgumentException: Cannot find class [com.mytest.Asset]
at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:293)
at org.springframework.beans.propertyeditors.ClassEditor.setAsText(ClassEditor.java:63)
at org.springframework.beans.TypeConverterDelegate.doConvertTextValue(TypeConverterDelegate.java:416)
at org.springframework.beans.TypeConverterDelegate.doConvertValue(TypeConverterDelegate.java:388)
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:157)
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:111)
at org.springframework.beans.TypeConverterDelegate.convertToTypedArray(TypeConverterDelegate.java:427)
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:169)
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:447)
We are using Tomcat 6.0 bundled with SpringSource. The Tomcat configuration is pretty standard with the exception of specifying an alternate class loader:
Code:
<Context docBase="C:\Program Files\springsource\vfabric-tc-server-developer-2.6.1.RELEASE\BaseInstance_MSL\wtpwebapps\msl-and-mars-services"
path="/msl-and-mars-services" reloadable="true" source="org.eclipse.jst.jee.server:msl-and-mars-services">
<Loader
loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"/>
</Context>
I originally thought maybe I needed to include the <jar-file> in the persistence.xml file, so I included it:
Code:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="mcbsDS">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jar-file>file://../mcbs-jpa-1.0-SNAPSHOT.jar</jar-file>
...
but I'm still getting the error.
Lots of other configuration details but I'm not sure what is relevant. Any advice?
Thanks