• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

org.apache.jasper.JasperException: Unable to compile class for JSP:

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,

i was trying my hands on Custom tags in JSP by doing a simple program when i encountered the following error :

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 9 in the jsp file: /tag.jsp
AdvisorTagHandler cannot be resolved to a type
6: <body>
7: <%@ taglib prefix="mine" uri="simple" %>
8: Advisor Page

9: <mine:advice user="${userName}" />
10: </body>
11: </html>


An error occurred at line: 9 in the jsp file: /tag.jsp
AdvisorTagHandler cannot be resolved to a type
6: <body>
7: <%@ taglib prefix="mine" uri="simple" %>
8: Advisor Page

9: <mine:advice user="${userName}" />
10: </body>
11: </html>


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:93)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)

javax.servlet.http.HttpServlet.service(HttpServlet.java:729)--

im using : eclipse :3.4.1 [ganymede]
jdk 1.6
apache tomcat 5.5

i created a Dynamic web project in eclipse named 'custom'

my tld file is in :custom/WebContent/WEB-INF/
advice.tld :


my JSP file is in :custom/WebContent/


my java file AdvisorTagHandler: is in :custom/src/


.class file for the above java file was created in : custom/build/classes/

it would be great if anyone could help me out ...
 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you really not indent your code? If you do, why did you post unreadable, unindented code?

In any case, all classes, including tag handlers, need to be in a package other than the default.
 
karthik chellappan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi bear,

i do use intendations ,but for this above code i happened to copy-paste from a text editor in linux which actually took its default intendation pattern and i neglected to correct it ,so im really sorry for making things difficult for you ...

i did create a package named "foo" and placed my Handler class inside tat ...but still its giving me this error :
org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 9 in the jsp file: /tag.jsp
AdvisorTagHandler cannot be resolved to a type
6: <body>
7: <%@ taglib prefix="mine" uri="simple" %>
8: Advisor Page

9: <mine:advice user="${userName}" />
10: </body>
11: </html>


An error occurred at line: 9 in the jsp file: /tag.jsp
AdvisorTagHandler cannot be resolved to a type
6: <body>
7: <%@ taglib prefix="mine" uri="simple" %>
8: Advisor Page

9: <mine:advice user="${userName}" />
10: </body>
11: </html>


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:93)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)


thanks again bear for going through my code ...

 
Bear Bibeault
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please repost the code, with proper indentation, and with your changes.

Otherwise, we can only guess.
 
karthik chellappan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi bear,

my Taghandler class is in foo package :
AdvisorTagHandler.java

tld file :
advice.tld

jsp file :
tag.jsp



ERROR:

org.apache.jasper.JasperException: /tag.jsp(10,0) Unable to load tag handler class "foo.AdvisorTagHandler" for tag "mine:advice"
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:198)
at org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1335)
at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1579)
at org.apache.jasper.compiler.Parser.parse(Parser.java:130)
at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:245)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:176)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:873)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:595)

earlier i posted wrong error ,as i didnt change the <tag-class> value accordingly .now im getting this above error ...

 
Bear Bibeault
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is the class file in the proper location?
 
karthik chellappan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
java file is in : custom/src/foo [ AdvisorTagHandler.java]

class file was created in : custom/build/classes [ AdvisorTagHandler.class]
 
Bear Bibeault
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The class file must also be in a folder named foo. You need to learn about Java packages before you can successfully deploy a web application.
 
karthik chellappan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but then eclipse is creating classes by default in ../build/classes/ and this 'class' folder is not visible in IDE and can be seen only when your navigating each folder from oustide eclipse ...

so how can i get my class file generated in foo package ?

i did tried copying the class file generated in ../build/classes/ to ../foo/ ,but it was showing the same error ...
 
Bear Bibeault
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It doesn't matter what Eclipse is doing, if it's not in the right location, it will not work.
 
karthik chellappan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi bear

i tried changing the path where the class file has to be generated in the classpath file which was generated by eclipse...then refreshed the project,restarted the server and ran it ,but still its comming up with same error ...

can you please guide me how i can solve this ?

classpath file of eclipse looks like this :


i changed just one in this file ,it was earlier :

later i changed it into :


also,for some reasons ...eclipse sometimes was not creating class file in 'build/classes' folder earlier and this is what exactly happening now...no class file is being created in 'src/foo' folder or 'build/classes' folder ...

thanks again ...

 
Bear Bibeault
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since this has become about eclipse, I have moved it to the IDEs forum.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is your build path correct (are the correct source directories listed in the source directory tab)?
 
karthik chellappan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes, java file is in /src/foo ...but no class file is created here even though i changed the classpath file created by eclipse ,ike this :


earlier it was like this :
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not really asking where the Java files are--I'm asking if Eclipse is configured to use it as a source directory during the build process.
 
karthik chellappan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi david ,

im sorry may be i sound stupid ,as i didnt really get what you are asking ?


I'm asking if Eclipse is configured to use it as a source directory during the build process.



i didnt do any configuration in eclipse after i started using it ...can you please guide me further in this ?

 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you didn't do anything to change it, it's probably ok.

Eclipse tracks the source directories for a given project. Rather than having all of the source in one "src/" directory, there might be others, like "test/" and "generated/" or whatever. The list of these directories (and optionally their output directories) is configurable under the project's settings.
 
karthik chellappan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


If you didn't do anything to change it, it's probably ok.



does that mean nothing is problem with configuration of source directories ?

i tried changing the configuration of src and output directories in project settings like this :

1.custom[project name]->right click->build path->configure build path->properties window pops up

2.In properties->selected 'source tab'->it was earlier custom/src in source folders on build path and custom/src in default output folder.

3.selected custom/src and clicked edit to add foo package also to source folder ,a edit window pops up but refuses to add foo to src saying :The folder 'custom/src/foo' already exists .

4.im left with no other option other than to add a new source folder which takes full path :custom/src/foo by clicking 'Add folder' and then delete this old src folder .

5.when i did the above step,in eclipse : 'Java resources:src' changed to 'Java resources:foo' and a default package was created under which java file was present.

and ofcourse i was getting the same error ...
 
reply
    Bookmark Topic Watch Topic
  • New Topic