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

org.apache.jasper.JasperException: Unable to compile class for JSP

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_91"
      Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
      Java HotSpot(TM) Client VM (build 25.91-b14, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.10586]

      A DESCRIPTION OF THE PROBLEM :
      My java servlet (Tomcat 6.26 ) application reads html (jsp actually) file with embedded keywords and replaces them with generated html/javascript/CSS web page code and directs user browser to the generated resulting web page. The code snippet doing this is here:

      File formFile = new File(m_Request.getSession().getServletContext().getRealPath(""), getServletName() + ".jsp");
      util_APIs.waitForFile(formFile.getParentFile(), true);
      BufferedWriter bw = new BufferedWriter(new FileWriter(formFile));
      bw.write(sOut);
      bw.close();

      RequestDispatcher rd = m_Request.getRequestDispatcher("/" + formFile.getName());
      rd.forward(m_Request, m_Response);

      The last line of the code above generates the exception below:


      [2016-04-27 11:48:20:589] Exception: org.apache.jasper.JasperException: Unable to compile class for JSP:

      An error occurred at line: 1 in the generated java file
      The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files

      Stacktrace:
      at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
      at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
      at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:349)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
      at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:589)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
      at com.adeda.adedapi.HtmlForm.HtmlFormProcessor.run(HtmlFormProcessor.java:105)
      at com.adeda.adedapi.servlet.ServletExtender.runButLoadPropertiesFirst(ServletExtender.java:102)
      at com.adeda.adedapi.servlet.ServletExtender.process(ServletExtender.java:307)
      at com.adeda.adedapi.util.DefaultProcessorThread.run(DefaultProcessorThread.java:49)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)

      I trace the effect to a both recently released (Apr 18) JDK/JRE 8u91 and 8u92. Once I revert to the JDK/JRE 8u77 or earlier - everything works without a hitch. I verified all configurations and compared system properties within the code running 8u77 versu 8u91. The only difference which makes or breaks my application is the JDK/JRE version

      REGRESSION. Last worked in version 8u77

      ADDITIONAL REGRESSION INFORMATION:
      C:\Users\mgmagi>java -version
      java version "1.8.0_77"
      Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
      Java HotSpot(TM) Client VM (build 25.77-b03, mixed mode, sharing)

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      html/jsp code is generated by servlet and corresponding web page properly displayed in browser
      ACTUAL -
      Exception thrown:
      An error occurred at line: 1 in the generated java file
      The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files

      Stacktrace:
      at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
      at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
      at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:349)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
      at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:589)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
      at com.adeda.adedapi.HtmlForm.HtmlFormProcessor.run(HtmlFormProcessor.java:105)
      at com.adeda.adedapi.servlet.ServletExtender.runButLoadPropertiesFirst(ServletExtender.java:102)
      at com.adeda.adedapi.servlet.ServletExtender.process(ServletExtender.java:307)
      at com.adeda.adedapi.util.DefaultProcessorThread.run(DefaultProcessorThread.java:49)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      An error occurred at line: 1 in the generated java file
      The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files

      Stacktrace:
      at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
      at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
      at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:349)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
      at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:589)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
      at com.adeda.adedapi.HtmlForm.HtmlFormProcessor.run(HtmlFormProcessor.java:105)
      at com.adeda.adedapi.servlet.ServletExtender.runButLoadPropertiesFirst(ServletExtender.java:102)
      at com.adeda.adedapi.servlet.ServletExtender.process(ServletExtender.java:307)
      at com.adeda.adedapi.util.DefaultProcessorThread.run(DefaultProcessorThread.java:49)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Can't be provided.
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      The only work around is to go back older JDK/JRE version and pray that the glitch will go away with the new release

        Activity

        webbuggrp Webbug Group created issue -
        psonal Pallavi Sonal made changes -
        Field Original Value New Value
        Assignee Pallavi Sonal [ psonal ]
        psonal Pallavi Sonal made changes -
        Status New [ 10000 ] Open [ 1 ]
        psonal Pallavi Sonal made changes -
        Security Confidential [ 10000 ]
        psonal Pallavi Sonal made changes -
        Labels regression webbug dcs-pso regression webbug
        psonal Pallavi Sonal made changes -
        CPU x86 [ 17004 ] generic [ 17008 ]
        psonal Pallavi Sonal made changes -
        OS other [ 17019 ] generic [ 17010 ]
        psonal Pallavi Sonal made changes -
        Labels dcs-pso regression webbug dcs-pso regression reproducer-yes webbug
        psonal Pallavi Sonal made changes -
        Project Java Incidents [ 10301 ] JDK [ 10100 ]
        Key JI-9036337 JDK-8155588
        Workflow JBS Incident Workflow [ 4888134 ] JBS Workflow [ 4888134 ]
        Component/s core-libs [ 10300 ]
        Component/s core-libs [ 10701 ]
        Affects Version/s 8u91 [ 18504 ]
        Affects Version/s 8u91 [ 18545 ]
        psonal Pallavi Sonal made changes -
        Subcomponent java.io [ 491 ] java.io [ 244 ]
        psonal Pallavi Sonal made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Duplicate [ 3 ]
        psonal Pallavi Sonal made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        psonal Pallavi Sonal made changes -
        Link This issue duplicates INTJDK-7622745 [ INTJDK-7622745 ]
        Hide
        psonal Pallavi Sonal added a comment -
        Closing as not an issue. This should be resolved by upgrading to latest versions of Tomcat.
        Show
        psonal Pallavi Sonal added a comment - Closing as not an issue. This should be resolved by upgrading to latest versions of Tomcat.
        psonal Pallavi Sonal made changes -
        Security Confidential [ 10000 ]
        psonal Pallavi Sonal made changes -
        Resolution Duplicate [ 3 ]
        Status Closed [ 6 ] Open [ 1 ]
        psonal Pallavi Sonal made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Not an Issue [ 10 ]
        psonal Pallavi Sonal made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Hide
        coffeys Sean Coffey added a comment -
        pasted comments from other bug reports :
        =========================================
        Old versions of Tomcat 6 JSP compiler don't seem to be aware of JDK 8 constant pool enhancements - eg. method handles. New code in JDK 8u is using a method handle instead of creating an anonymous class. This will cause the method handle to be listed in the constant pool and the eclipse compiler will choke on this - https://bz.apache.org/bugzilla/show_bug.cgi?id=56613

        End users would have had the same problems for any version of JDK 8 if their JSPs referenced any classes containing method handles. The failure you can observe here is unearthed only because a JSP is accessing ObjectInputStream which happens to contain a MethodHandle now.

        I am not certain this is JDK problem - this version of tomcat really should not be used together with JDK 8. One could run into this kind of problems by referencing any other JDK class with JDK 8 only constant pool enhancements. Upgrading to the latest Tomcat 6.x version(or later family versions) might solve issue.
        =====

        In any case, Tomcat 6.x versions are almost end of life. Best to upgrade to a newer version of Tomcat :
        http://tomcat.apache.org/tomcat-60-eol.html
        Show
        coffeys Sean Coffey added a comment - pasted comments from other bug reports : ========================================= Old versions of Tomcat 6 JSP compiler don't seem to be aware of JDK 8 constant pool enhancements - eg. method handles. New code in JDK 8u is using a method handle instead of creating an anonymous class. This will cause the method handle to be listed in the constant pool and the eclipse compiler will choke on this - https://bz.apache.org/bugzilla/show_bug.cgi?id=56613 End users would have had the same problems for any version of JDK 8 if their JSPs referenced any classes containing method handles. The failure you can observe here is unearthed only because a JSP is accessing ObjectInputStream which happens to contain a MethodHandle now. I am not certain this is JDK problem - this version of tomcat really should not be used together with JDK 8. One could run into this kind of problems by referencing any other JDK class with JDK 8 only constant pool enhancements. Upgrading to the latest Tomcat 6.x version(or later family versions) might solve issue. ===== In any case, Tomcat 6.x versions are almost end of life. Best to upgrade to a newer version of Tomcat : http://tomcat.apache.org/tomcat-60-eol.html
        klward Klara Ward made changes -
        Link This issue relates to JMC-4946 [ JMC-4946 ]

          People

          • Assignee:
            psonal Pallavi Sonal
            Reporter:
            webbuggrp Webbug Group
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: