简体   繁体   中英

Upgrade to Java 1.8 Causes Issues

I'm trying to upgrade my current java project that running on 1.6 to 1.8 but the program compiles fine how ever when I go http://localhost:8080/MyProject/login.jsp- I'm getting errors.

I'm using eclipse luna and I changed the java_HOME to 1.8 and eclipse project facets to 1.8 and updated the javax.servlet-api=3.1.0.

The stack trace

springframework.web.util.NestedServletException: Request processing failed; nested exception is org.apache.tiles.impl.CannotRenderException: ServletException including path '/WEB-INF/jsp/template/noLayout.jsp'.
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:943) ~[spring-webmvc-4.0.0.RELEASE.jar:4.0.0.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:822) ~[spring-webmvc-4.0.0.RELEASE.jar:4.0.0.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:735) ~[servlet-api-3.0.jar:na]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:807) ~[spri

Caused by: org.apache.tiles.impl.CannotRenderException: ServletException including path '/WEB-INF/jsp/template/noLayout.jsp'.
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:692) ~[tiles-core-2.2.2.jar:2.2.2]
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:644) ~[tiles-core-2.2.2.jar:2.2.2]
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:627) ~[tiles-core-2.2.2.jar:2.2.2]
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:321) ~[tiles-core-2.2.2.jar:2.2.2]
at org.springframework.web.servlet.view.tiles2.TilesView.renderMergedOutputModel(TilesView.java:88) ~[spring-webmvc-4.0.0.RELEASE.jar:4.0.0.RELEASE]
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:266) ~[spring-webmvc-4.0.0.RELEASE.jar:4.0.0.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1225) ~[spring-webmvc-4.0.0.RELEASE.jar:4.0.0.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1012) ~[spring-webmvc-4.0.0.RELEASE.jar:4.0.0.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) ~[spring-webmvc-4.0.0.RELEASE.jar:4.0.0.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876) ~[spring-webmvc-4.0.0.RELEASE.jar:4.0.0.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:931) ~[spring-webmvc-4.0.0.RELEASE.jar:4.0.0.RELEASE]
... 65 common frames omitted
Caused by: org.apache.tiles.util.TilesIOException: ServletException including path '/WEB-INF/jsp/template/noLayout.jsp'.
at org.apache.tiles.servlet.context.ServletUtil.wrapServletException(ServletUtil.java:243) ~[tiles-servlet-2.2.2.jar:2.2.2]
at org.apache.tiles.servlet.context.ServletTilesRequestContext.forward(ServletTilesRequestContext.java:243) ~[tiles-servlet-2.2.2.jar:2.2.2]
at org.apache.tiles.servlet.context.ServletTilesRequestContext.dispatch(ServletTilesRequestContext.java:222) ~[tiles-servlet-2.2.2.jar:2.2.2]
at org.apache.tiles.renderer.impl.TemplateAttributeRenderer.write(TemplateAttributeRenderer.java:44) ~[tiles-core-2.2.2.jar:2.2.2]
at org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:106) ~[tiles-core-2.2.2.jar:2.2.2]
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:670) ~[tiles-core-2.2.2.jar:2.2.2]
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:690) ~[tiles-core-2.2.2.jar:2.2.2]
... 75 common frames omitted
Caused by: org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP

PWC6199: Generated servlet error:
string:///noLayout_jsp.java:7: cannot access java.lang.Object
bad class file: java\lang\Object.class(java\lang:Object.class)
class file has wrong version 52.0, should be 50.0
Please remove or make sure it appears in the correct subdirectory of the classpath*.

noLayout.jsp

  <% response.setHeader("Cache-Control", "no-store, private, must-revalidate, max-stale=0, post-check=0, pre-check=0"); //Forces caches to obtain a new copy of the page from the origin server
response.setHeader("Pragma", "no-cache"); //HTTP 1.0 backward compatibility 
response.setDateHeader("Expires", 0); //Causes the proxy cache to see the page as "stale"
%><%@ page isELIgnored="false"%><!doctype html>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%><%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<html>
 <head>  
  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">  
<link href="${pageContext.request.contextPath}/css/base.css" rel="stylesheet" type="text/css">

I'm using Ivy for dependency management

I changed from

Tiles version 2.2 ,spring 4.0 and jetty

One possible solution is to define the compilerSourceVM and compilerTargetVM for org.apache.jasper.servlet.JspServlet (tomcat-home/conf/web.xml)

Like this:

 <servlet>
        <servlet-name>jsp</servlet-name>
        <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
        <init-param>                                   
            <param-name>compilerSourceVM</param-name>
            <param-value>1.8</param-value>
        </init-param>
        <init-param>
            <param-name>compilerTargetVM</param-name>
            <param-value>1.8</param-value>
        </init-param>                                   
    </servlet>

This configuration define the compiler version of jasper.

For more information please see the configuration properties of your tomcat implementation, for example Tomcat 7 reference doc

Also you can read this post with related information about how to define the jasper compiler version Jasper Compiler Version config

string:///noLayout_jsp.java:7: cannot access java.lang.Object
bad class file: java\lang\Object.class(java\lang:Object.class)
class file has wrong version 52.0, should be 50.0

the compiler being used to process the JSP seems to still be Java 6 but got fed with the system jars of Java 8. Are you starting your application from Eclipse or is that when running it as a standalone application? If it's the former, make sure you also set the JRE System Library (Properties of the Project -> Java Build Path -> JRE System Library) to Java 8. Just setting everything to Java 8 in the Java compiler settings isn't enough. If it's the letter, check your JSP configuration if there is still something left of the old one that points to the Java 6 binaries.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM