0

"org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP

PWC6197: An error occurred at line: 26 in the jsp file: /index.jsp PWC6199: Generated servlet error: diamond operator is not supported in -source 1.5 (use -source 7 or higher to enable diamond operator)"

How to change -source 1.5 to -source 1.7 in Glass Fish?

greenpo1son
  • 37
  • 1
  • 8

2 Answers2

2

I was facing the same problem. The problem persists because you are using a web server that is by default configured to compile JSP files via source 1.5. All you need to specify is custom target and compiled java versions. If you are using tomcat then have a look at this answer https://stackoverflow.com/a/20194823/2445898

If you are using Glassfish server like i am suing Glassfish 9, you can configure glassfish-web.xml file to do the same. Create a glassfish-web.xml file in WEB-INF directory of your web application if it does not exists already and add the following lines

<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD
GlassFish Application Server 3.1 Servlet 3.0//EN"
    "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
    <jsp-config>
        <property name="compilerSourceVM" value="7"/>
        <property name="compilerTargetVM" value="7"/>
    </jsp-config>
</glassfish-web-app>

After adding this. Stop and restart your server. It should work now. It worked for me i hope this will work for you too.

Community
  • 1
  • 1
Gaurav Sharma
  • 1,983
  • 18
  • 18
0

Try to add in pom.xml file next lines:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>7</source>
                <target>7</target>
            </configuration>
        </plugin>
    </plugins>
</build>
Alex Titov
  • 91
  • 1
  • 2
  • 9