简体   繁体   中英

JSP Not Compiling in JDK 1.8

Hi Friends,

I am working in a project where we just migrated from JAVA 7 to JAVA 8. While doing so I came accross the issue related to jsp compilation problem. While going through the problem by googling I came to know it is a common issue. But I have tried replacing the jars but that didn't seems working . I was running in Jetty Server when the Java version was 7.

So run the test case and there too the problem is there. I am posting the error along with the jars in the class path and sample java and jsp code.

Please note I need to compile in JDK 1.8 only so help me with the possible solution around JDK 8.

Error Log:

testSimpleSearchClassComboBox(com.osm.jsp.SimpleSearchTest)junit.framework.AssertionFailedError:  expected:<Creo Elements/Direct Model Manager Web Client - Index> but was:<Error 500 PWC6033: Unable to compile class for JSP PWC6197: An error occurred at line: 7 in the jsp file: /style/ptc_creo/../../include/head_common.jsp PWC6199: Generated servlet error: The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files>
     [java]     at com.osm.ReportingTestCase.assertEquals(ReportingTestCase.java:246)
     [java]     at com.osm.jsp.SimpleSearchTest.getHtmlForm(SimpleSearchTest.java:91)
     [java]     at com.osm.jsp.SimpleSearchTest.testSimpleSearchClassComboBox(SimpleSearchTest.java:102)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
     [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     [java]     at com.osm.WMTestCase.runTest(WMTestCase.java:550)
     [java]     at com.osm.ReportingTestCase.runBare(ReportingTestCase.java:127)
     [java]     at com.osm.webservices.legacy.WebServiceTestCase.runBare(WebServiceTestCase.java:313)
     [java]     at com.osm.ReportingTestCase.run(ReportingTestCase.java:325)
     [java]     at com.osm.WMTestSuite.runTest(WMTestSuite.java:214)
     [java]     at com.osm.WMTestSuite.run(WMTestSuite.java:209)
     [java]     at com.osm.WMTestSuite.runTest(WMTestSuite.java:214)
     [java]     at com.osm.WMTestSuite.run(WMTestSuite.java:209)
     [java]     at com.osm.WMTestSuite.runTest(WMTestSuite.java:214)
     [java]     at com.osm.WMTestSuite.run(WMTestSuite.java:209)
     [java]     at com.osm.jsp.UnitTests.main(UnitTests.java:30)

My ant script which is sets the jar in the path:

<path id="project.classpath.common">
    <pathelement location="${basedir}/tools/anttools/dist/anttools.jar"/>
    <fileset dir="jar">
      <include name="**/*.jar"/>
      <exclude name="WorkManager.jar"/>
    </fileset>
    <fileset dir="${basedir}/windchill/adapter/9.1/jar">
      <include name="**/*.jar"/>
    </fileset>
    <fileset dir="${basedir}/tools/htmlunit-2.8/lib">
      <include name="**/*.jar"/>
    </fileset>
    <fileset dir="${basedir}/tools/junit-4.8.2/lib">
      <include name="**/*.jar"/>
    </fileset>
    <fileset dir="tools/leakdetection/java/dist/">
      <include name="*.jar"/>
    </fileset>
    <fileset dir="tools/sqljdbc/lib/">
      <include name="*.jar"/>
    </fileset>
    <fileset dir="${basedir}/tools/clover/lib">
      <include name="**/*.jar"/>
    </fileset>
    <pathelement location="${basedir}/OSMWebServices/build/web/WEB-INF/classes"/>
    <pathelement location="${basedir}/OSMWebServices/build/test/classes"/>
  </path>

Here WorkManager is the jar which is our application jar successfully compiled in JDK 1.8.

Sample java method in class SimpleSearchTest:

public void testSimpleSearchClassComboBox() throws Exception {
        System.out.println("Inside  testSimpleSearchClassComboBox ");

        HtmlForm form = getHtmlForm();
        System.out.println("After  HtmlForm ");
        assertEquals("parsm 0 should be search.value", "search.val",
            form.getInputByName("search.val").getNameAttribute());
        System.out.println("After  form.getInputByName() ");

        final List<HtmlSelect> classes = form.getSelectsByName("search.class");
        System.out.println("After  form.getSelectsByName() ");

        final List<HtmlOption> options = classes.get(0).getOptions();
        System.out.println("After  HtmlOption ");
        assertEquals("Should have 4 classes", 4, options.size());

        assertEquals("search class should be",
            MessageCatalogUtil.getInstance().getMessage("awm_stda", 258, "MODEL_3D", Locale.getDefault()),
            options.get(0).getText());
        assertEquals("search class should be",
            MessageCatalogUtil.getInstance().getMessage("awm_stda", 251, "MASTERDATA", Locale.getDefault()),
            options.get(1).getText());
        assertEquals("search class should be",
            MessageCatalogUtil.getInstance().getMessage("awm_stda", 254, "DRAWING_2D", Locale.getDefault()),
            options.get(2).getText());
        assertEquals("search class should be",
            MessageCatalogUtil.getInstance().getMessage("awm_stda", 261, "PACKAGE_3D", Locale.getDefault()),
            options.get(3).getText());
    }

I don't see this as possible duplicate as I am not running it currently in any webserver. I am trying to run it through a test case with the required jars as mentioned. In such case kindly explain how and what needs to be upgraded. I am not even running it through netbeans or eclipse IDE . I am running it through the command prompt which invokes my test cases. Kindly let me know what can I possible look into in this case.

I solved this problem in jboss-5.1.0.GA and jboss-eap-5.2 with a system that needs to run on both platforms. You need to replace the file jasper-jdt.jar in the directory /server/default/deploy/jbossweb.sar of your jboss for the ecj-4.3.1.jar and rename it to jasper-jdt.jar . (Observation: backup the original jasper-jdt.jar before applying changes).

So: Replace jasper-jdt.jar for ecj-4.3.1.jar renaming ecj-4.3.1.jar to jasper-jdt.jar.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM