Maven EJB Plugin - ejb client generation-tip
One of the developers on my Team came up to me with the folloing scenario, whilst deploying module a webapps to weblogic, one of them would not deploy due to an error "could not istantiate DataSource <datasource name>" ... altough this DataSource isn't declared in that specific app.
It could be I am pointing out the obvious, altough If I'm not the following should save you some time.
I am mentioning this for on a large Cluster like ours which consists fo several machines, build & deploy lifecycle can take over an hour-three depends on the environmens site & location (automation or not ...), so why spend valuable time on it ?
We have a cluster utilizing several layers, In order for layer A to interact with layer B an ejb client is built as part og B.ear, the ejb module naturally generates an ejb-client with the Maven-EJB-Plugin, the ear is compiled and good to go (Well there are no compliation errors ...), in runtime whilst deploying layer B (B.ear for exmaple which includes a-ejb.cleint.jar) starts to look for a data source which is included in the WEB_INF of B.ear, due to the existence of A-ejb-cleint.jar, alrough module B isn't aware A layer exists - This above scenario is cause due to a minor "glitch" in configuration, I call it minor because you really need to exclude one file to make this issue go away see below:
Whilst generating the a-ejb-cleint.jar one needs to execlude any Datasource declarations in the client for it doesent need to access it. The presistence / Datasource declaraiotn is only relevant to A.ear itself - or we would not need a client but the EJB itself - right ???
In order to generate a client you would configure Maven-EJB-Plugin like so:
[...] <build> [...] <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ejb-plugin</artifactId> <version>2.3</version> <configuration> <!-- this is false by default --> <generateClient>true</generateClient> </configuration> </plugin> </plugins> [...] </build> [...]
Whilst in order to make sure the client doesn't include the presistence.xml (which stores the Datasource decleration of module A you should Exclude the presistence.xml file like so:
[...] <build> [...] <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ejb-plugin</artifactId> <version>2.3</version> <configuration> <clientExcludes> <clientExclude>WEB_INF/presistence.xml</clientExclude> </clientExcludes> </configuration> </plugin> </plugins> [...] </build> [...]
Again I hope this was clear / useful.