Ae, fiz uma função EL mas não ta dando certo nem a pau… :???: Segue oq tenho:
a classe com o método static:
package com.foo.el;
public class DiceRoller {
public static int rollDice() {
return ( int ) ( ( Math.random() * 6 ) + 1 );
}
}
o arquivo .tld q mapeia, myFunctions.tld, salvo em /WEB-INF
<?xml version="1.0" encoding="ISO-8859-1" ?>
<tablib 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"
version="2.0">
<tlib-version>1.2</tlib-version>
<uri>MyFunctions</uri>
<function>
<name>rollIt</name>
<function-class>com.foo.el.DiceRoller</function-class>
<funtion-signature>int rollDice()</funtion-signature>
</function>
</tablib>
o jsp q chama a função no EL:
<%@ taglib uri="MyFunctions" prefix="mine" %>
<html>
<head></head>
<body>
Roll Dice: ${mine:rollIt()}
</body>
</html>
e a fucking expection lançada qnd tento acessar o jsp:
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
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:565)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.foo.web.FooServlet.doGet(FooServlet.java:31)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.lang.NullPointerException
org.apache.jasper.compiler.Validator$ValidateVisitor.getMethod(Validator.java:1283)
org.apache.jasper.compiler.Validator$ValidateVisitor.processSignature(Validator.java:1271)
org.apache.jasper.compiler.Validator$ValidateVisitor.access$400(Validator.java:309)
org.apache.jasper.compiler.Validator$1FVVisitor.visit(Validator.java:1262)
org.apache.jasper.compiler.ELNode$Function.accept(ELNode.java:122)
org.apache.jasper.compiler.ELNode$Nodes.visit(ELNode.java:193)
org.apache.jasper.compiler.ELNode$Visitor.visit(ELNode.java:234)
org.apache.jasper.compiler.ELNode$Root.accept(ELNode.java:53)
org.apache.jasper.compiler.ELNode$Nodes.visit(ELNode.java:193)
org.apache.jasper.compiler.Validator$ValidateVisitor.validateFunctions(Validator.java:1266)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:607)
org.apache.jasper.compiler.Node$ELExpression.accept(Node.java:896)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Validator.validate(Validator.java:1489)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:157)
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:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.foo.web.FooServlet.doGet(FooServlet.java:31)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.
Help, oqq tem de errado? Ta tudo indo pro deploy direitinho, ja conferi :sad:
obs: Tomcat 5.5.9