开发者

Where do I put jar files in Tomcat 6?

开发者 https://www.devze.com 2023-02-03 10:07 出处:网络
I am having trouble getting my JSP page to load a Java class which is in a jar file.The message I get appears to indicate a class not found exception:

I am having trouble getting my JSP page to load a Java class which is in a jar file. The message I get appears to indicate a class not found exception:

Jan 6, 2011 12:21:45 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 72 in the jsp file: /xmlloader.jsp
FactArray cannot be resolved to a type
69:         sourceType = "1";
70: }
71: 
72: FactArray fa = new FactArray();
73: Fact f;
74: 
75: /***********************/

The Type FactArray is one of my classes in a package com.mypackage.fact.FactArray which exists in myjar.jar. myjar.jar is a separate Java project (using NetBeans, but I don't think that's relevant).

I include the package in my JSP as follows:

<%@ page import="com.mypackage.fact.*" %>

I deploy my web site and JSPs into Tomcat 6 as a WAR file. I inclu开发者_开发技巧de myjar.jar in that WAR in WEB-INF/lib but that doesn't work. I tried putting myjar.jar in my tomcat/lib folder, but that doesn't work either.

I have bounced the server several times between changes. I have read a whole bunch of questions on here which say "put it in WEB-INF/lib" but that isn't working, so I'm asking my own question.

Where do I need to put common JAR files so they get picked up by Tomcat?


Putting in /WEB-INF/lib folder of the deployed webapp should work.

If that doesn't work, then the possible causes are:

  • The JAR doesn't contain the desired class at all (extract with ZIP tool and verify)
  • There's a typo in your import and/or class declaration (mind case sensitivity!)

Unrelated to the problem, using scriptlets is not the best practice. Consider a servlet.


Make sure you have the correct import statements in the code; depending on how you set up your env, place the jars in the webapps/ROOT/lib

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号