Error in Referencing a Dependency Jar File from JBoss 7.1

一笑奈何 提交于 2019-12-24 08:13:04

问题


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!


回答1:


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.




回答2:


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:-)



来源:https://stackoverflow.com/questions/12581157/error-in-referencing-a-dependency-jar-file-from-jboss-7-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!