I deploy a WAR file in Tomcat. In addition I have a JAR file.
Is it possible to make the classes in the JAR file available to services in the WAR file without changing the WAR file, or does it have be added to the WAR’s WEB-INF/lib?
I’ve tried adding the JAR to lib/, but it doesn’t work. Spring fails with org.springframework.beans.factory.BeanCreationException » java.lang.NoClassDefFoundError upon startup.
EDIT
I realized that I might have made myself an unsolvable and architectually ugly problem. Here’s the thing:
- The WAR has a reference
<bean id="warService" class="com.war.Service" /> - My JAR has a class com.mystuff.MyService that extends com.war.Service
- I have replaced the bean reference with
<bean id="warService" class="com.mystuff.MyService" /> - Spring fails with java.lang.NoClassDefFoundError: com.war.Service
Or you could put it(your jar file) in your Tomcat root directory under
libfolder. Chk this out :http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html
Per your edit
I’ve happen to have
mysql-connector-java-5.0.8-binjar in mylibfolder. And just for test I’ve put this in my application context :Worked as charm, check those two cases above