-
Feb 14th, 2012, 01:32 PM
#1
Datasource config for shared EAR contexts (Websphere)
I have read the following very helpful posts about setting up a parent EAR context that can be shared between WARs. My question is about how best to set up datasources under such a config (for Websphere).
http://springtips.blogspot.com/2007/...n-context.html
http://blog.springsource.com/2007/06...g-application/
If you have DAO beans defined in a shared EAR context, which want to @Autowire a Datasource... Or you have @Service beans which use @Transactional.... Then, I presume that you need to have your Datasource and TransactionManager beans also defined in the EAR context.
My problem is that we are currently using Datasource resource references defined in the web.xml for each WAR. How to make these visible to the EAR context? We currently use a shared Datasource definition defined in the Websphere console. The WAR resource references refer to this shared Datasource.
One approach I am considering is to make the DAO and Service beans in the EAR prototypes. And leaving the Datasource and TransactionManager beans defined in each WAR. The idea being that whenever an individual WAR uses such a bean, the individual WAR Datasource and/or TransactionManager will be used. I don't know if there are any pitfalls to this approach, other than marginal extra overhead associated with prototypes. I don't really want to do it this way, because it just seems non-standard and stupid.
Another approach would be to abandon WAR resource references, and define a Datasource bean in the EAR context using the JNDI reference for the console Datasource directly. One issue with this is that it makes Websphere cranky. It emits a warning if you do not use a resource reference. Another issue is that we have found it necessary to tweak the default settings on the resource reference (Unshareable). I don't know how we could preserve this setting without a resource reference.
Finally, Websphere provides a way to define Datasources at the EAR level, using a thing called "The WebSphere Enhanced EAR editor". But this looks clunky. It appears if you do it this way, you are embedding a JDBC provider, and Datasource, including drivers, usernames, and passwords within your application EAR binary.
So, this is almost more of an appserver question. Is there a way to define a resource reference to a console Datasource at the EAR level in Websphere? I am also asking what the standard approach for datasource config in a shared EAR context would be for other application servers. ie TCServer/Jboss.
Thanks in advance for any advice!
- Dom
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules