PDA

View Full Version : [java] Unable to load tag handler class


Pompolus
30-08-2008, 17:46
Ciao a tutti,
sto perdendo 20 kg di capelli cercando di capire un errore in un programma java!
Ho fatto una pagina jsp che utilizza un tag personalizzato. Il problema è che quando vado a chiamarla mi da questo errore:

type Exception report

message

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

exception

org.apache.jasper.JasperException: /index.jsp(135,2) Unable to load tag handler class "mieiTag.PannelloTag" for tag "security:pannello"
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:198)
org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1242)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1467)
org.apache.jasper.compiler.Parser.parse(Parser.java:138)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:216)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:103)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:154)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:315)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
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.18 logs.


il file tld è questo: --sicurezza.tld--
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">

<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>prova</shortname>
<info>prova2</info>

<tag>
<name>login</name>
<tagclass>mieiTag.LoginTag</tagclass>
<bodycontent>empty</bodycontent>
<attribute>
<name> loginPage </name>
<required> true </required>
<rtexprvalue> true </rtexprvalue>
</attribute>
<attribute>
<name> errorPage </name>
<required> false </required>
<rtexprvalue> true </rtexprvalue>
</attribute>
</tag>
<tag>
<name>pannello</name>
<tagclass>mieiTag.PannelloTag</tagclass>
<bodycontent>JSP</bodycontent>
</tag>
</taglib>


situato in .../context-root/tld


questa è la classe handler del tag
//PannelloTag.java

package mieiTag;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.util.*;
import java.io.*;

public class PannelloTag extends TagSupport {

public int doStartTag() {
HttpSession session = pageContext.getSession();
if (session.getAttribute("user") == null) {
return (SKIP_BODY);
}
else {
int tipo = Integer.parseInt(session.getAttribute("tipoUtente").toString());
if (tipo > 1){
return (EVAL_BODY_INCLUDE);
}
else
return (SKIP_BODY);
}
}


public int doEndTag() {
HttpSession session = pageContext.getSession();
if ( session.getAttribute("user") == null) {
return(SKIP_PAGE);
}
else {
int tipo = Integer.parseInt (session.getAttribute("tipoUtente").toString());
if (tipo > 2){
return (EVAL_PAGE);
}
else
return (SKIP_PAGE);
}
}
}



situata in .../context-root/web-inf/classes/mieiTag

e nella jsp il tag viene così chiamato chiamato:

<%@ taglib uri= "/tld/sicurezza.tld" prefix = "security" %>

<security: pannello>
...blablabla...
</security: pannello>



Ho provato a cambiare cartelle e percorsi del tdl, del .class e mille altre cavolate ma il problema resta uguale,
qualcuno sa dove devo mettere le mani?

grazie mille a tutti

Pompolus
30-08-2008, 17:47
non so se può esserci qualche collegamento, ma mi sono accorto di aver chiamato la cartella WEB-INF in minuscolo (web-inf).

Mettendola in maiuscolo (come dovrebbe essere da quel che ne so), non mi parte più l'applicazione, mi restituisce questoi errore:


FAIL - Application at context path /unione_sarda could not be started


se rimetto WEB-INF in minuscolo l'applicazione pare partire ma torna il solito errore: "Unable to load tag handler class".


STO IMPAZZENDO!

ma web-inf non dovrebb essere maiuscolo???

Pompolus
30-08-2008, 19:35
sembra che l'errore sia stato proprio che web-inf era scritto in minuscolo, ora sembro aver risolto.

Grazie lo stesso