-
1. Re: Nested DataSource fails to deploy before ejbs
jaikiran Feb 16, 2010 2:19 PM (in response to henk53)There's the jboss.xml (for ejb jar files) where you can add dependencies per bean (i.e. a bean can be configured to depend on something else through the use of <depends>). But since you mention that it's the persistence.xml which requires this datasource, then you can just add this dependency in your persistence.xml. See this http://www.jboss.org/file-access/default/members/jbossejb3/freezone/docs/reference/1.0.7/html/entityconfig.html which explains about:
jboss.depends.{some arbitrary name} - Specify an MBean dependency for the persistence unit deployment.
So you can use:
<?xml version="1.0" encoding="UTF-8"?> <persistence 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_1_0.xsd" version="1.0"> <persistence-unit name="..."> <jta-data-source>java:/DefaultDS</jta-data-source> ... <properties> ... <property name="jboss.depends.1" value="jboss.test:service=YetAnotherDependedOn"/> </properties> </persistence-unit> </persistence>
-
2. Re: Nested DataSource fails to deploy before ejbs
henk53 Feb 16, 2010 2:50 PM (in response to jaikiran)That looks very nice and is exactly what I was looking for. Thanks a bunch!
Although I was originally thinking about finding a way to let the entire EJB module wait for the datasource having been deployed, this seems to do the trick quite nicely. Since the deployment fails only occasionally (perhaps a race condition, perhaps a deployment error on my part), I can't test directly whether it solves my problems, but we'll see in the longer term.
Wouldn't it btw be possible for JBoss AS to spot the dependency automatically? If persistence.xml declares using a specific datasource and JBoss AS is able to keep track of which datasources are already deployed, then it might attempt to look for undeployed datasources whenever it wants to start a persistence unit with a yet undeployed datasource.
Would something like that be possible?
-
3. Re: Nested DataSource fails to deploy before ejbs
jaikiran Feb 16, 2010 2:57 PM (in response to henk53)henk53 wrote:
Wouldn't it btw be possible for JBoss AS to spot the dependency automatically? If persistence.xml declares using a specific datasource and JBoss AS is able to keep track of which datasources are already deployed...
Would something like that be possible?
It does try to add a implicit dependency actually (AFAIK). And the document that i pointed to http://www.jboss.org/file-access/default/members/jbossejb3/freezone/docs/reference/1.0.7/html/entityconfig.html talks about a jboss.no.implicit.datasource.dependency property to "disable" this behaviour. The property description is as follows:
jboss.no.implicit.datasource.dependency - JBoss tries to register deployment dependencies for datasource by guessing the dependency name based on the jndi name of the datasource. Use this switch if the guess is wrong.
I think the persistence module is not able to "guess" the datasource dependency MBean ObjectName correctly because you have packaged the -ds.xml within your .ear - which i think results in a different MBean ObjectName than if you had deployed it directly in deploy folder.