chrisl08
chrisl08

Reputation: 1658

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

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?

Upvotes: 1

Views: 2754

Answers (1)

mrboo
mrboo

Reputation: 76

  1. Create a jboss-deployment-structure.xml in /WEB-INF
  2. Add the following XML:

    <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
      <deployment>
        <dependencies>  
          <module name="org.apache.commons.lang" export="true" services="import" meta-inf="import"/>
        </dependencies>
      </deployment>
    </jboss-deployment-structure>
    

Upvotes: 3

Related Questions