P.S. I should add something. The "shared" classes still need to be in their own classloaders, some of them are statics which would be different between app1 and app2...
So are you saying that you are maintaining these statistics in static variables, or that you are using singletons? If so, then you will need to inlcude the common classes in each EAR and define a classloader repository for reach EAR.
The other otpion would be to not maintain any data in static or singleton object - then each EAR would have its own set of data objects maintining their own sets of data even if the command classes were packed in a JAR and placed in common/lib.
thanks for answer, Peter.
I'll try to be more concrete, imagine a Database class which manages the database (what else) operations. This class will create a singleton per app (app1 Database and app2 Database will have different connections and so, to 2 different databases). In the same time, the WAR and the EJBs in each app will have to use the same Database instance (since they do work on the same database).
What I want is an infrastructure which will allow me to add core/classes/../Database to both classpaths of the 2 apps. I want to be able to compile the class and have the apps bounce without restarting the server (hot redeployment), and I definitely want to have the folder in the classpaths, not a packaged jar.
Hope that clarifies a little...
P.S. refactoring the statics and replacing them with actual instances is not really a solution, the amount of code that needs to change is vast, and the database class is one of the many singletons in the apps...
Since you are using singletons (you answered "yes" to the question in the first paragraph of my prior reply), the solution is in the second sentence of the first paragraph.
thanks Peter, I might have misread your first question "you are maintaining these statistics in static variables or ..."
The truth is that for the purpose of my question I hardly see any relevance if it's statics or singletons, since singletons (as a pattern) are implemented usually using statics. So, in any case, assuming that there is a subtle difference which I miss at this point, allow me to change the answer to your question by saying that yes, the Database class uses static variables, and is not a Singleton in a "design pattern" kind of way... Would this change your answer?
Up to this point is pretty clear that I need separate classloaders for each EAR, and this classloader should be the one that loads the Database class (as per my example). The question remains if I can just add a folder with classes to the classpath of each app, or I still need to package them as a jar and copy them in the structure of the EAR of each app...
Static or singleton, it doesn't matter. You are still stuck packaging the common classes in a JAR and including that JAR in both EARs and defining a classloader repository. Unless you place the JAR completely ouside of JBoss AS and write your own classloader.