Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-12701

JSTL EL Evulation not working properly throwing NoClassDefFoundError

    Details

    • Type: Bug
    • Status: Reopened (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 16.0.0.Final
    • Fix Version/s: None
    • Component/s: EE
    • Labels:
      None
    • Story Points:
      3
    • Steps to Reproduce:
      Hide

      create a jsp Page
      1. import JSTL core libraray <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
      2. create a bean object com.akash.Person and add
      <jsp:useBean id="person" class="com.akashPerson" scope="session"/>
      3 . write JSTL evaluation ${person.name}

      try to lunach the wildlfy server with deployed JSP in windows machine
      it will throw the above error mention in the description

      Probable Fix Required in class
      java.el.ImportHandler.java of jboss-el-api_3.0_spec.1.0.13.final.jar

          private Class<?> getClassFor(String className) {
              if (!notAClass.contains(className)) {
                  try {
                      return Class.forName(className, false, Thread.currentThread().getContextClassLoader());
                  } catch (ClassNotFoundException ex) {
                      notAClass.add(className);
                  }
              }
              return null;
          }
      

      the above code will only work if class will throw ClassNotFoundException
      but in windows when it will try to create instance of a class
      ex – com.rendition.person instead of com.rendition.Person
      it will throw NoClassDefFoundError
      https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8024775
      https://bugs.openjdk.java.net/browse/JDK-8133522

      Fix can be to catch NoClassDefFoundError

      private Class<?> getClassFor(String className) {
              if (!notAClass.contains(className)) {
                  try {
                      return Class.forName(className, false, Thread.currentThread().getContextClassLoader());
                  } catch (ClassNotFoundException ex || NoClassDefFoundError ex1) {
                      notAClass.add(className);
                  }
              }
              return null;
          }
      
      Show
      create a jsp Page 1. import JSTL core libraray <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2. create a bean object com.akash.Person and add <jsp:useBean id="person" class="com.akashPerson" scope="session"/> 3 . write JSTL evaluation ${person.name} try to lunach the wildlfy server with deployed JSP in windows machine it will throw the above error mention in the description Probable Fix Required in class java.el.ImportHandler.java of jboss-el-api_3.0_spec.1.0.13.final.jar private Class <?> getClassFor( String className) { if (!notAClass.contains(className)) { try { return Class .forName(className, false , Thread .currentThread().getContextClassLoader()); } catch (ClassNotFoundException ex) { notAClass.add(className); } } return null ; } the above code will only work if class will throw ClassNotFoundException but in windows when it will try to create instance of a class ex – com.rendition.person instead of com.rendition.Person it will throw NoClassDefFoundError https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8024775 https://bugs.openjdk.java.net/browse/JDK-8133522 Fix can be to catch NoClassDefFoundError private Class <?> getClassFor( String className) { if (!notAClass.contains(className)) { try { return Class .forName(className, false , Thread .currentThread().getContextClassLoader()); } catch (ClassNotFoundException ex || NoClassDefFoundError ex1) { notAClass.add(className); } } return null ; }
    • Workaround:
      Workaround Exists
    • Workaround Description:
      Hide

      use ${requestScope.person.name} instead of using ${person.name}

      Show
      use ${requestScope.person.name} instead of using ${person.name}
    • Estimated Difficulty:
      Medium

      Description

      Following is the stacktrace of server running on wildlfy

      2019/10/21 17:02:09 WARN  [org.jboss.modules.define] Failed to define class com.akash.web.beans.deviceBean in Module "deployment.sample.ear.sample1.war" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link com/akash/web/beans/deviceBean (Module "deployment.sample.ear.sample1.war" from Service Module Loader): com/akash/web/beans/deviceBean (wrong name: com/akash/web/beans/DeviceBean)
      	at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.8.0_212]
      	at java.lang.ClassLoader.defineClass(ClassLoader.java:763) [rt.jar:1.8.0_212]
      	at java.lang.ClassLoader.defineClass(ClassLoader.java:839) [rt.jar:1.8.0_212]
      	at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:424) [jboss-modules.jar:1.9.0.Final]
      	at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:555) [jboss-modules.jar:1.9.0.Final]
      	at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:339) [jboss-modules.jar:1.9.0.Final]
      	at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:126) [jboss-modules.jar:1.9.0.Final]
      	at org.jboss.modules.Module.loadModuleClass(Module.java:731) [jboss-modules.jar:1.9.0.Final]
      	at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:247) [jboss-modules.jar:1.9.0.Final]
      	at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410) [jboss-modules.jar:1.9.0.Final]
      	at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.9.0.Final]
      	at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116) [jboss-modules.jar:1.9.0.Final]
      	at java.lang.Class.forName0(Native Method) [rt.jar:1.8.0_212]
      	at java.lang.Class.forName(Class.java:348) [rt.jar:1.8.0_212]
      	at javax.el.ImportHandler.getClassFor(ImportHandler.java:176) [jboss-el-api_3.0_spec-1.0.13.Final.jar:1.0.13.Final]
      	at javax.el.ImportHandler.resolveClassFor(ImportHandler.java:165) [jboss-el-api_3.0_spec-1.0.13.Final.jar:1.0.13.Final]
      	at javax.el.ImportHandler.resolveClass(ImportHandler.java:128) [jboss-el-api_3.0_spec-1.0.13.Final.jar:1.0.13.Final]
      	at org.wildfly.extension.undertow.ImportedClassELResolver.getValue(ImportedClassELResolver.java:83)
      	at org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:96) [jastow-2.0.7.Final.jar:2.0.7.Final]
      	at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:116) [javax.el-impl-3.0.1-b08-jbossorg-1.jar:3.0.1-b08-jbossorg-1]
      	at com.sun.el.parser.AstValue.getBase(AstValue.java:150) [javax.el-impl-3.0.1-b08-jbossorg-1.jar:3.0.1-b08-jbossorg-1]
      	at com.sun.el.parser.AstValue.getValue(AstValue.java:199) [javax.el-impl-3.0.1-b08-jbossorg-1.jar:3.0.1-b08-jbossorg-1]
      	at javax.el.ImportHandler.resolveClassFor(ImportHandler.java:161) [jboss-el-api_3.0_spec-1.0.13.Final.jar:1.0.13.Final]
      	at javax.el.ImportHandler.resolveClass(ImportHandler.java:128) [jboss-el-api_3.0_spec-1.0.13.Final.jar:1.0.13.Final]
      	at org.wildfly.extension.undertow.ImportedClassELResolver.getValue(ImportedClassELResolver.java:83)
      	at org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:96) [jastow-2.0.7.Final.jar:2.0.7.Final]
      	at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:116) [javax.el-impl-3.0.1-b08-jbossorg-1.jar:3.0.1-b08-jbossorg-1]
      	at com.sun.el.parser.AstValue.getBase(AstValue.java:150) [javax.el-impl-3.0.1-b08-jbossorg-1.jar:3.0.1-b08-jbossorg-1]
      	at com.sun.el.parser.AstValue.getValue(AstValue.java:199) [javax.el-impl-3.0.1-b08-jbossorg-1.jar:3.0.1-b08-jbossorg-1]
      	at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:226) [javax.el-impl-3.0.1-b08-jbossorg-1.jar:3.0.1-b08-jbossorg-1]
      	at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:917) [jastow-2.0.7.Final.jar:2.0.7.Final]
      	at org.apache.jsp.task_frames_jsp._jspService(task_frames_jsp.java:2641)
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  jamezp James Perkins
                  Reporter:
                  akash5551 Akash Gupta
                  Tester:
                  Akash Gupta
                  Involved:
                  Akash Gupta
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated: