I have the following EAR structure which is deployed to WildFly 9.0.2
root.ear
|-ejb1.jar
|-ejb2.jar
|-lib/
|-libA.jar
|-libB.jar
The libA.jar and libB.jar both have the same class. I have no access to modify libB.jar and I need both the EJB modules to pick the class from libA.jar.
How to enforce this like we do with classpath by the ordering the jars as required?
If your EJB jars need access to classes in both jars then you must remove the unwanted class from libB.jar.
All jars in an EAR lib directory are considered to be the same module when it comes to class visibility. This is mandated by the Java EE specification.
You might get away with adding a Class-Path entry to the MANIFEST.MF file in each EJB jar:
Class-Path: lib/libA.jar lib/libB.jar