Lambda expressions in JSP files will not compile

user5908538 picture user5908538 · Oct 14, 2016 · Viewed 7.2k times · Source

I've tried most of the suggestions mentioned on stackoverflow but haven't come across a solution yet. The error I'm being presented with is the following.

An error occurred at line: 379 in the jsp file: /application-new-project_process.jsp
Lambda expressions are allowed only at source level 1.8 or above 

I'm using IntelliJ IDEA 2016.2 and have applied these settings.

Project StructureProject, Project SDK to 1.8 (java version "1.8.0_102")

Project StructureProject, Project Language Level to 8.0 - Lambdas, type annotations etc.

SettingsBuild, Execution, DeploymentCompilerJava Compiler, Project bytecode version to 1.8

SettingsBuild, Execution, DeploymentCompilerJava Compiler, Target bytecode version to 1.8

I'm using Tomcat v8.0.36 and have the following for JSP servlets.

<servlet>
    <servlet-name>jsp</servlet-name>
    <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
    <init-param>
        <param-name>fork</param-name>
        <param-value>false</param-value>
    </init-param>
    <init-param>
        <param-name>xpoweredBy</param-name>
        <param-value>false</param-value>
    </init-param>
    <init-param> 
        <param-name>compiler</param-name> 
        <param-value>modern</param-value> 
    </init-param> 
    <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> 
    <init-param> 
        <param-name>suppressSmap</param-name> 
        <param-value>true</param-value> 
    </init-param> 
    <load-on-startup>3</load-on-startup>
</servlet>

Any suggestions will be greatly appreciated!

Answer

Alexey Alexeenka picture Alexey Alexeenka · Jan 11, 2017

I use IntelliJ IDEA 2016.3.2, tomcat apache-tomcat-8.5.8, following changes are sufficient for me:
1. Change following file: apache-tomcat-8.5.8\conf\web.xml
2. Modify configuration for

 <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
  1. Add following init params:

    <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>

Finish.