0

I have a jar that has an implementation class which implements an interface which resides in war. Also jar requires certain custom exceptions and some domain classes from war file. I can't put the jar into the war, as it can be altered frequently.
I am deploying this war into wildfly 10. I read one post from stackoverflow and tried it How can i add a jboss 7.1 module that contain classes that implements/extends from classes in the main ear file of the server?, but again I am getting ClassNotFoundException. I put my jar in the standalone folder and give the path for resource in jboss-deployment-structure.xml as

<jboss-deployment-structure>
    <resources>
        <resource-root path:"../test.jar"/>
    </resources>
</jboss-deployment-structure>

Also I tried doing by referring to it as a module but in turn it needed the dependency from war file which is in different classloader. Can anyone help me with this issue.

1 Answers1

0

Since you say you deploy the JAR you should be using a module dependency not a resource dependency.

<jboss-deployment-structure>
    <dependencies>
        <module name="deployment.test.jar"/>
    </dependencies>
</jboss-deployment-structure>

A <resource/> is used for file system paths. Have a look at the have a look at the documentation for the jboss-deployment-structure.xml.

James R. Perkins
  • 16,800
  • 44
  • 60
  • I think there may be a slight confusion. I am deploying the WAR file and I want that external jar to be loaded in the same class loader. I already tried adding this JAR as a module in JBOSS and declaring its dependency in jboss-deployment-structure.xml . But the classloader which loads the modules external to WAR is on higher level of the classloader which loads the WAR. So while I try to deploy it said that unable to link that particular external module to WAR, due to dependency of JAR classes on some WAR classes. – Avijit Saxena Jul 14 '18 at 12:36
  • If you want the JAR loaded in the same class loader as the WAR it needs to be included in the WAR. That's the only way that would work. – James R. Perkins Jul 16 '18 at 15:54