Visualizzazione dei risultati da 1 a 8 su 8
  1. #1

    [java] Unable to load tag handler class

    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:

    codice:
    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--
    codice:
    <?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
    codice:
    //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" %>

    <securityannello>
    ...blablabla...
    </securityannello>



    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

  2. #2
    Hai indicato nel web.xml la presenza della libreria di tag personalizzata?
    Al mio segnale... scatenate l'inferno!

  3. #3
    no, non l'ho fatto, ma da quel che ho letto non dovrebbe servire, riporto quel che ho trovato in rete:

    "The final step is to test the tag we have developed. In order to use the tag, we have to reference it, and this can be done in three ways:

    1)Reference the tag library descriptor of an unpacked tag library. For example:

    <@ taglib uri="/WEB-INF/jsp/mytaglib.tld"
    prefix="first" %>


    2)Reference a JAR file containing a tag library. For example:

    <@ taglib uri="/WEB-INF/myJARfile.jar"
    prefix='first" %>


    3)Define a reference to the tag library descriptor from the web-application descriptor (web.xml) and define a short name to reference the tag library from the JSP."


    quindi sembrerebbe che un metodo escluda l'altro, io ho usato il primo, quindi il web.xml non dovrei toccarlo, almeno credo...


    Comunque, cosa dovrei scrivere?

    Ah grazie per la risposta

  4. #4
    Ok... allora prova a modificare il tld in questo modo:

    Codice PHP:
    <?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>prova</short-name>
        <info>prova2</info>
        <uri>/WEB-INF/....</uri> (percorso al tuo file.tld)
        <tag>
              <name>login</name>
              <tag-class>mieiTag.LoginTag</tag-class>
              <body-content>empty</body-content>
              <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>
              <tag-class>mieiTag.PannelloTag</tag-class>
              <body-content>JSP</body-content>
         </tag>
    </taglib>
    Al mio segnale... scatenate l'inferno!

  5. #5
    ho provato come dici a modificare il tld, ho provato a psostare il file .class di PannelloTag in tutte le cartelle, ma il problema sembra restare lo stesso :\

  6. #6
    Originariamente inviato da R@ve M@ster
    Ok... allora prova a modificare il tld in questo modo:

    <uri>/WEB-INF/....</uri> (percorso al tuo file.tld)
    comunque il file .tld lo trovava anche prima di questa modifica, perchè se lo sposto l'errore di tomcat cambia e mi dice che non torva il .tld

  7. #7
    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???

  8. #8
    sembra che l'errore sia stato proprio che web-inf era scritto in minuscolo, ora sembro aver risolto.

    Grazie lo stesso

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.