BladeRunnerJS / brjs

BladeRunnerJS (BRJS) is an open source development toolkit and framework for modular construction of large single-page HTML5 apps. It consists of a set of conventions, supporting tools and micro-libraries that make it easy to develop, test, deploy and maintain complex JavaScript apps.
http://bladerunnerjs.org/
GNU Lesser General Public License v3.0
229 stars 36 forks source link

Exception using JSPs on Java8 #1556

Open dogoku opened 9 years ago

dogoku commented 9 years ago

I came across an exception when adding the following code in my index.jsp, in an attempt to read JNDI tokens from within the scriplet

<%@ page import="javax.naming.*" %>
<% Context env = new InitialContext(); %>
<%= env.lookup("java:comp/env/CAPLIN.DEV.MODE").toString() %>

The exception is caused by the 3rd line

500 error:

Problem accessing /mobile/brjs/. Reason:

Error when trying to write the index page for 'apps/mobile/default-aspect/index.jsp'; org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP

PWC6197: An error occurred at line: 101 in the jsp file: /default-aspect/index.jsp PWC6199: Generated servlet error: The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files

Call stack from terminal:

Oct 02, 2015 4:00:46 PM org.apache.jasper.compiler.JDTJavaCompiler$1 findType
SEVERE: Compilation error
org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException
    at org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.<init>(ClassFileReader.java:372)
    at org.apache.jasper.compiler.JDTJavaCompiler$1.findType(JDTJavaCompiler.java:353)
    at org.apache.jasper.compiler.JDTJavaCompiler$1.findType(JDTJavaCompiler.java:310)
    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:113)
    at org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(UnresolvedReferenceBinding.java:49)
    at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTypeBinding.java:122)
    at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.superInterfaces(BinaryTypeBinding.java:1152)
    at org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.implementsInterface(ReferenceBinding.java:940)
    at org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.isCompatibleWith0(ReferenceBinding.java:1088)
    at org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.isCompatibleWith(ReferenceBinding.java:1039)
    at org.eclipse.jdt.internal.compiler.lookup.Scope.parameterCompatibilityLevel(Scope.java:3990)
    at org.eclipse.jdt.internal.compiler.lookup.Scope.parameterCompatibilityLevel(Scope.java:3978)
    at org.eclipse.jdt.internal.compiler.lookup.Scope.computeCompatibleMethod(Scope.java:574)
    at org.eclipse.jdt.internal.compiler.lookup.Scope.findMethod(Scope.java:1361)
    at org.eclipse.jdt.internal.compiler.lookup.Scope.findMethod(Scope.java:1271)
    at org.eclipse.jdt.internal.compiler.lookup.Scope.getMethod(Scope.java:2333)
    at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:418)
    at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:331)
    at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:374)
    at org.eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.java:947)
    at org.eclipse.jdt.internal.compiler.ast.Block.resolveUsing(Block.java:103)
    at org.eclipse.jdt.internal.compiler.ast.TryStatement.resolve(TryStatement.java:1033)
    at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:456)
    at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:252)
    at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:415)
    at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1148)
    at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1258)
    at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:539)
    at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:763)
    at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:468)
    at org.apache.jasper.compiler.JDTJavaCompiler.compile(JDTJavaCompiler.java:489)
    at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:364)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:433)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:608)
    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:652)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1317)
    at org.bladerunnerjs.appserver.BRJSDevServletFilter.doFilter(BRJSDevServletFilter.java:83)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1288)
    at org.bladerunnerjs.appserver.util.VirtualFilterChain.doFilter(VirtualFilterChain.java:25)
    at org.bladerunnerjs.appserver.filter.BRJSHeaderFilter.doFilter(BRJSHeaderFilter.java:57)
    at org.bladerunnerjs.appserver.util.VirtualFilterChain.doFilter(VirtualFilterChain.java:30)
    at org.bladerunnerjs.appserver.filter.TokenisingServletFilter.doFilter(TokenisingServletFilter.java:109)
    at org.bladerunnerjs.appserver.util.VirtualFilterChain.doFilter(VirtualFilterChain.java:30)
    at org.bladerunnerjs.appserver.filter.FileExtensionFilter.doFilter(FileExtensionFilter.java:41)
    at org.bladerunnerjs.appserver.util.VirtualFilterChain.doFilter(VirtualFilterChain.java:30)
    at org.bladerunnerjs.appserver.BRJSServletFilter.doFilter(BRJSServletFilter.java:44)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1288)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:443)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:574)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1044)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:372)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:189)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:978)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
    at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:293)
    at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:120)
    at org.bladerunnerjs.appserver.ServletContentAccessor.handleRequest(ServletContentAccessor.java:45)
    at org.bladerunnerjs.utility.AppRequestHandler.getIndexPageContent(AppRequestHandler.java:231)
    at org.bladerunnerjs.utility.AppRequestHandler.handleLogicalRequest(AppRequestHandler.java:120)
    at org.bladerunnerjs.appserver.BRJSDevServlet.doGet(BRJSDevServlet.java:85)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:652)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1317)
    at org.bladerunnerjs.appserver.BRJSDevServletFilter.doFilter(BRJSDevServletFilter.java:83)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1288)
    at org.bladerunnerjs.appserver.util.VirtualFilterChain.doFilter(VirtualFilterChain.java:25)
    at org.bladerunnerjs.appserver.filter.BRJSHeaderFilter.doFilter(BRJSHeaderFilter.java:57)
    at org.bladerunnerjs.appserver.util.VirtualFilterChain.doFilter(VirtualFilterChain.java:30)
    at org.bladerunnerjs.appserver.filter.TokenisingServletFilter.doFilter(TokenisingServletFilter.java:109)
    at org.bladerunnerjs.appserver.util.VirtualFilterChain.doFilter(VirtualFilterChain.java:30)
    at org.bladerunnerjs.appserver.filter.FileExtensionFilter.doFilter(FileExtensionFilter.java:38)
    at org.bladerunnerjs.appserver.util.VirtualFilterChain.doFilter(VirtualFilterChain.java:30)
    at org.bladerunnerjs.appserver.BRJSServletFilter.doFilter(BRJSServletFilter.java:44)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1288)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:443)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:574)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1044)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:372)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:189)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:978)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
    at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:293)
    at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:120)
    at org.bladerunnerjs.appserver.BRJSDevServletFilter.doFilter(BRJSDevServletFilter.java:80)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1288)
    at org.bladerunnerjs.appserver.util.VirtualFilterChain.doFilter(VirtualFilterChain.java:25)
    at org.bladerunnerjs.appserver.filter.BRJSHeaderFilter.doFilter(BRJSHeaderFilter.java:57)
    at org.bladerunnerjs.appserver.util.VirtualFilterChain.doFilter(VirtualFilterChain.java:30)
    at org.bladerunnerjs.appserver.filter.TokenisingServletFilter.doFilter(TokenisingServletFilter.java:69)
    at org.bladerunnerjs.appserver.util.VirtualFilterChain.doFilter(VirtualFilterChain.java:30)
    at org.bladerunnerjs.appserver.filter.FileExtensionFilter.doFilter(FileExtensionFilter.java:41)
    at org.bladerunnerjs.appserver.util.VirtualFilterChain.doFilter(VirtualFilterChain.java:30)
    at org.bladerunnerjs.appserver.BRJSServletFilter.doFilter(BRJSServletFilter.java:44)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1288)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:443)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:532)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1044)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:372)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:189)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:978)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
    at org.eclipse.jetty.server.Server.handle(Server.java:369)
    at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:486)
    at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:933)
    at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:995)
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
    at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
    at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:667)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
    at java.lang.Thread.run(Thread.java:745)

Oct 02, 2015 4:00:46 PM org.apache.jasper.compiler.Compiler generateClass
SEVERE: Error compiling file: /private/var/folders/m2/6_ds_dkj1y7ccw1rm3zht4z4h8s9q5/T/jetty-0.0.0.0-7070-mobile-_mobile-any-/jsp/org/apache/jsp/default_002daspect/index_jsp.java
andy-berry-dev commented 9 years ago

Any reason why you're not using @CAPLIN.DEV.MODE@ to access the token? There's still the problem of JSPs not working correctly but using @ABC@ style tokens are the recommended way of accessing JNDI (or property file) token replacements (http://bladerunnerjs.org/docs/use/app_tokens/).

dogoku commented 9 years ago

The tokens are replaced after jsp scriptlets are executed. Therefore if I need the value of the JNDI I need to read it myself. For example, given this token

<New class="org.eclipse.jetty.plus.jndi.EnvEntry">
    <Arg><Ref id='webAppCtx'/></Arg>
    <Arg>HELLO.WORLD</Arg>
    <Arg type="java.lang.String">hello world</Arg>
    <Arg type="boolean">true</Arg>
</New>

This line returns false instead of true

<%= "@HELLO.WORLD@".equals("hello world") %>
andy-berry-dev commented 9 years ago

Yes ok, that makes sense. Ive also checked the above using property file tokens and the same is true.

I managed to get the above working by using Java7 rather than Java8 (https://support.lucidworks.com/hc/en-us/articles/201784186-Error-in-Javac-compilation-for-JSP-in-LucidWorks-Search-UI). This is probably caused by our use of an old version of Jetty (the older versions are compiled for Java7 not Java8) which in turn comes from a requirement to use a very old version of the servlet API to support Java 6.

dchambers commented 9 years ago

@dogoku, does running BRJS with Java 7 solve the problem for you too?

dchambers commented 9 years ago

@andyberry88, didn't you create a branch where you spiked upgrading to a newer version of Jetty to address #1387?

dchambers commented 9 years ago

This stack-overflow issue seems to be the best match I could find:

andy-berry-dev commented 9 years ago

didn't you create a branch where you spiked upgrading to a newer version of Jetty to address #1387?

Yep, I've did a spike investigating adding http2 and SSL support. I upgraded to the latest (at the time) version of Jetty but I vaguely remember this required upgrading to version 3 of the servlet API and dropping support for Java6. I can have another look at that branch and work out how feasible an upgrade would be on Monday.

andy-berry-dev commented 9 years ago

The https://github.com/BladeRunnerJS/brjs/tree/upgrade-jetty is the branch with the Jetty upgrade. As it stands it includes an upgrade to Jetty 9.3.0 and an upgrade to v3 of the servlet API. But it requires us to stop supporting Java 1.7 in dev (due to Jetty upgrade) and legacy versions of Tomcat (due to the servlet API upgrade). It does allow us to continue supporting Java 1.6 in production but this may be pointless since AFAIK most servers that use servlet API v3 don't support 1.6 anyway.

cqzuo commented 6 years ago

replace the ecj.jar with ecj-4.3.1.jar