user3166316
user3166316

Reputation: 61

Cannot get Glassfish to compile JSP's using version 7

I have a legacy application I am moving from WebSphere to Liferay running on a Glassfish server.

I had gotten the error while trying to deploy the application to Glassfish:

*org.glassfish.deployment.common.DeploymentException: JSP Compilation Error: org.apache.jasper.JasperException:

PWC6033: Error in Javac compilation for JSP

PWC6199: Generated servlet error: diamond operator is not supported in -source 1.5 (use -source 7 or higher to enable diamond operator)

PWC6199: Generated servlet error: try-with-resources is not supported in -source 1.5 (use -source 7 or higher to enable try-with-resources)

PWC6199: Generated servlet error: Some input files use unchecked or unsafe operations.

PWC6199: Generated servlet error: Recompile with -Xlint:unchecked for details.

-- PWC6033: Error in Javac compilation for JSP PWC6199: Generated servlet error: diamond operator is not supported in -source 1.5 (use -source 7 or higher to enable diamond operator)*

I added a section in the glassfish-web.xml:

<jsp-config> 
<property name="keepgenerated" value="true"> 
<description>Keep a copy of the generated servlet class' java code.</description> 
</property> 
<property name="compilerSourceVM" value="7"/> 
<property name="compilerTargetVM" value="7"/> 
</jsp-config> 

This resolved it immediately on my local machine but not on the Test server we are running. I was not able to see a specific solution for this anywhere. Please Help :)

Upvotes: 4

Views: 6711

Answers (1)

user3166316
user3166316

Reputation: 61

In the GlassFish admin console under Domain -> Applications Configuration there is an option to Precompiles JSPs (deploys only resulting class files). It was selected on the test server and the directive in the glassfish-web.xml was ignored.

To diagnose I created a simple 1 page application wehere the index.jsp looked like this:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="java.util.Map,java.util.List,java.util.ArrayList"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                       "http://www.w3.org/TR/html4/loose.dtd">

<html>
  <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">


        <title>GlassFish JSP Page</title>
  </head>
  <body>
    <h1>Hello World!</h1>
    <%List <String> testerList = new ArrayList<>(); 
      testerList.add("hello");
    %>  
  </body>
</html> 

With Precompile option selected it produced the dreaded PWC6033: Error in Javac compilation for JSP error even with the

<property name="compilerSourceVM" value="7"/> 
<property name="compilerTargetVM" value="7"/> 

set in glassfish-web.xml. Once the Precompile option was unselected, application deployed and page could be reached on test server without the error. I believe this is a GlassFish bug.

Upvotes: 2

Related Questions