[英]Where do I put jar files in Tomcat 6?
I am having trouble getting my JSP page to load a Java class which is in a jar file. 我无法让我的JSP页面加载一个jar文件中的Java类。 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. Type
FactArray
是我的一个类com.mypackage.fact.FactArray中的一个类,它存在于myjar.jar中。 myjar.jar is a separate Java project (using NetBeans, but I don't think that's relevant). myjar.jar是一个单独的Java项目(使用NetBeans,但我不认为这是相关的)。
I include the package in my JSP as follows: 我在JSP中包含了如下包:
<%@ page import="com.mypackage.fact.*" %>
I deploy my web site and JSPs into Tomcat 6 as a WAR file. 我将我的网站和JSP作为WAR文件部署到Tomcat 6中。 I include myjar.jar in that WAR in WEB-INF/lib but that doesn't work.
我在WEB-INF / lib中的WAR中包含myjar.jar,但这不起作用。 I tried putting myjar.jar in my tomcat/lib folder, but that doesn't work either.
我尝试将myjar.jar放在我的tomcat / lib文件夹中,但这也不起作用。
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.
我在这里读了很多问题,说“把它放在WEB-INF / lib中”,但这不起作用,所以我问自己的问题。
Where do I need to put common JAR files so they get picked up by Tomcat? 我需要在哪里放置常见的JAR文件,以便它们被Tomcat选中?
Putting in /WEB-INF/lib
folder of the deployed webapp should work. 放入已部署的webapp的
/WEB-INF/lib
文件夹应该可以正常工作。
If that doesn't work, then the possible causes are: 如果这不起作用,那么可能的原因是:
Unrelated to the problem, using scriptlets is not the best practice. 与问题无关,使用scriptlet不是最佳实践。 Consider a servlet .
考虑一个servlet 。
Make sure you have the correct import statements in the code; 确保代码中包含正确的import语句; depending on how you set up your env, place the jars in the webapps/ROOT/lib
根据您设置env的方式,将jar放在webapps / ROOT / lib中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.