Http status 500 org.apache.jasper.JasperException: Unable to compile class

Using netbeans 5.5

executing a jsp using a custom simple tag (tag handler, tld file, jsp file code included after the error)

how do i resolve this following runtime error:

==============================

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: Unable to compile class for JSP

An error occurred at line: 17 in the jsp file: /test3.jsp

Generated servlet error:

[javac] /Users/user2/SDK/domains/domain1/generated/jsp/j2ee-modules/JspTester1/org/apache/jsp/test3_jsp.java:96: cannot find symbol

[javac] symbol : class NewClass

[javac] location: class org.apache.jsp.test3_jsp

[javac]NewClass _jspx_th_tld1_simple1_0 = new NewClass();

[javac]^

An error occurred at line: 17 in the jsp file: /test3.jsp

Generated servlet error:

[javac] /Users/user2/SDK/domains/domain1/generated/jsp/j2ee-modules/JspTester1/org/apache/jsp/test3_jsp.java:96: cannot find symbol

[javac] symbol : class NewClass

[javac] location: class org.apache.jsp.test3_jsp

[javac]NewClass _jspx_th_tld1_simple1_0 = new NewClass();

[javac]^

[javac] Note: /Users/user2/SDK/domains/domain1/generated/jsp/j2ee-modules/JspTester1/org/apache/jsp/test3_jsp.java uses unchecked or unsafe operations.

An error occurred at line: 17 in the jsp file: /test3.jsp

Generated servlet error:

[javac] Note: Recompile with -Xlint:unchecked for details.

[javac] 2 errors

note The full stack traces of the exception and its root causes are available in the Sun Java System Application Server Platform Edition 9.0_01 logs.

==============

tag handler:

============

import javax.servlet.jsp.tagext.*;

import javax.servlet.jsp.JspWriter;

import javax.servlet.jsp.JspException;

public class NewTagHandler extends SimpleTagSupport {

public void doTag() throws JspException {

JspWriter out=getJspContext().getOut();

try {

out.println("<strong>" + "new tag handler class" + "</strong>");

// out.println("<blockquote>");

} catch (java.io.IOException ex) {

throw new JspException(ex.getMessage());

}

}

}

tld file:

======

<?xml version="1.0" encoding="UTF-8"?>

<taglib version="2.0" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd">

<tlib-version>1.0</tlib-version>

<short-name>tld1</short-name>

<uri>/WEB-INF/tlds/tld1.tld</uri>

<tag>

<name>simple1</name>

<tag-class>NewClass</tag-class>

<body-content>empty</body-content>

</tag>

</taglib>

jsp file:

======

<%@page contentType="text/html"%>

<%@page pageEncoding="UTF-8"%>

<%@ taglib uri="/WEB-INF/tlds/tld1.tld" prefix="tld1" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>JSP Page</title>

</head>

<body>

<h1>JSP Page</h1>

TagTester: <tld1:simple1/>

</body>

</html>

========

[3673 byte] By [javauser9000a] at [2007-11-26 18:43:56]
# 1
where is this NewClass located? is it in the CLASSPATH?
ganesh_renganathana at 2007-7-9 6:17:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
NewClass location:/jspTester1/build/web/WEB-INF/classes/i believe it is (other jsp's using java class files work fine, when not extending SimpleTagSupport or TagSupport)i dont know how to check that in the Netbeans IDE
javauser9000a at 2007-7-9 6:17:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Your posted code shows the class: NewTagHandler

Your tld mentions the class: <tag-class>NewClass</tag-class>

Presumably these should be the same.

Also, this problem may be caused by your Class not being in a package.

Classes in a named package can no longer access classes in the "unnamed" package.

Solution:

- put your tag in a package: eg com.mytag

Don't forget you need to update both your class AND the tld which references it.

Cheers,

evnafets

evnafetsa at 2007-7-9 6:17:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
placing the tag handler in a named package resolved the problem. Thanks.
javauser9000a at 2007-7-9 6:17:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...