1

Migrating an application based on Jetty 6 to 9.2 (embedded).

I can't figure out how exactly JSPs are compiled at runtime (no pre-compiling). My application runs OK when I use JDK. But it fails to serve JSP when running in JRE, the error I get is:

org.apache.jasper.JasperException: PWC6345: There is an error in invoking javac.  A full JDK (not just JRE) is required
    at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:92)
    at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:378)
    at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:119)
    at org.apache.jasper.compiler.Jsr199JavaCompiler.compile(Jsr199JavaCompiler.java:208)
    at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:384)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:453)

Which clearly indicates that Jetty is looking for Java compiler which is obviously not present in JRE. Looking into Jetty 9.2 docs I read that:

By default, the Apache JSP container will look for the Eclipse Java Compiler (jdt).

I have jetty-jsp-jdt-2.3.3.jar in the classpath but for some reason, Jetty seems to ignore it.

So, my question is - how do I setup an embedded Jetty without JSP precompiling and able to run in JRE. This is essentially what my application in Jetty 6 was doing by means of built-in jasper compiler. Is it even possible with Jetty 9.2?

Dima
  • 4,068
  • 4
  • 38
  • 47
  • There's a github project demonstrating Jetty 9 embedded with JSP (Maintained by the Jetty project) -> https://github.com/jetty-project/embedded-jetty-jsp – Joakim Erdfelt Jul 08 '16 at 13:48

1 Answers1

2

Actually I've found a solution to this by simply doing:

System.setProperty("org.apache.jasper.compiler.disablejsr199", "true"); 

This made the application with embedded Jetty 9.2 run happily in JRE. See this for the reference.

Community
  • 1
  • 1
Dima
  • 4,068
  • 4
  • 38
  • 47
  • 1
    Note: that property is no longer valid in Jetty 9.3+. (Jetty project dropped the Glassfish Jasper impl and moved to official Apache Jasper which doesn't have that property) – Joakim Erdfelt Jul 08 '16 at 13:47
  • @Joakim - does that mean that Jetty 9.3+ will fully depend on JDK to run? – Dima Jul 08 '16 at 17:19
  • Jetty 9.3+ uses Apache Jasper 8.0, which works with jsr199 compilers (like ECJ) just fine, and with the normal JDK. I'm just saying that the System Property `org.apache.jasper.compiler.disablejsr199` has no meaning for Apache Jasper anymore (it doesn't use that System property) – Joakim Erdfelt Jul 08 '16 at 19:16
  • I was incorrect in my prior statement, please read the comment from janbartel on the following bug - https://github.com/eclipse/jetty.project/issues/706 – Joakim Erdfelt Jul 13 '16 at 00:46
  • @Joakim, thank you for the update on this. I am a bit confused about where it goes.., could you please clarify - will Jetty 9.2+ run in JRE or will it require JDK. This is crucial for our product because we ship installers for end users with all necessary dependencies and JDK is obviously out of the question for us. – Dima Jul 13 '16 at 06:31
  • 1
    The existence of the ECJ compiler means you can stick with the JRE distribution. – Joakim Erdfelt Jul 13 '16 at 12:08