2 Replies Latest reply on Aug 14, 2013 5:35 AM by Alexander Hartner

    NoClassDefFoundError: javax/naming/InitialContext from new protocol

    Alexander Hartner Expert

      On startup our application invokes a @StartupBean. This bean uses a custom protocol declared as a module on startup via -Djboss.protocol.handler.modules=com.abc.protocol. The problem we are facing is that the protocol does not seem to be able to resolve the InitialContext class and we end up with:

      Caused by: java.lang.NoClassDefFoundError: javax/naming/InitialContext

              at com.abc.protocol.xx.EnterpriseDataSourceLocator.getDataSource(EnterpriseDataSourceLocator.java:28)

              at com.abc.protocol.xx.ResourceURLConnection.loadResource(ResourceURLConnection.java:103)

              at com.abc.protocol.xx.ResourceURLConnection.connect(ResourceURLConnection.java:42)

              at com.abc.protocol.xx.ResourceURLConnection.getInputStream(ResourceURLConnection.java:49)

              at java.net.URL.openStream(URL.java:1037) [rt.jar:1.7.0_25]

              at com.abc.util.IOUtil.openURLOrFileInputStream(IOUtil.java:95)

              at com.abc.cms.ContentTypeRegistry.readConfig(ContentTypeRegistry.java:81)

              at com.abc.cms.ContentTypeRegistry.init(ContentTypeRegistry.java:65)

              at com.abc.cms.CMS.init(CMS.java:81)

              at com.abc.apps.Startup.run(Startup.java:139)

              at com.abc.apps.Startup.run(Startup.java:77)

       

      At first I figured that the problem is that our protocol module does not declare the required dependencies, so I updated the descriptor to include :

      <module xmlns="urn:jboss:module:1.1" name="com.abc.protocol">

        <resources>

          <resource-root path="ABCResource.jar"/>

        </resources>

        <dependencies>

          <module name="org.jboss.as.naming"/>

        </dependencies>

      </module>

      However this didn't fix the issue. Upon further investigation none of the JAR files included with JBoss contain the javax.naming.InitialContext class

       

      Any suggestion on what I need to change for my startupbean to use the custom protocol which in turn uses services offered by the application server such as JDBC connection pools and other beans of the application.