Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] embedded jetty 9 JSP: NullPointerException in org.apache.jasper.compiler.Validator


To upgrade to jetty-9, follow the example of a single embedded webapp that uses jsp here:

That maven project will list all necessary dependencies (actually there's probably a few extra in there, but it will get you going) by doing mvn dependency:tree.

If your jsps use java8-isms then you will need to redefine the JspServlet in your web.xml and set the init params "compilerSourceVM" and "compilerTargetVM" to "1.8" (the default in jetty-9 is "1.7").

Alternatively, it may be simpler for you to just precompile your jsps. You can use either the jetty-jspc-maven plugin (see  to do this or you could write an ant build script to do it (google for info).


On 27 August 2015 at 10:45, Barbara Tuchman <barbaratuchman@xxxxxxxxx> wrote:
Lothar & Joakim: thanks much for your responces.


>Per the JSP spec the Java support level is Java 6 (and it still is, even today).
>Notice that Jetty 6 doesn't use Java itself to compile JSPs?
>Jetty 6 is using the Eclipse JDT compiler.
>Breaking spec to support Java 8 is handled by configuring to use Java and JavaC itself.

Does this mean that I can continue using jetty 6, so long as I configure it to not use JDT but instead to use my JDK 8's javac?

I would love for that to be true, as it should be the quickest way for me to resolve the conflict between jetty 6 and JDK 8.

Assuming that, how do you so configure jetty 6 to use javac?  A web search came up empty.  The codehaus website is defunct, and does not seem to be archived anywhere.

I tried some guesses.  The most important being:

1) as per your github page, I added a call to
    System.setProperty("org.apache.jasper.compiler.disablejsr199", "false");
before I create a Server instance, but that fails--I still see
    2015-08-26T18:21:12.783-0400 WARN [842741472@qtp-1002021887-0] - Compilation error
    org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException: null
        at org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.<init>( ~[core-3.1.1.jar:na]
        at org.apache.jasper.compiler.JDTJavaCompiler$1.findType( [jsp-2.1.jar:6.1.11]
I guess that property must be for newer jetty (e.g. jetty 7+)?

2) I tried removing the core-3.1.1.jar file from my lib directory, as that jar contains the JDT classes, but that caused a different error:
    2015-08-26T18:42:46.485-0400 ERROR [1712943792@qtp-1202683709-0] - /errors.jsp
    java.lang.NoClassDefFoundError: org/apache/tools/ant/BuildListener
        at org.apache.jasper.compiler.Compiler.initJavaCompiler( ~[jsp-2.1.jar:6.1.11]
        at org.apache.jasper.compiler.Compiler.<init>( ~[jsp-2.1.jar:6.1.11]

>You really should use some sort of build system.

The decision is not 100% mine to make, and involves as many political factors as technical.

I can use whatever I want when playing around on my own workstation (e.g. to determine dependent jars), but forcing other users our or prd servers to use, say maven, may be impossible.

>>Doing a more focused web search found:
>>    --this link, which reports what looks like the same problem (but has no solution):

>This looks like your blog.

No it is not!

>Its identical to what you are describing.
>Why they didn't use this forum, or stackoverflow, i cannot comprehend.


I think that our use of jetty 6 is very similar to what is described here:

Perhaps it will help if I post the code we use to embed jetty.

Our application has a Main class that is its entry point. The sole jetty code is entirely in these 3 methods of Main:

    private static void startWebServer() throws Exception {
        Server server = new Server();
    private static Connector[] makeJettyConnectors() {
        Connector connector = new SelectChannelConnector();
        return new Connector[] {connector};
    private static Handler makeJettyHandler() {
        WebAppContext context = new WebAppContext();
        context.setDefaultsDescriptor(urlOfFile("/webdefault.xml"));    // the / prefix means to start the search at the class path root
        return context;

Main's static initializer calls startWebServer.

In addition to that code in Main, there is also:
    1) a web directory, containing the .jsp files and a bunch of other stuff
    2) a .../config/webdefault.xml file
    3) these jars, which I think are all jars we use for jetty/JSP:

I mentioned above that I tried using
    System.setProperty("org.apache.jasper.compiler.disablejsr199", "false");
to disable JDT; I put that call as the first line in startWebServer.

I also tried adding this line
as the 2nd line of makeJettyHandler, since your github page also mentions it; that too made no difference (probably for the same reason).

jetty-users mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Jan Bartel <janb@xxxxxxxxxxx>
Expert assistance from the creators of Jetty and CometD

Back to the top