NBW
NBW

Reputation: 1487

How does Jetty compile JSPs?

I am working with a legacy project which includes jetty-6.1.9.jar, jsp-2.1.jar, jsp-api-2.1.jar, servlet-api-2.5-6.1.9.jar and is run under JRE 1.7.0_03.

Jetty server is started inside MyServer.java's main method. It creates a WebAppContext and calls WebAppContext.setWar($webAppRoot) where $webAppRoot is a full path to a directory under which is the usual WEB-INF structure.

All of the app classes and dependent JARs are specified on the classpath which invokes MyServer.main, there are no JARs in WEB-INF/lib and no classes in WEB-INF/class (yes I know that's messed up). The html, javascript, css and JSP files live in $webAppRoot.

The Jetty doc talking about JSP2.1 support indicates that ant-1.6.5 is a required dependency. This project does not include ant yet the JSPs are compiled and work when you hit them.

When I move the application class files into WEB-INF/classes and their dependent JARs into WEB-INF/lib Jetty throws a class not found error saying it can't find an ANT related class when I hit one of the JSPs. Why do the JSPs compile without ANT in the original configuration but when I move things into WEB-INF ANT becomes required?

Upvotes: 0

Views: 4020

Answers (1)

jesse mcconnell
jesse mcconnell

Reputation: 7182

Where are you getting those jsp jars?

JSP is a crazy technology that has more forks then a kitchen drawer...I recently advocated our forking it because the one we consume seems dead (the one at jsp.java.net) and we need a reasonable path to getting updates with on an IP acceptable jsp into jetty. Anyway, I digress, currently with the jsp versions we have in jetty 7, 8 and 9 the default behavior is to use the system compiler and if a certain property is set (org.apache.jasper.compiler.disablejsr199=true) then it instead looks for either the eclipse compiler which we currently distribute or the ant one after that. So...this behavior is entirely dependent on the jsp implementation you are using. If you don't have ant in your classpath and jsps are being compiled, then odds are it is being done by the system compiler. Otherwise look for an ejc jar file which contains the eclipse java compiler, it could be leveraging that one as well.

Also, I know you are working with a legacy project but updating to a more recent and supported version of jetty is truly recommended. And barring that then updating to jetty 6.1.26 would be recommended as a lot of things were fixed between 6.1.9 and the last maintenance release. Barring that, if you are having jsp issues then updating just the jsp jars from a 6.1.26 distribution might help sort that out. You might just need to crack open the source for those jsp jars (which I believe is under org/mortbay/jetty in maven central).

Lastly, taking a stab since its been years since I touched jetty 6, perhaps you need to put ant into the webapp classloader, and it worked previously because it was in the system classloader? If its under $jetty.home/lib then perhaps the webapp context was configured to use a parent priority in the webapp classloader and pulled ant from there?

[edit] I noticed there is a maven-jetty-jspc-plugin for 6.1.9 so it might behoove you to just precompile your jsps and be done with it. (http://repo2.maven.org/maven2/org/mortbay/jetty/maven-jetty-jspc-plugin/)

Upvotes: 2

Related Questions