Tomcat 5.5 - custom tag problem

P

Piet71

Hello,
I have recently started to learn JSP and servlets and have installed
Tomcat5.5 as servlet engine. At the moment, I am struggling with the
correct use of taglibs. After trying to write my own simple JSPs
without success, I switched to a sample webapp from a book CD but that
isn´t working either. Here is a description of the webapp:
Folder "custom" below the tomcat "webapps" folder contains the file
custom.jsp with the following content:
<%@ taglib uri="/WEB-INF/tld/tags.tld" prefix="jct" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html;charset=iso-8859-1">
</head>
<body>
<jct:ausgabe />
</body>
</html>
The "custom" folder has a subfolder "WEB-INF" with the following
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web
Application 2.2//EN' 'http://java.sun.com/j2ee/dtds/web-app_2.2.dtd'>
<web-app>
<taglib>
<taglib-uri>
http://www.xmlguru.de/jct
</taglib-uri>
<taglib-location>
/WEB-INF/tld/tags.tld
</taglib-location>
</taglib>
</web-app>
Below "WEB-INF", there is a folder "tld" with the following file
"tags.tld":
<?xml version="1.0" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
"http://java.sun.com/j2ee/dtd/web-jsptaglibrary_1_2.dtd">

<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>jct</short-name>
<uri>http://www.xmlguru.de/jct</uri>
<description>
Mein erstes selbstdefiniertes Tag
</description>
<tag>
<name>ausgabe</name>
<tag-class>meineTags.AusgabeText</tag-class>
</tag>
</taglib>
Finally, the "WEB-INF" contains a folder "classes" with the following
"AusgabeText.java":
package meineTags;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;

public class AusgabeText extends TagSupport
{
public int doStartTag()
{
try
{
JspWriter out = pageContext.getOut();
out.println("Dies ist mein erstes JSP-Tag");
}
catch (IOException iex)
{
System.out.println(iex.toString());
}
return SKIP_BODY;
}

public int doEndTag()
{
return EVAL_PAGE;
}
}
When I compile this file, I can see the class file being generated in
the "meineTags" folder.
When I invoke the JSP, I get the following error page in my browser:
type Exception report

message

description The server encountered an internal error () that prevented
it from fulfilling this request.

exception

javax.servlet.ServletException:
javax.servlet.jsp.tagext.TagInfo.<init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljavax/servlet/jsp/tagext/TagLibraryInfo;Ljavax/servlet/jsp/tagext/TagExtraInfo;[Ljavax/servlet/jsp/tagext/TagAttributeInfo;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljavax/servlet/jsp/tagext/TagVariableInfo;Z)V
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:272)
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

root cause

java.lang.NoSuchMethodError:
javax.servlet.jsp.tagext.TagInfo.<init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljavax/servlet/jsp/tagext/TagLibraryInfo;Ljavax/servlet/jsp/tagext/TagExtraInfo;[Ljavax/servlet/jsp/tagext/TagAttributeInfo;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljavax/servlet/jsp/tagext/TagVariableInfo;Z)V
org.apache.jasper.compiler.TagLibraryInfoImpl.createTagInfo(TagLibraryInfoImpl.java:435)
org.apache.jasper.compiler.TagLibraryInfoImpl.parseTLD(TagLibraryInfoImpl.java:248)
org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:162)
org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:423)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:492)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1552)
org.apache.jasper.compiler.Parser.parse(Parser.java:126)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:146)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

note The full stack trace of the root cause is available in the Apache
Tomcat/5.5.12 logs.

The last entry in the error.log is the following:

13.05.2006 21:41:11 org.apache.catalina.core.StandardWrapperValve
invoke
SCHWERWIEGEND: Servlet.service() for servlet jsp threw exception
java.lang.NoSuchMethodError:
javax.servlet.jsp.tagext.TagInfo.<init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljavax/servlet/jsp/tagext/TagLibraryInfo;Ljavax/servlet/jsp/tagext/TagExtraInfo;[Ljavax/servlet/jsp/tagext/TagAttributeInfo;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljavax/servlet/jsp/tagext/TagVariableInfo;Z)V
at
org.apache.jasper.compiler.TagLibraryInfoImpl.createTagInfo(TagLibraryInfoImpl.java:435)
at
org.apache.jasper.compiler.TagLibraryInfoImpl.parseTLD(TagLibraryInfoImpl.java:248)
at
org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:162)
at
org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:423)
at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:492)
at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1552)
at org.apache.jasper.compiler.Parser.parse(Parser.java:126)
at
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211)
at
org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:146)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
at
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:534)

The book that I have used dates from 2003 and contains only tomcat 5.
Are some of the files erronous or has the handling og taglibs changed
in tomcat 5.5?
Many thanks for your hints
Best regards

Peter
 
W

Wretched Excess

Is there a Context for your application ("custom") in your server.xml...?
If so, did you restart Tomcat after adding it...?
 
P

Piet71

Wretched said:
Is there a Context for your application ("custom") in your server.xml...?
No. Such a modification was not mentioned in the book that I used. It
should be sufficient to provide a suitable web.xml file and the other
resources in the subfolder of the web-app directory.
If so, did you restart Tomcat after adding it...?
It turned out that I didn´t use the correct or sufficient *.jar files
for compilation. I don´t remember where I got the servlet.jar file in
the lib\ext folder of my jdk installation. After I copied the files
jsp-api.jar and servlet-api.jar from the common\lib folder of my tomcat
installation to the lib\ext folder of the dsk, everything worked. For
some reason, my IDE doesn´t find the jar files when they reside in
common\lib folder, but that´s only a minor issue.
Thanks for your reply
Piet
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,967
Messages
2,570,148
Members
46,694
Latest member
LetaCadwal

Latest Threads

Top