This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
I've searched the forums and seen this question asked, but there doesn't seem to be an answer to it. I deployed a webapp of mine to tomcat 5.5 as a .war file. The deployment works and I can call jsps. I try to call a servlet which uses a .jar file which is in my application's /WEB-INF/lib/ directory. I get a NoClassDefFoundError for a class that the servlet tries to call. However, if I add my .jar file to $tomcat-home/common/lib everything works fine. I can't imagine I would need to add all my .jar files to the common/lib to get them to work. Please let me know what I need to do to have the files in my own application's \WEB-INF\lib directory to be seen.
I think I figured out why it can't find the class. I am using castor-jdo to do object/database mapping with a mysql database. Castor-jdo uses a class javax.transaction.Synchronization...it doesn't seem to work without this. This class is in j2ee.jar When I start my webapp I see INFO: validateJarFile(C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\ahs96\WEB-INF\lib\j2ee.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
So j2ee.jar never gets loaded when it is in my webapp. It only gets loaded if I put it in the $CATALINA_HOME/common/lib directory.
The problem is I need this class for the castor stuff to work. It 'does' work putting it in $CATALINA_HOME/common/lib directory. but this is not the right way to do it. Can anyone give me some insight into this?
Joined: Mar 11, 2005
I've discovered that j2ee.jar is unnecessary. jta1.0.1.jar includes the required interfaces. the jar is in the lib directory of the full castor download.