2

I a Jboss Wildfly 8.2 instance I have a webapp ROOT.war and another OTHER.war and I need that the class OtherXYZ.class that is inside OTHER.war be able to access RootXYZ.class. I've read somewhere that this might be possible using EAR but I don't know how.

Here there is the schema I need to implement

                     ClassesVisibleToAllWars.jar
                     /          |              \    
            (access)/           |(access)       \(access)
                   /            |                \
            Root.war         Other1.war         Other2.war
           /                    |                    |
        R.class              O1.class              O2.class  
  • I CANNOT create/use a Global Module to put inside wildfly/modules directory. I'll only have access to standalone/deployments/* directory
  • all classes from ClassesVisibleToAllWars.jar must be visible to R.class, O1.class and O2.class, for example
  • new other .war files might eventually be deployed and this behavior must persist

Question

Wheare should I put ClassesVisibleToAllWars.jar in order to achieve that schema?

thiagoh
  • 7,098
  • 8
  • 51
  • 77
  • Obviously you are dealing with dependency issue. Why don't you use a build script (Maven/Ant...) to package the dependencies in your .war file? Have you consider **Nexus sonatype** – Armaiti Jun 17 '15 at 00:59
  • Why don't you extract OtherXYZ.class to a jar file OtherXYZ.jar then package the OtherXYZ.jar to both ROOT.war and OTHER.war – diufanman Jun 17 '15 at 03:08

1 Answers1

5

You will not be able to make a reference to a class in one war from another.

If you deploy as an ear, you could pull RootXYZ.class out of ROOT.war and then place it in a jar that would be on the classpaths of both wars (usually in a /lib directory in the ear). I'm not sure about the exact steps required to set this up in Wildfly, but its' usually a setting in META-INF/application.xml, something like:

<library-directory>/lib</library-directory>

Since in the above you're already pulling common classes into a jar file, I'd probably just include this jar in each war file as part of my build process.

Robert Moskal
  • 21,737
  • 8
  • 62
  • 86
  • "You will not be able to make a reference to a class in one war from another." Can you provide specification or documentation about this/classes visibility between WARs? – Paul Sep 13 '18 at 07:57
  • I can't point to everything except to say that the point of a war file is to contain all the resources needed to run an application. Ear files used to package together multiple applications. – Robert Moskal Sep 13 '18 at 16:17