Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java 8 application server  RSS feed

 
Stan Sokolov
Ranch Hand
Posts: 120
Hibernate IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tomcat 8 apparently does not work with Java 8. So is any alternative available already ?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15861
81
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's not true, I'm using Tomcat 8 on Java 8 without problems. Why do you think Tomcat 8 does not work on Java 8?

From the Tomcat 8.0.15 Release Notes:
Tomcat 8.0.15 Release Notes wrote:
Tomcat 8.0 is designed to run on Java SE 7 and later.
 
Stan Sokolov
Ranch Hand
Posts: 120
Hibernate IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:That's not true, I'm using Tomcat 8 on Java 8 without problems. Why do you think Tomcat 8 does not work on Java 8?

From the Tomcat 8.0.15 Release Notes:
Tomcat 8.0.15 Release Notes wrote:
Tomcat 8.0 is designed to run on Java SE 7 and later.


It does not when it comes to JSP pages. Try to use closures in a JSP page



The exception will follow as bellow.


type Exception report

message Unable to compile class for JSP:

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 131 in the jsp file: /inventory.jsp
Lambda expressions are allowed only at source level 1.8 or above
128: }
129:
130:
131: Collections.sort(selectedLines, (String o1, String o2)->f.parse(o1.split(",")[0]).compareTo(f.parse(o2.split(",")[0])));
132:
133: //Collections.sort(selectedLines, new StringDateComparator());
134: DateFormat formatterCsv1 = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss SSS");


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:199)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:450)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:361)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

note The full stack trace of the root cause is available in the Apache Tomcat/8.0.15 logs.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15861
81
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can configure what Java compiler Tomcat should use for compiling JSPs. It should work if you configure it to use the JDK 8 compiler.

See Jasper 2 JSP Engine How To

There are settings named compiler, compilerSourceVM and compilerTargetVM. By default it's set to Java 7, but you can change that.
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course, just by coding complex logic like that in a JSP, you're likely to get a from our resident defenders of the MVC paradigm.


ASPs were bad enough. Writing JSPs like they were ASPs is generally not recommended.
 
Stan Sokolov
Ranch Hand
Posts: 120
Hibernate IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tnx! It worked and I agree this is a junk design pattern to embed such a code in a jsp. Was just playing.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!