I have a problem loading JBoss and loading classes.
Here is the configuration I'm working with. I have two instances of JBoss 4.2.3.GA on the same server. In each instance, the application launches, and these applications exchange data with each other. There is a utility class packaged in both application archives. This utility class is exactly the same in both applications.
This is usually normal, but in special situations I can get a ClassCastException . The point is: The user uses a web application that invokes the application on the first instance of JBoss (let him name application A). And application A calls application B (in the second instance). This particular challenge takes a few seconds to succeed. If another user tries to use the web application in a similar context (a call to application A calling application B), and if this call occurs during the first user call, I get a ClassCastException systematic exception: X cannot be cast to X
(where X is my utility class shared by both applications) .
I found some information, and I realized that this is a class loading problem. Indeed, in this particular context of simultaneous calls, my utility class is not loaded by the same class loader. I put the print command to see which class loader is used. In normal mode, org.jboss.mx.loading.UnifiedClassLoader3 is used to load classes . In the example described above, application B apparently uses a different classloader for the second user. My print team gave me the following:
WebappClassLoader
delegate: false
repositories:
/WEB-INF/classes/----------> Parent Classloader:java.net.FactoryURLClassLoader@de8209
I assume that application B returns an instance of my utility class loaded by this WebappClassLoader , and application A (which uses UnifiedClassLoader3) cannot use it.
, UnifiedClassLoader3 B. WebappClassLoader ?
, JBoss, , , :
<jboss-app>
<module-order>strict</module-order>
<loader-repository>applicationAorApplicationB.ear</loader-repository>
</jboss-app>
- ? jboss, ?
, : , .
.