• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ServletException after JSP precompilation

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have been attempting to pre-compile my JSP files in Tomcat 5.0. I am using Struts with Tiles, and my JSP files are all contained under the WEB-INF folder, so they are not directly accessible. Some of the pages work fine after the pre-compilation, but others do not. Specifically, I get a ServletException that looks something like this:



Any idea why this may be happening? The exception information is not particularly helpful.


Thanks!

Todd Farmer
 
Todd Farmer
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've managed to compare the .java files created by JSPC in the precompilation step to the .java files created when I deply the .jsp files as part of my WAR file. I've found the differences that are causing the problem. Here's a snippet from a method in an inner class of one of the .java files created by the JSPC precompilation:



This private inner class extends org.apache.jasper.runtime.JspFragmentHelper, which has a protected field _jspx_page_context (a javax.servlet.jsp.PageContext type).

The .java file created by Tomcat when the same .jsp file is deployed as part of the WAR file looks different, and uses this _jspx_page_context field from the superclass in place of the pageContext variable:



I'm still at a loss as to why the generated .java files are different when using JSPC to precompile the .jsp files and when Tomcat does it during deployment. I'm using the Maven Tomcat plug-in. I may try to use an Ant script to see if I have the same problems, but I don't see any reason to believe I will get different results.

Any suggestions?

Todd Farmer
[ August 17, 2005: Message edited by: Todd Farmer ]
 
Todd Farmer
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I finally figured out the root cause of the problem. It appears that when I precompile .jsp files that contain custom tags, I end up with this problem. Removing the custom tags allows the precompilation to work correctly. The standard Struts and JSTL tags appear precompile fine; it's just my custom tags that do not.

At this point, I have no idea why this is the case. I sure would like to be able to use custom tags and precompilation. I wonder if there is something I am doing wrong, or if I need to register my custom tags somehow with the JSPC step to make this work.

Todd Farmer
 
Sheriff
Posts: 67746
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 jar file containing your custom tags and its tld in the classpath during the pre-compile?
 
Todd Farmer
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's a really good question. The custom tags I developed haven't been factored out to a separate .jar file (they are under the WEB-INF/classes folder), which is different than the Struts and JSTL code.

I'm using the Maven Tomcat plug-in, so I'm not explicitly setting the classpath for the pre-compile step. I can imagine the loose class files are not being included in the classpath used by the Tomcat plug-in.

I'll try pulling the tags out into a separate .jar file and listing that as a Maven dependency and seeing if that resolves my issue.

Thanks for the good suggestion!

Todd Farmer
 
Todd Farmer
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I pulled the custom tag code out to a separate project and used that .jar file (including the .tld) as a dependency for my web project. When I ran the Maven Tomcat plug-in, I ended up with the same result. Bummer.

I guess it is still possible (OK, likely) that I'm doing something wrong and missing some needed configuration to precompile successfully. I've already upgraded from Tomcat 5.0 to 5.5, and that didn't resolve anything. Next step has to be to try pre-compilation using Ant to try to isolate the Maven Tomcat plug-in, I guess.

Todd Farmer
 
Todd Farmer
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can tell that the precompile process is able to access the Java code for the custom tags, because the business logic encapsulated in the tags is visible in the precompiled JSPs. It still seems to be naming the PageContext object variable incorrectly.

Odd.

Todd Farmer
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic