• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

problem in TLD

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI friends...

I am trying to implement the rollIt program of HRSJ, but I am encountering some problem in excuting my rollIt function.

Here is my code :

TestBean.jsp
<%@ taglib prefix="mine" uri="DiceFunctions" %>
<html>
<body>

${mine:rollIt()}

</boby>
</html>
=========================================================================
Tld file :
<?xml version="1.0" encoding="ISO-8859-1" ?>
<taglib 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>DiceFunctions</uri>
<function>
<name>rollIt</name>
<function-class>foo.DiceRoller</function-class>
<function-signature> int rollDice() </function-signature>
</function>
</taglib>
=========================================================================
My rollDice function
package foo;

public class DiceRoller {

public static int rollDice()
{
return (int)((Math.random() * 6 ) + 1);
}

}
===========================================================================
Out which I am getting is :
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: The class specified in the method signature in TLD for the function mine:rollDice cannot be found.
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:94)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:365)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:216)
at org.apache.jasper.compiler.Validator$1$MapperELVisitor.visit(Validator.java:1380)
at org.apache.jasper.compiler.ELNode$Function.accept(ELNode.java:159)
at org.apache.jasper.compiler.ELNode$Nodes.visit(ELNode.java:230)
at org.apache.jasper.compiler.ELNode$Visitor.visit(ELNode.java:268)
at org.apache.jasper.compiler.ELNode$Root.accept(ELNode.java:92)
at org.apache.jasper.compiler.ELNode$Nodes.visit(ELNode.java:230)
at org.apache.jasper.compiler.Validator$ValidateVisitor.getFunctionMapper(Validator.java:1395)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:669)
at org.apache.jasper.compiler.Node$ELExpression.accept(Node.java:821)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2017)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2059)....................................................................................................
===========================================================================

I dont understand why it is not executing the function and printing the statement as it is...

........................................................................
thanks,
Pooja
 
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Puja,

I have tested your code and everything seems to be fine unless ...

1. Your DiceRoller.class file is not in the correct directory. Make sure you put the .class file inside /WEB-INF/classes/foo directory.

2. Your .tld file file is not in the correct directory. Make sure you put the .tld file inside either /WEB-INF or any of its subdirectories.

3. The dumb one Make sure you stoped and started your web app after changing either your .tld file or .class file.


The class specified in the method signature in TLD for the function mine:rollDice cannot be found



According to the error message you got from container, I would guess you put the .class file in the incorrect place. Maybe inside WEB-INF/classes instead of /WEB-INF/classes/foo.

I hope that helps.
[ September 04, 2006: Message edited by: Edisandro Bessa ]
 
Puja Verma
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. My .tld file is in WEB-INF
2. My DiceRoller class files is in classes.foo directory
3. I think no need to say that i have restarted my web server after every changes...

Only thing remain is the libraries and web.xml part.... Do i need to have some specific library for this or do i need to put some specific details in my web.xml ???
Here is my web.xml

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

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app 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-app_2_4.xsd" id="WebApp" version="2.4">

<display-name>ELTest</display-name>

</web-app>


Do you think there is some problem in this web.xml??
thanks,
Pooja
 
Edisandro Bessa
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Puja,

Sorry for my late reply.


2. My DiceRoller class files is in classes.foo directory


Just to make the things clear : The name you gave for your directory is classes.foo ? or you created a foo directory within classes directory in this way /classes/foo ?

Taking a closer look at the error message, this sounds strange :


org.apache.jasper.JasperException: The class specified in the method signature in TLD for the function mine:rollDice cannot be found.



How the container cannot find the mine:rollDice if your .jsp page contains the statement ${mine:rollIt()} ?

I think something was mistyped in either your jsp page or .tld file or class file.

Well, in the first time I replied your question, I created in my container the same files you provided above with exception of the web.xml file which I did not provide.

Everything worked fine even though my application had no web.xml file.

For now, I just created the web.xml file with the same contents you provided above and everything still remains working fine.

As per error message you provided above and based on your previous comments, I would guess the problem is with your .class file.

Are you sure your .class reflects the latest version of your source file ?

I simply did everything again in only one turn and everything still works fine right here.
[ September 05, 2006: Message edited by: Edisandro Bessa ]
 
Puja Verma
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your help ... I am using WIZAD application developer and might be becoz of that I am getting this problem. I think now i should start using command line to run my programs and might be i will get the desired output by that... Anyways thanks of helping me
 
I am not a spy. Definitely. Definitely not a spy. Not me. No way. But this tiny ad ...
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic