1 Reply Latest reply on May 28, 2015 2:09 PM by jaysensharma

    java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils when deploying web application

    christopher.lambrou

      Running JBOSS EAP 6.4.0.GA (AS 7.5.0.Final-redhat-21) in Windows 7. Commons lang is deployed in path .\jboss-eap-6.4\modules\system\layers\base\org\apache\commons\lang\main\commons-lang-2.6.0.redhat-4.jar and module.xml in the same folder says

       

      <module xmlns="urn:jboss:module:1.1" name="org.apache.commons.lang">...

       

      As per Red Hat, in In my web application's META-INF/MANIFEST.MF I have entry:
      Dependencies: org.apache.commons.lang

      Using Netbeans 8.0.2 I debug the application, but it fails to start with error:

       

      [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/TestApp]] (ServerService Thread Pool -- 62)
      JBWEB000287: Exception sending context initialized event to listener
      instance of class com.netu.test.web.ContextListener: java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
                  at com.xxx.lib.db.ConnectionPoolSetter.setJdbcURL
      (ConnectionPoolSetter.java:81)

       

      So I get error about Jboss not finding class StringUtils, but that class is in commons lang. Note that I do not want to deploy commons lang in my Web App's WEB-INF/lib. I want to use the module as it is installed in JBOSS.

      What am I doing wrong?

      Chris

        • 1. Re: java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils when deploying web application
          jaysensharma

          I tried with a very simple webapplication and i can see that JBoss EAP6 does not have any issue.  The application can access the "org.apache.commons.lang" module and the classes present inside this module jar  using "TestAppe.war/META-INF/MANIFEST.MF"  Dependencies entry.

           

          Tried the following JSP to access that class :

           

          <%@ page import="org.apache.commons.lang.StringUtils" %>
          <%
              Class c = Class.forName("org.apache.commons.lang.StringUtils");
              out.println("Class c = " + c);
          %>
          

          I see no issues.   The "TestApp.war/META-INF.MANIFEST.MF" file has the following entry in it

           

          Dependencies: org.apache.commons.lang
          
          

           

           

          I am attaching that simple WAR so that you can test it at your end and compare it with your application.