I have several web applications packaged in war files, running on a TomEE 9.1 server, with JDK17. The war files are built with Maven. One of these applications (named Historisation) has an interface package in a Historisation.jar file, and an implementation packaged in a Historisation.war file. In Historisation.jar, there is an EJB remote interface, and in Historisation.war, the EJB implementation. As every other application uses this EJB, I specified in the respective pom.xml a dependency with Histoeisation.jar :
<dependency\>
<groupId\>xxx\</groupId\>
<artifactId\>Historisation\</artifactId\>
</dependency\>
The result is that in every war file, there is the Historisation.jar file in the WEB-INF/lib directory.
My problem occurs at execution time : when an application X tries to use the EJB, it **does **get it from the JNDI, but it can't cast it with the correct class. The class name is correct but it is seen in an other module :
java.lang.ClassCastException: class jdk.proxy14.$Proxy596 cannot be cast to class fr.csf.histo.handlers.HistSender (jdk.proxy14.$Proxy596 is in module jdk.proxy14 of loader org.apache.tomee.catalina.TomEEWebappClassLoader @3f4b138; fr.csf.histo.handlers.HistSender is in unnamed module of loader org.apache.tomee.catalina.TomEEWebappClassLoader @44bb33a4)
I don't use the module specificities anywhere in theses applications. Everything was OK with JDK 8, and I don't know what to do to make the class of the object got from the JNDI seen from the classpath rather than a module.
I tried to copy Historisation.jar in the lib directory of the TomEE server. It seems to work, but it looks more like a workaround than a solution. I really have the feeling that I missed something.
Thank you for your help.