2 Replies Latest reply on Sep 20, 2017 9:16 AM by Søren Friis

    "NoClassDefFoundError: Failed to link" on runtime

    Søren Friis Newbie

      Hi,

       

      I have a strange problem. When I uses scriplets in a jsp it sometime fails on runtime. The following example is working:

       

      <%@ page import="test.Class1" %>
      <%
          Class1 class1 = new Class1();
          pageContext.setAttribute("class1", class1);
      %>
      Output: ${class1}
      

       

      If I change the import so it uses "*" in the import the code fails on runtime:

       

      <%@ page import="test.*" %>
      <%
          Class1 class1 = new Class1();
          pageContext.setAttribute("class1", class1);
      %>
      Output: ${class1}
      

       

      If I change my EL so it uses the name of another class (class2) it is also failing:

       

      <%@ page import="test.*" %>
      <%
          Class1 class1 = new Class1();
          pageContext.setAttribute("class1", class1);
      %>
      Output: ${class1}
      

       

      If I use a name which dos not have the same name as a class in test package it works:

       

      <%@ page import="test.*" %>
      <%
          Class1 class1 = new Class1();
          pageContext.setAttribute("class1", class1);
      %>
      Output: ${dummy}
      

       

      If I exclude the scriplet part it also fails:

       

      <%@ page import="test.*" %>
      Output: ${class1}
      

       

      When the code fails I get the following stack trace:

       

      javax.servlet.ServletException: java.lang.NoClassDefFoundError: Failed to link test/class1 (Module "deployment.ROOT.war" from Service Module Loader): test/class1 (wrong name: test/Class1)
      at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:889)
      at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:818)
      at org.apache.jsp.index5_jsp._jspService(index5_jsp.java:106)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:403)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:347)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
      at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
      at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
      at io.undertow.jsp.JspFileHandler.handleRequest(JspFileHandler.java:32)
      at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
      at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
      at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
      at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
      at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
      at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
      at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
      at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
      at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
      at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
      at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
      at org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68)
      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
      at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
      at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
      at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
      at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
      at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
      at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
      at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
      at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
      at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
      at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
      at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
      at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
      at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
      at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
      at io.undertow.server.Connectors.executeRootHandler(Connectors.java:326)
      at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:812)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at java.lang.Thread.run(Thread.java:748)
      Caused by: java.lang.NoClassDefFoundError: Failed to link test/class1 (Module "deployment.ROOT.war" from Service Module Loader): test/class1 (wrong name: test/Class1)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
      at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
      at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:77)
      at org.jboss.modules.Module.loadModuleClass(Module.java:713)
      at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
      at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:412)
      at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:400)
      at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:348)
      at javax.el.ImportHandler.getClassFor(ImportHandler.java:176)
      at javax.el.ImportHandler.resolveClassFor(ImportHandler.java:165)
      at javax.el.ImportHandler.resolveClass(ImportHandler.java:128)
      at org.wildfly.extension.undertow.ImportedClassELResolver.getValue(ImportedClassELResolver.java:70)
      at org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:96)
      at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:116)
      at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:226)
      at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:917)
      at org.apache.jsp.index5_jsp._jspService(index5_jsp.java:94)
      ... 45 more
      

       

      The error occurs on WildFly 10/11 but NOT on WildFly 8. I have attached the sources to an webapp showing the problem.

       

      Does anybody knows how to fix it? I now that I just can avoid using * in my import, but then I have to go through a very large number of jsp's and correct it.

       

      Regards

      Søren