jsp jar Failed to load
In the /var/lib/tomcat6/webapps/ROOT
I have the following structure =>
META-INF teiExample.jsp WEB-INF
./META-INF:
context.xml
./WEB-INF:
exampleTags.tld lib web.xml
./WEB-INF/lib:
example.jar
Content of the example.jar =>
META-INF/
META-INF/MANIFEST.MF
classes/utilities/arrayExtraInfo.class
classes/utilities/createArrayTag.class
exampleTags.tld
teiExample.jsp =>
<%@ taglib prefix="example" uri="exampleURI" %>
<html>
<head>
<title>Welcome and time example</title>
</head>
<body>
<example:createArray name="theArray" />
We are now using a JAR file<BR />
The array has <%= theArray.length %> items.<BR />
</body>
</html>
exampleTags.tld =>
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>ExampleTags</short-name>
<uri>exampleURI</uri>
<description>A set of example tag handlers.</description>
<tag>
<name>createArray</name>
<tag-class>utilities.createArrayTag</tag-class>
<tei-class>utilities.arrayExtraInfo</tei-class>
<attribute>
<name>name</name>
</attribute>
</tag>
</taglib>
web.xml =>
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
<web-app>
<taglib>
<taglib-uri>exampleTags</taglib-uri>
<taglib-location>/WEB-INF/exampleTags.tld</taglib-location>
</taglib>
</web-app>
But all I get is =>
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Failed to load or instantiate TagExtraInfo class: utilities.arrayExtraInfo
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:281)
org.apache.jasper.compiler.TagLibraryInfoImpl.createTagInfo(TagLibraryInfoImpl.java:419)
org.apache.jasper.compiler.TagLibraryInfoImpl.parseTLD(TagLibraryInfoImpl.java:250)
org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:163)
org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:382)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:445)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1392)
org.apache.jasper.compiler.Parser.parse(Parser.java:130)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:255)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:103)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:170)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:332)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:589)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.开发者_如何学Gojasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
java.lang.ClassNotFoundException: utilities.arrayExtraInfo
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1484)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1329)
org.apache.jasper.compiler.TagLibraryInfoImpl.createTagInfo(TagLibraryInfoImpl.java:416)
org.apache.jasper.compiler.TagLibraryInfoImpl.parseTLD(TagLibraryInfoImpl.java:250)
org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:163)
org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:382)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:445)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1392)
org.apache.jasper.compiler.Parser.parse(Parser.java:130)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:255)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:103)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:170)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:332)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:589)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.24 logs.
Apache Tomcat/6.0.24
Why please? And, do I need web.xml
at all?
org.apache.jasper.JasperException: Failed to load or instantiate TagExtraInfo class: utilities.arrayExtraInfo
This just means that under the covers
TagExtraInfo tag = (TagExtraInfo) Class.forName("utilities.arrayExtraInfo").newInstance();
has failed.
I.e. either the class is not present in the classpath or does not have a default no-arg constructor. The real root cause should however be present in the stacktrace. Read a bit further in the stacktrace, the bottommost part is the real root cause of the problem.
In your case class name is incorrect. As you've structured your JAR, the class name should be classes.utilities.arrayExtraInfo
or you should get rid of the /classes
folder in the JAR.
Unrelated to the concrete problem: please read the Java Naming Conventions. Classnames ought to start with uppercase.
精彩评论