1

I reference a jar file from JBoss 7.1 module according to the instructions provided in a stackoverflow question here. I have used this jar in JBoss 5.x, 6.x without any issue. However, when I try to deploy a war file in JBoss 7.1 which references the above jar, it gives me the following error:

15:59:19,220 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].  [/Max_client]] (MSC service thread 1-2) StandardWrapper.Throwable: java.lang
NoClassDefFoundError: org/xml/sax/SAXException
    at com.systinet.wasp.webservice.ServiceClientImpl.lookup(ServiceClientImpl.java:556) [wasp.jar:]
    at com.systinet.wasp.webservice.ServiceClientImpl.createProxy(ServiceClientImpl.java:437) [wasp.jar:]
    at org.systinet.wasp.webservice.Registry.lookup(Registry.java:168) [wasp.jar:]
    at MyServlet.init(MyServlet.java:103)   at javax.servlet.GenericServlet.init(GenericServlet.java:242) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Fi
al]
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1102) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3655) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3873) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    at  org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    at  java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_35]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_35]
    at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_35]
Caused by: java.lang.ClassNotFoundException: org.xml.sax.SAXException from [Module "commons.wasp:main" from local module loader @2adb1d4 (roots: c:\jboss-as-7.1.1
Final\modules)]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
    ... 15 more 

I'm very new to this new module concept in JBoss 7. Any idea what is the issue here?

Thank you!

Details on what I tried to do:

I want to be able to make this dependency jar available globally. So what I did was created a folder structure modules/common_libs/test/main and placed the required jar in it. Then created the module descriptor module.xml:

<module xmlns="urn:jboss:module:1.1" name="common_libs.test">
    <resources>
        <resource-root path="test.jar"/>
    </resources>
</module>

Then in the application from which I need to access this jar, I added in the MANIFEST.MF:

Dependencies: common_libs.test

The application is a war file and I deployed it under the deployment folder, and created a .war.dodeploy file. I get this exception when I start the JBoss server.

Any idea, anyone?

Thanks!

Community
  • 1
  • 1
Izza
  • 2,389
  • 8
  • 38
  • 60

2 Answers2

3

You need to look at the dependencies your module requires. With the current error message it looks like it needs a dependency on SAX. You should probably add a dependency for javax.api (this is the module SAX is in) to your module.xml.

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="common_libs.test">
    <resources>
        <resource-root path="test.jar"/>
    </resources>

    <dependencies>
        <module name="javax.api"/>
    </dependencies>
</module>

You'll need to add dependencies for any dependencies your shared library needs.

James R. Perkins
  • 16,800
  • 44
  • 60
1

In your module.xml add a dependency on javax.api and it should work.

As you mentioned you are new to this module concept. So little explanation for what are we doing. with JBoss AS7x archietecture, we use modules to provide jars/ classes to our application. One +ve of this is that it lightens the war.

We create modules for our jars, module.xml is a descriptor that acts as an ID/bio of the module , tells the server about what is in it <resources> tag

and what this module is dependent on <dependencies> tag

For mostly all our module we add a dependency on javax.api so the module couldcompile. Why? Cant remember look out for it. And add as comment when you know it.

Hope this helps:-)

Mukul Goel
  • 8,387
  • 6
  • 37
  • 77
  • One additional question. I managed to package the jar into the module. However, when I try to access a web service deployed in localhost, I get an error obtaining WSDL definition message. I can access the WSDL through the browser, and this same client code I used in JBoss 5.x and 6.x with the same service hosted in localhost without such an error. Any other configuration that I need to do in JBoss 7 to access a web service through a servlet? – Izza Sep 26 '12 at 13:19
  • 1
    No specific config is as such required. should be some classpath issues. is your ejb.jar in your web-inf/lib? Can you provide exact stack n error from console? I could be of more help if you could. Regards – Mukul Goel Sep 27 '12 at 08:10
  • It is a service lookup exception that I get, even though the web service has started and is accessible through the browser/another client. I didn't add ejb.jar to the WEB-INF/lib in earlier versions on JBoss as well, why do I have to do it? – Izza Sep 27 '12 at 11:09
  • 1
    Not sure why we need the ejb.jar in the lib. I myself faced a similar issue back in time, took help from some folks at JBossCommunity and I was told to add the ejb.jar to the lib (reason i was given : it is needed to create webservice endpoints ). please try and add this to your lib and see if it works. regards – Mukul Goel Sep 28 '12 at 09:31