-
1. JBoss 6 & Persitence Archive in WEB-INF/lib
alesj Mar 21, 2011 5:41 AM (in response to vincent_aumont)I doubt the order has anything to do with this.
As we scan things in a different stage then where we do the wiring.
The real cause may be hidden somewhere else,
unfortuantely I don't have any idea where that might be. :-)
-
2. JBoss 6 & Persitence Archive in WEB-INF/lib
asiandub Mar 21, 2011 8:52 AM (in response to vincent_aumont)Dan Allen just blogged about about a similiar issue with Glassfish / JEE 6. I doubt that this is related, but as I happen to read both articles within 30 minutes or so, I provide the link...
http://in.relation.to/Bloggers/IsSeam3GoingToBePortableOrWhat#H-AlphabravoVisibility
Cheers,
Jan
-
3. JBoss 6 & Persitence Archive in WEB-INF/lib
alesj Mar 21, 2011 9:44 AM (in response to asiandub)How is this related?
Afaik VincentA is not using Seam nor CDI, but plain per-spec web-profile behavior.
-
4. JBoss 6 & Persitence Archive in WEB-INF/lib
vincent_aumont Mar 21, 2011 12:13 PM (in response to alesj)Jan, Ales,
Not related, but similar.
The issue Dan describes is:
- in certain cases, types (classes) in one bean archive (jar) aren't visible to beans and extensions in another jar in a web module
- visibility is dependent on the alphabetic order of the archive names
which is what I'm observing with AS 6.
I would expect jboss to start all Persistence Units it finds in web-inf/lib/*.jar before doing the wiring (
@PersistenceContext(unitName = "my-pu"))
. It is clearly not the case.It start smelling like a bug.
I guess the workaround is to 1) rename my persistence jars so that the are scanned first or (2) stopusing
@PersistenceContext
and do a lookup insteadVincent
-
5. JBoss 6 & Persitence Archive in WEB-INF/lib
alesj Mar 21, 2011 12:25 PM (in response to vincent_aumont)Are you using Seam3/CDI?
I think .war visibility issues are mostly related to GlassFish,
as BeanManager wiring is done differently as how we do it in JBossAS6.
* WELD-846
-
6. JBoss 6 & Persitence Archive in WEB-INF/lib
vincent_aumont Mar 21, 2011 3:09 PM (in response to alesj)I'm not using seam, but I use CDI.Should I try to upgrade Weld?
-
7. Re: JBoss 6 & Persitence Archive in WEB-INF/lib
vincent_aumont Mar 27, 2011 3:48 PM (in response to vincent_aumont)Making progress: when I have two entities jars (i.e. 2 persistence.xml files) in WEB-INF/lib, only the persistence unit from the first jar is started.
My war file has the following structure:
{code}
my-war
+-- WEB-INF
+-- lib
+-- pu1.jar
+-- META-INF
+ persistence.xml
+-- pu2.jar
+-- META-INF
+ persistence.xml
{code}
pu1.jar's persistence.xml:
{code}
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="pu1" >
<jta-data-source>java:/DefaultDS</jta-data-source>
</persistence-unit>
</persistence>
{code}
pu2.jar's persistence.xml:
{code}
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="pu2" >
<jta-data-source>java:/DefaultDS</jta-data-source>
</persistence-unit>
</persistence>
{code}
When I deploy this file, only the first PU is started:
{code}
12:23:38,192 INFO [PersistenceUnitDeployment] Starting persistence unit persistence.unit:unitName=webapp-1.0-SNAPSHOT.war#pu1
{code}
If I rename pu2.jar 'apu2.jar' (so that it is scanned first), only the pu2 PU is started:
{code}
12:37:15,631 INFO [PersistenceUnitDeployment] Starting persistence unit persistence.unit:unitName=webapp-1.0-SNAPSHOT.war#pu2
{code}
I tried using two different data sources but it didn't help.
Having JPA entities in the jars does not help either.
Any idea who jboss 6 doesn't process the second entities jar?
-
8. Re: JBoss 6 & Persitence Archive in WEB-INF/lib
vincent_aumont Mar 27, 2011 3:59 PM (in response to vincent_aumont)Attaching the war file.
-
webapp-1.0-SNAPSHOT.war 4.4 KB
-
-
9. Re: JBoss 6 & Persitence Archive in WEB-INF/lib
alesj Mar 27, 2011 5:21 PM (in response to vincent_aumont)Any idea who jboss 6 doesn't process the second entities jar?
I think this is by design -- see PersistenceUnitParsingDeployer.
It only parses the first persistence.xml it finds in (sub)deployment.
If you would re-organize / re-structure your app,
so that it's 1 persistence.xml per sub-deployment,
it will pick up all of them.
e.g.
An .ear with N jars with persistence.xml and X .wars.
-
10. Re: JBoss 6 & Persitence Archive in WEB-INF/lib
vincent_aumont Mar 27, 2011 6:38 PM (in response to alesj)And if I have a pu in WEB-INF/classes/META-INF, it's the one that gets started:
{code}
my-war
+-- WEB-INF+-- classes
+-- META-INF
+ persistence.xml
+-- lib
+-- pu1.jar
+-- META-INF
+ persistence.xml
+-- pu2.jar
+-- META-INF
+ persistence.xml{code}
Is this behaviour documented somewhere? I don't understand why it was implemented that way.
I also noticed that when jboss does not start my PU's, it starts the timerdb PU from $JBOSS_HOME/common/deploy/jboss-ejb3-timerservice-mk2.jar/ . Should not jars in common/lib be considered as different sub-deployment?
Another workaround -if I want to keep packaging my app as a war- would be add a persistence.xml in WEB-INF/classes/META-INF and load all entities contained in pu1.jar and pu2.jar with <jar-file>.
Of course it'll wotk only if all my PU's use the same data source.
-
11. Re: JBoss 6 & Persitence Archive in WEB-INF/lib
vincent_aumont Mar 27, 2011 9:53 PM (in response to vincent_aumont)Hi Ales,
I read the JPA spec again, and I think starting only the first PU in a sub-deployment is non-compliant.
Clearly, we can have several persistence jars whithin a war:
{code}
(from section 6.2)
A persistence unit may be packaged within one or more jar files
contained within a WAR or EAR, as a set of classes within an
EJB-JAR file or in the WAR classes directory, or as a combination
of these as defined below.
{code}
The only reason why you'd need an ear file is if your PU contains classes outside of the jar:
{code}
(from section 6.2)
It is not required that an EJB-JAR or WAR containing a persistence
unit be packaged in an EAR unless the persistence unit contains
persistence classes in addition to those contained in the EJB-JAR
or WAR. See Section 6.2.1.6.
{code}
And it's clear that the container must process all persistence.xml files, not just the first one:
{code}
7.1.1 Responsibilities of the Container
At deployment time the container is responsible for scanning the
locations specified in Section 6.2 and discovering the persistence.xml
files and processing them.
When the container finds a persistence.xml file, it processes the
persistence unit definitions that it contains.
{code}
-
12. Re: JBoss 6 & Persitence Archive in WEB-INF/lib
alesj Mar 28, 2011 10:33 AM (in response to vincent_aumont)Let me check how hard would it be to replace current deployer's behavior.
-
13. Re: JBoss 6 & Persitence Archive in WEB-INF/lib
jaikiran Mar 29, 2011 5:21 AM (in response to alesj)Ales Justin wrote:
Any idea who jboss 6 doesn't process the second entities jar?
I think this is by design -- see PersistenceUnitParsingDeployer.
It only parses the first persistence.xml it finds in (sub)deployment.
my-war +-- WEB-INF +-- classes +-- META-INF + persistence.xml +-- lib +-- pu1.jar +-- META-INF + persistence.xml +-- pu2.jar +-- META-INF + persistence.xml
Isn't pu1.jar and pu2.jar considered as 2 different sub deployments in this case?
-
14. Re: JBoss 6 & Persitence Archive in WEB-INF/lib
alesj Mar 29, 2011 5:57 AM (in response to jaikiran)Isn't pu1.jar and pu2.jar considered as 2 different sub deployments in this case?
Nope, they are just 2 entries in .war's classpath.
(or 2 more roots in its classloader)