0

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

  • I tried upgrading the tiles and spring to latest version but still getting errors. –  Sep 07 '17 at 19:57
  • Looks like something (possible Jasper?) is running with an older java version. [This](https://stackoverflow.com/questions/28180915/class-file-has-wrong-version-52-0-should-be-50-0) might be related. – Turing85 Sep 07 '17 at 19:57
  • Thanks @Turing85, I updated jasper to latest version too still same error. It work fine with java 6 –  Sep 07 '17 at 20:09
  • Jasper as-is is not the problem, it seems that the configuration of Jasper is faulty: `Caused by: org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP`. The message `class has wrong version` points at some version incompatibility, i.e. Jasper tries to compile some classes with an older version and your application tries to load this classes in a system (i.e. your web server) running with a newer version. – Turing85 Sep 07 '17 at 20:11

2 Answers2

0

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

Daniel C.
  • 5,418
  • 3
  • 23
  • 26
0
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.

Lothar
  • 5,323
  • 1
  • 11
  • 27