Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8272079

System.out cannot be resolved to a type in JSPs

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Multiple. We have seen this on at least Windows 10 and Linux.

      I also looked through the bug reports and could not find anything about this.

      I have looked over the release notes for Java 17 (https://jdk.java.net/17/release-notes) and could not find any reference to changes to System.out that would explain this. But this might be more of a classloading issue.

      A DESCRIPTION OF THE PROBLEM :
      Not sure which subcomponent this belongs under, so it might need to be adjust as needed.

      When trying to use System.out.* methods in a JSP in Java 17 (currently testing with latest java 17 build 33), we get the following error when run in Open Liberty:
      System.out cannot be resolved to a type

      and a stack trace of (tried to clean up most of the intermingled HTML tags and noise):
      JSP Processing Error
      HTTP Error Code:500
      Error Message:
      JSPG0049E: /updateable.jsp failed to compile
      JSPG0091E: An error occurred at line: 7 in the file: /updateable.jsp
      JSPG0093E: Generated servlet error from file: /updateable.jsp
      /home/jazz_build/Build/jbe/build/dev/image/output/wlp/usr/servers/classloader_updateable/workarea/org.eclipse.osgi/70/data/temp/default_node/SMF_WebContainer/updateableApp/updateableAppWeb/_updateable.java : 100 : System.out cannot be resolved to a type
      at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.translateJsp(AbstractJSPExtensionServletWrapper.java:603)
      at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper._checkForTranslation(AbstractJSPExtensionServletWrapper.java:463)
      at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.checkForTranslation(AbstractJSPExtensionServletWrapper.java:253)
      at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionProcessor.findWrapper(AbstractJSPExtensionProcessor.java:512)
      at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionProcessor.getServletWrapper(AbstractJSPExtensionProcessor.java:355)
      at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:5019)
      at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.handleRequest(DynamicVirtualHost.java:314)
      at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1007)
      at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:279)
      at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:1159)
      at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.wrapHandlerAndExecute(HttpDispatcherLink.java:428)
      at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.ready(HttpDispatcherLink.java:387)
      at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:566)
      at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleNewRequest(HttpInboundLink.java:500)
      at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.processRequest(HttpInboundLink.java:360)
      at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.ready(HttpInboundLink.java:327)
      at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:167)
      at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:75)
      at com.ibm.ws.tcpchannel.internal.WorkQueueManager.requestComplete(WorkQueueManager.java:504)
      at com.ibm.ws.tcpchannel.internal.WorkQueueManager.attemptIO(WorkQueueManager.java:574)
      at com.ibm.ws.tcpchannel.internal.WorkQueueManager.workerRun(WorkQueueManager.java:958)
      at com.ibm.ws.tcpchannel.internal.WorkQueueManager$Worker.run(WorkQueueManager.java:1047)
      at com.ibm.ws.threading.internal.ExecutorServiceImpl$RunnableWrapper.run(ExecutorServiceImpl.java:238)
      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
      at java.base/java.lang.Thread.run(Thread.java:833)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Try to serve up a very basic JSP that references a System.out method like System.out.println()

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expect it to work and not cause the "System.out cannot be resolved to a type" exception.
      ACTUAL -
      "System.out cannot be resolved to a type" exception thrown when used in a JSP.

      ---------- BEGIN SOURCE ----------
      Here is a sample JSP we use in our testing that fails consistently at Java 17, but works fine a previous Java levels:

      <html>
      <title>updateable.jsp</title>
      <body>
      <%
      String greeting = request.getParameter("greeting");
      String userName = "Joe";
      System.out.println("executing updateable.jsp - printing " + greeting + " " + userName);
      %>
      <div><%=greeting%> <%=userName%></div>
      </body>
      </html>
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      One of our colleges found out that by adding

      <%@page import="java.io.PrintStream"%>

      to the JSP prevents the "System.out cannot be resolved to a type" exception.

      FREQUENCY : always


            tongwan Andrew Wang
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: