When you moved your entity beans into "subsystems-shared.jar", are you also moving the persistence.xml? And removing persistence.xml from "subsystem.jar"?
Boot up and take a look at the JMX Console, under the heading "persistence.units". If you see more than one entry, and an EAR>JAR>UNITNAME one, this could be a clue that you're services are trying to use the wrong persistence unit (I accidentally did this recently).
Thanks for your reply. Unfortunally the error remains..
From the JMX console.
accountsystem.jar references shared-susbsystems.jar with a Class-Path attribute in the manifest. The Entity EJB3 classes are in the shared-subsystems.jar and the persistence.xml is the accountsystem.jar's meta-inf directory.
The classes loads. In my bean I do this on the first line in the method:
log.info("This: " + this.getClass().getClassLoader());
log.info("User: " + user.getClass().getClassLoader());
And the result is:
[AccountSystem] This: org.jboss.mx.loading.UnifiedClassLoader
[AccountSystem] User: org.jboss.mx.loading.UnifiedClassLoader
Same classloader... I don't understand..
Thanks anyone for anyhelp!!
The Entity EJB3 classes are in the shared-subsystems.jar and the persistence.xml is the accountsystem.jar's meta-inf directory.
Yep - the error isn't due to classloading; it's to the container not recognizing your classes as entities.
Throw persistence.xml into META-INF of shared-subsystems.jar, where your entities are, and give that a whirl.
Hi Al! Thanks again... unfortunally same error.
I moved persistence.xml into subsystem-shared.jar and registered it in application.xml as and removed persisitence.xml from accountsystem.jar.
Same Exception "Unknown Entity".
It simply doesn't seem to work if the EJB3 entities AND the persistence.xml AND the EntityManager(UnitName=xxx) is not defined in the same .jar.
Can it really be like that??
I think it would be great if you could reuse the same entities and persist them through different PersistenceContexts anywhere in the system...
My wish is simple...
I want each subsystem to be as independent as possible. In case of dependency I want to put all dependent classes in a shared.jar for each subsystem.jar to reference to to not get any classloading problems. (Classic approach)
Basiucally the dependent classes are: SessionBean interfaces, Exceptions and DataObjects. The dataobjects are Ejb3 entities.
How do I package it to work?
My idea is that each subsystem put different aspects on the data.... So if I create one dataaccess subsystem and have all entity access go through there and define the whole domainmodel in that .jar I't becomes a mess when the system evolves...
I would like each subsystem to handle its own datamodel with some systemwide dataclassess(Basically PKs with some systemwide attributes) available..
Thanks thanks thanks for your involvement so far!!
In persistence.xml add:
Makes the deployer scan for files in the shared jar..
Why the ../ is used I don't know.. Doesn't find it otherwise..
Thanks anyhow for the help! Hope this helps someone else..