[javaee-spec users] [jsr342-experts] Re: Clarification on Default resources

From: Linda DeMichiel <>
Date: Wed, 5 Jun 2013 16:09:45 -0700 (PDT)

Hi Kevin,

On 6/4/2013 2:07 PM, Kevin Sutter wrote:
> Hi,
> The discussion about the Default resources in the Java EE 7 spec pre-dates my involvement, so I'm looking for some
> clarification. I've reviewed the discussion in the archives and an associated JIRA, but I still have questions...
> I was especially interested in David Blevin's replies as they relate to OpenEJB and TomEE since it sounds like they
> already provide default resource bindings similar to WebSphere.
> My basic question centers around this example. From the spec, are these two @Resource injections supposed to resolve to
> the same datasource?


> __at_Resource_(lookup="java:comp/DefaultDataSource")
> DataSource myDS;
> __at_Resource_
> DataSource myDS;
> My reading of the spec would indicate that the latter example (plain @Resource) would default to the product's default
> datasource. The use of the word "product" is key in my understanding. If the product already provides a default mapping,
> then the plain @Resource could continue to default to the behavior as prescribed by the product. But, if the product
> does not currently provide a default mapping, then the plain @Resource could default to the newly defined resource
> located at java:comp/DefaultDataSource. And, Werner's final comment seems to support that interpretation:

If the product already (i.e., pre JavaEE 7) supported a default mapping, then the expectation would be
that the two code snippets above would under Java EE 7 both refer to that same default data source.

> "Thanks, that sounds like the most flexible approach. While not confusing those who are fine with the default
> lookup, others who may require alternatives there can overwrite it."

The spec requires the product to support the default mapping, but is silent on the possibility of
the overwriting of the mapping, e.g., by the administrator or deployer. However, in the absence of such
hypothetical overwriting, the expectation of the spec is that the two uses of @Resource above reference
the same default datasource.

> Is my interpretation accurate? Thanks for the input.

I'm not sure whether your interpretation is in agreement with what I've written. Can you confirm?



> ----------------------------------------------------------------------------------------------------------------------------------------------------------------
> Kevin Sutter, Java EE and Java Persistence API (JPA) architect
> mail:, Kevin Sutter/Rochester/IBM
> phone: tl-553-3620 (office), 507-253-3620 (office)