<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Unable to use Java 8 Language features in JSP</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=102692420" />
  <subtitle>Unable to use Java 8 Language features in JSP</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=102692420</id>
  <updated>2026-04-05T03:20:22Z</updated>
  <dc:date>2026-04-05T03:20:22Z</dc:date>
  <entry>
    <title>RE: Unable to use Java 8 Language features in JSP</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111415119" />
    <author>
      <name>Jan Tošovský</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111415119</id>
    <updated>2018-11-01T07:43:20Z</updated>
    <published>2018-11-01T07:43:20Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Seeing Jasper in stacktrace I expect you run LR on Tomcat. There is default source/target Java version value used for compiling JSP pages, which can be overridden in /conf/web.xml. Java 8 is default source/target since Tomcat 9 so I suppose you use Tomcat 8.x version. Here you have to add these lines to the proper section inside web.xml: &lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;&amp;lt;init-param&amp;gt;
   &amp;lt;param-name&amp;gt;compilerSourceVM&amp;lt;/param-name&amp;gt;
   &amp;lt;param-value&amp;gt;1.8&amp;lt;/param-value&amp;gt;
&amp;lt;/init-param&amp;gt;
&amp;lt;init-param&amp;gt;
   &amp;lt;param-name&amp;gt;compilerTargetVM&amp;lt;/param-name&amp;gt;
   &amp;lt;param-value&amp;gt;1.8&amp;lt;/param-value&amp;gt;
&amp;lt;/init-param&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Jan Tošovský</dc:creator>
    <dc:date>2018-11-01T07:43:20Z</dc:date>
  </entry>
  <entry>
    <title>RE: Unable to use Java 8 Language features in JSP</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111413781" />
    <author>
      <name>Lilian Holden</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111413781</id>
    <updated>2018-11-01T07:06:38Z</updated>
    <published>2018-11-01T07:06:38Z</published>
    <summary type="html">Steps to reproduce:&lt;ol style="list-style: decimal outside;" start="1"&gt;&lt;li&gt;Deploy the attached bundle&lt;/li&gt;&lt;li&gt;Add the Liferay Sample portlet to the page&lt;/li&gt;&lt;/ol&gt;Expected behavior is that the portlet will show abc. Actual behavior is that the portlet says &amp;#34;Liferay Sample is temporarily unavailable.&amp;#34; and there is an error in the server log:&lt;blockquote&gt;Error in Javac compilation for JSPPWC6197: An error occurred at line: 4 in the jsp file: /view.jsp&lt;br /&gt;PWC6199: Generated servlet error: lambda expressions are not supported in -source 1.7 (use -source 8 or higher to enable lambda expressions)&lt;br /&gt;&lt;/blockquote&gt;&lt;a href="https://www.apkjunky.com/"&gt;&lt;span style="color: #000000"&gt;Apkjunky&lt;/span&gt;&lt;/a&gt;</summary>
    <dc:creator>Lilian Holden</dc:creator>
    <dc:date>2018-11-01T07:06:38Z</dc:date>
  </entry>
  <entry>
    <title>RE: Unable to use Java 8 Language features in JSP</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=102724350" />
    <author>
      <name>Zak Thompson</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=102724350</id>
    <updated>2018-01-12T21:34:45Z</updated>
    <published>2018-01-12T21:34:45Z</published>
    <summary type="html">&lt;div class="quote-title"&gt;Minhchau Dang:&lt;/div&gt;&lt;blockquote&gt;I don&amp;#39;t think it&amp;#39;s a regression, since the code change that was submitted in LPS-66641 still exists (&lt;a href="https://github.com/liferay/liferay-portal/blob/7.0.4-ga5/modules/apps/static/portal-osgi-web/portal-osgi-web-servlet-jsp-compiler/src/main/java/com/liferay/portal/osgi/web/servlet/jsp/compiler/JspServlet.java#L284-L285"&gt;reference&lt;/a&gt;). It&amp;#39;s more likely that it was never fixed and closed erroneously due to improper testing.&lt;br /&gt;&lt;br /&gt;It&amp;#39;s the same error as &lt;a href="https://bz.apache.org/bugzilla/show_bug.cgi?id=54475"&gt;SMAP broken in Java 8 for JSP compile&lt;/a&gt;, so I&amp;#39;m guessing that we also needed to update a dependency in order to fix it.&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I think that would make the most sense.  The code seems happy with Arrays.stream and Collectors.toList, so it is definitely compiling against Java 8, as Arrays.stream and the collector class did not exist in Java 7.  My best guess is that its compiling against 1.8, but the parser in the dependency does not know how to handle the new lambda and method reference syntax.</summary>
    <dc:creator>Zak Thompson</dc:creator>
    <dc:date>2018-01-12T21:34:45Z</dc:date>
  </entry>
  <entry>
    <title>RE: Unable to use Java 8 Language features in JSP</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=102723576" />
    <author>
      <name>Minhchau Dang</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=102723576</id>
    <updated>2018-01-12T21:18:33Z</updated>
    <published>2018-01-12T21:18:33Z</published>
    <summary type="html">I don&amp;#39;t think it&amp;#39;s a regression, since the code change that was submitted in LPS-66641 still exists (&lt;a href="https://github.com/liferay/liferay-portal/blob/7.0.4-ga5/modules/apps/static/portal-osgi-web/portal-osgi-web-servlet-jsp-compiler/src/main/java/com/liferay/portal/osgi/web/servlet/jsp/compiler/JspServlet.java#L284-L285"&gt;reference&lt;/a&gt;). It&amp;#39;s more likely that it was never fixed and closed erroneously due to improper testing.&lt;br /&gt;&lt;br /&gt;It&amp;#39;s the same error as &lt;a href="https://bz.apache.org/bugzilla/show_bug.cgi?id=54475"&gt;SMAP broken in Java 8 for JSP compile&lt;/a&gt;, so I&amp;#39;m guessing that we also needed to update a dependency in order to fix it.</summary>
    <dc:creator>Minhchau Dang</dc:creator>
    <dc:date>2018-01-12T21:18:33Z</dc:date>
  </entry>
  <entry>
    <title>RE: Unable to use Java 8 Language features in JSP</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=102697267" />
    <author>
      <name>Zak Thompson</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=102697267</id>
    <updated>2018-01-12T18:49:21Z</updated>
    <published>2018-01-12T18:49:21Z</published>
    <summary type="html">@Olaf&lt;br /&gt;&lt;br /&gt;This code was part of an existing front end web portlet, I am going to try to recreate on a vanilla portlet to confirm its an issue with the runtime and not a configuration error, before submitting a ticket&lt;br /&gt;&lt;br /&gt;@Minhchau&lt;br /&gt;&lt;br /&gt;This code is part of a OSGI module and not a WAR plugin</summary>
    <dc:creator>Zak Thompson</dc:creator>
    <dc:date>2018-01-12T18:49:21Z</dc:date>
  </entry>
  <entry>
    <title>RE: Unable to use Java 8 Language features in JSP</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=102696028" />
    <author>
      <name>Minhchau Dang</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=102696028</id>
    <updated>2018-01-12T17:49:37Z</updated>
    <published>2018-01-12T17:49:37Z</published>
    <summary type="html">If your JSP is inside a module, it should work. If the JSP is inside a regular war you deploy to the application server, you also have to modify the entry web.xml for the JspServlet and set compilerSourceVM and compilerTargetVM (as documented in the &lt;a href="https://tomcat.apache.org/tomcat-8.0-doc/jasper-howto.html"&gt;Jasper How To&lt;/a&gt;) if you wish to use JDK 8 features in your JSPs, since it defaults to JDK 7.</summary>
    <dc:creator>Minhchau Dang</dc:creator>
    <dc:date>2018-01-12T17:49:37Z</dc:date>
  </entry>
  <entry>
    <title>RE: Unable to use Java 8 Language features in JSP</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=102696583" />
    <author>
      <name>Olaf Kock</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=102696583</id>
    <updated>2018-01-12T16:59:37Z</updated>
    <published>2018-01-12T16:59:37Z</published>
    <summary type="html">As you&amp;#39;re on DXP, you might want to open a support ticket. That&amp;#39;s what it&amp;#39;s there for. And the support staff loves you when you already come with an LPS reference, steps to reproduce, and are on the latest FP.</summary>
    <dc:creator>Olaf Kock</dc:creator>
    <dc:date>2018-01-12T16:59:37Z</dc:date>
  </entry>
  <entry>
    <title>Unable to use Java 8 Language features in JSP</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=102692419" />
    <author>
      <name>Zak Thompson</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=102692419</id>
    <updated>2018-01-12T15:33:12Z</updated>
    <published>2018-01-12T15:33:12Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;I'm trying to use Java 8 streams within my init JSP, but running into errors. It seems that using lambdas or method references within a JSP breaks the JSP compiler.  According to &lt;a href="https://issues.liferay.com/browse/LPS-66641"&gt;this LPS case&lt;/a&gt;, the issue was resolved on DXP fix pack 3,&lt;br&gt;I am currently on the latest fix pack (35) on my local development environment. I wasn't sure if there were any additional steps that I had to take to get this to work, or if this is in fact a regression bug.  &lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;
        //works (manual functional interface)
         Arrays.stream(portletPreferences.getValues("selectedVocabularyIds", new String[]{}))
				.map(new Function&amp;lt;string, long&amp;gt;() {
					@Override
					public Long apply(final String value) {
						return Long.parseLong(value);
					}
				}).collect(Collectors.toList());

		//doesn't work (lambda)
		Arrays.stream(portletPreferences.getValues("selectedVocabularyIds", new String[]{}))
				.map(id -&amp;amp;gt; Long.parseLong(id))
				.collect(Collectors.toList());

		//doesn't work (method reference)
		Arrays.stream(portletPreferences.getValues("selectedVocabularyIds", new String[]{}))
				.map(Long::parseLong)
				.collect(Collectors.toList());
&amp;lt;/string,&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;Exception Generated (for both lambda and method reference):&lt;br&gt;&lt;pre&gt;&lt;code&gt;
java.io.IOException: unexpected tag: 18
	at org.apache.jasper.compiler.SmapUtil$SDEInstaller.copyConstantPool(SmapUtil.java:459)
	at org.apache.jasper.compiler.SmapUtil$SDEInstaller.addSDE(SmapUtil.java:304)
	at org.apache.jasper.compiler.SmapUtil$SDEInstaller.&amp;lt;init&amp;gt;(SmapUtil.java:257)
	at org.apache.jasper.compiler.SmapUtil$SDEInstaller.install(SmapUtil.java:246)
	at org.apache.jasper.compiler.SmapUtil.installSmap(SmapUtil.java:167)
	at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:406)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:453)
	at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:625)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:473)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:377)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    ........
    15:37:44,371 ERROR [http-apr-8080-exec-2][PortletRequestDispatcherImpl:265] Unable to dispatch request: PWC6033: Error in Javac compilation for JSP
&amp;lt;/init&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Zak Thompson</dc:creator>
    <dc:date>2018-01-12T15:33:12Z</dc:date>
  </entry>
</feed>
