Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 358784

Summary: JSP broken on Java 1.5
Product: [RT] Jetty Reporter: Eirik Bjørsnøs <eirbjo>
Component: serverAssignee: Jan Bartel <janb>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: janb, jetty-inbox, weijx2003
Version: unspecified   
Target Milestone: 7.5.x   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Patch adds jsp-impl and ecj to aggregate modules which recompile JDTJavaCompiler none

Description Eirik Bjørsnøs CLA 2011-09-23 18:03:59 EDT
Build Identifier: 

JSP support is broken using the Jetty 7 Eclipse distro on Java 5. 

Jetty 7 is supposed to run on Java 5, right?

I'm guessing this is related to the recent JSP update to org.glassfish:jsp-impl:2.1.3-b10

Here's the exception, should be easily reproducable using any JSP on Java 5:

org.apache.jasper.JasperException: PWC6349: Cannot find a java compiler for compilation.  If running with JDK 5 or before, Ant or JDT compiler can be used, if the corresponding jars and bridge classes (org.apache.jasper.compiler.AntJavaCompiler or org.apache.jasper.compiler.JDTJavaCompiler) are included
	at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:89)
	at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:375)
	at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:116)
	at org.apache.jasper.compiler.Compiler.initJavaCompiler(Compiler.java:740)
	at org.apache.jasper.compiler.Compiler.<init>(Compiler.java:133)
	at org.apache.jasper.JspCompilationContext.createCompiler(JspCompilationContext.java:288)
	at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:605)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:476)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:366)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:547)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:481)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:483)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:940)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:409)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:186)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:874)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250)
	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)
	at org.eclipse.jetty.server.Server.handle(Server.java:349)
	at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:441)
	at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:904)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:565)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:217)
	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:46)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:545)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:43)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)
	at java.lang.Thread.run(Thread.java:613)





Reproducible: Always
Comment 1 Eirik Bjørsnøs CLA 2011-09-23 19:23:50 EDT
Newer JSP implementations from Glassfish seems to exclude JDTJavaCompiler from compilation, see: https://svn.java.net/svn/jsp~svn/tags/jsp-2.1.3-b10/impl/pom.xml

Stealing the following content from org.mortbay.jetty:jsp-2.1-glassfish:2.1.v20100127:

org/apache/jasper/compiler/JDTJavaCompiler*.class
com/sun/org/apache/commons/logging/**

plus adding JDT to the classpath, I was  able to compile JSP again on Java 5.

Jetty 7 could add the classes above or a solution could be to talk to the Glassfish people and hear if they would consider re-enabling Java 5 support upstream.
Comment 2 Jan Bartel CLA 2011-09-25 18:42:32 EDT
Eirik,

If you put the Ant jar into $JETTY_HOME/lib/jsp jar, did it use that compiler?

Jan
Comment 3 Jan Bartel CLA 2011-09-25 19:40:27 EDT
Actually, don't bother to respond, I just discovered that the jar does not contain any of the other compiler wrappers, other than the in-jvm compiler wrapper.

Sigh.

Jan

(In reply to comment #2)
> Eirik,
> 
> If you put the Ant jar into $JETTY_HOME/lib/jsp jar, did it use that compiler?
> 
> Jan
Comment 4 weijx CLA 2011-09-26 03:03:13 EDT
I encountered the same problem!

Waiting for this problem being fixed!
Comment 5 Jan Bartel CLA 2011-09-26 06:27:59 EDT
Fixed for 7.5.2.

Eirik,

If you want to checkout and build head of jetty @ eclipse and also jetty @
codehaus, you should be able to try out the jetty-maven-plugin 7.5.2-SNAPSHOT
and verify that if you use jdk1.5 then the jdt compiler will be used. Let me
know if there are any problems.

cheers
Jan
Comment 6 Eirik Bjørsnøs CLA 2011-09-26 12:40:13 EDT
(In reply to comment #3)

> Sigh.

 "Sigh." is a compact and precise description of the situation!

(In reply to comment #5)

> If you want to checkout and build head of jetty @ eclipse and also jetty @
> codehaus, you should be able to try out the jetty-maven-plugin 7.5.2-SNAPSHOT
> and verify that if you use jdk1.5 then the jdt compiler will be used. Let me
> know if there are any problems.

Jan,

I don't have Java 5 on my dev box right now, but I faked Jasper to use the JDTJavaCompiler and that seems to work.

The Jetty aggregate modules don't build though. They recompile JDTJavaCompiler from unpacked sources, so they need to have jsp-impl and ecj on their compile class paths.

I've added them in jetty-aggregate/jetty-all, jetty-aggregate/jetty-all-server and jetty-aggregate/jetty-webapp which seems to fix that issue. I'll attach a patch for that.
Comment 7 Eirik Bjørsnøs CLA 2011-09-26 12:42:14 EDT
Created attachment 204024 [details]
Patch adds jsp-impl and ecj to aggregate modules which recompile JDTJavaCompiler

Patch adds jsp-impl and ecj to aggregate modules which recompile JDTJavaCompiler
Comment 8 Eirik Bjørsnøs CLA 2011-09-26 13:15:31 EDT
(In reply to comment #0)

Jan,

This might have deserved a separate isssue, but I'm lazy today:

org.eclipse.jetty:jetty-jsp-2.1:7.5.2-SNAPSHOT doesn't really work very smooth for embedded use.

Issue #1:
org.glassfish.web:jsp-impl is in provided scope, hence I need to add it to my <dependencies> in my consuming project.

Issue #2:
Additionally, org.glassfish.web:jsp-impl pulls in a version of the JSP API jar that doesn't include the DTDs for TLDs, hence parsing of taglibs fails.

So I need to specify javax.servlet.jsp:jsp-api:2.1 as well to override jsp-impl's version.

So my complete Jetty dependency list for use with JSP in a unit test ends up being:

        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-webapp</artifactId>
            <version>7.5.2-SNAPSHOT</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-jsp-2.1</artifactId>
            <version>7.5.2-SNAPSHOT</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.web</groupId>
            <artifactId>jsp-impl</artifactId>
            <version>2.1.3-b10</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
            <scope>test</scope>
        </dependency>

which is rather long and needs to be checked/updated between Jetty versions. The last two of these could be fixed by making jsp-impl non-provided and by explicitly choosing the 2.1 version of the JSP API. (Which is what jetty-distribution ends up using anyhow..)

As a side effect, this would make jsp-impl a transitive dependency inside Jetty as well, so adding it to the aggregate modules would no longer be needed.
Comment 9 Eirik Bjørsnøs CLA 2011-09-26 13:18:33 EDT
(In reply to comment #8)
> (In reply to comment #0)
> 
> Jan,
> 
> This might have deserved a separate isssue, but I'm lazy today:

This really did deserve its own issue:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=358934
Comment 10 Jan Bartel CLA 2011-09-26 20:49:54 EDT
Re-opening to deal with the aggregate modules.

<eye-roll><long-sigh/></eye-roll>

Jan
Comment 11 Jan Bartel CLA 2011-09-27 00:18:35 EDT
Fixed the jetty-aggregates to remove build error caused by addition of JDTJavaCompiler.