I have two independent applications (ear) that have a module with the same name (CoreModule).
The module has the same name in both applications but are different.
Both applications are running in the same Wildfly instance.
The class AuthModule (in the Authentication.jar) instances the class UserFacade (that is in the CoreModule) using lookup:
import javax.naming.InitialContext;
var ic = new InitialContext();
authService = (AuthFacadeLocal) ic.lookup("java:app/core/UserFacade");
AuthFacadeLocal is a local interface in the Authentication.jar that is extended by UserFacadeLocal (that is in the CoreModule).
UserFacade implements UserFacaceLocal.
The problem I’m facing is that when I deploy both ear applications only works the first that finishes its deployment and the second one gives this error when the lookup is executed:
ERROR [org.wildfly.extension.undertow] (default task-3) WFLYUT0077: Error invoking secure response: java.lang.ClassCastException: class com.example.coreModule.boundary.UserFacadeLocal$$$view80 cannot be cast to class com.example.authentication.auth.AuthFacadeLocal (com.example.core.boundary.UserFacadeLocal$$$view80 is in unnamed module of loader 'deployment.App2.ear.coreModule.jar' @235099dd; com.example.authentication.auth.AuthFacadeLocal is in unnamed module of loader 'deployment.App1.ear' @47b9b7dc)
The application structure is as follows:
-App1.ear (http://localhost:8080/App1)
- CoreModule.ejb
-UserFacadeLocal (local interface)
-UserFacade
- Authentication.jar
-AuthFacadeLocal (local interface)
-AuthModule
-App2.ear (http://localhost:8080/App2)
- CoreModule.ejb
-UserFacadeLocal (local interface)
-UserFacade
- Authentication.jar
-AuthFacadeLocal (local interface)
-AuthModule
I tried used the jboss-deployment-structure.xml in each ear with the property:
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
But not worked.