[jboss-dev-forums] [Design of EJB 3.0] - EJBTHREE-1823 - handling of res-type in resource-ref

Wolfgang Knauf do-not-reply at jboss.com
Fri Jun 26 14:30:52 EDT 2009


In https://jira.jboss.org/jira/browse/EJBTHREE-1823 a warning message was introduced if a "resource-ref" in ejb-jar.xml lacks the element "res-type".

19:56:41,171 WARN  [ResourceHandler] EJBTHREE-1823 : <res-type> not specified for the <resource-ref> ... in bean ...Bean

I think this warn message is a slight violation of the spec (chapter 16.7.1.3 of EJB3 spec and 5.6.2 of JavaEE5 spec):

"The resource-ref element consists of ... the optional res-type .... The res-type element is optional if an injection target is specified for the
resource; in this case, the res-type defaults to the type of the injection target."

And:
"The resource manager connection factory type must be compatible with the type declared in the res-type element"

So I think that JBoss should warn only if no "injection-target" is specified (though it can handle this case, too).

The content of the res-type element does not seem to be checked by JBoss. Even if I don't enter an injection target and have no or an invalid res-type value, a lookup works. That's quite gentle of JBoss. But according to the spec, I would at least expect an error if the type of the object bound to the mapped-name does not match the "res-type".

By the way: the "resource-ref" element seems to be only valid for a "Resource Manager Connection Factory", but I could use it for injection of a javax.ejb.SessionContext from "java:comp/EJBContext". While digging through the spec for writing this post, I found that I should have used a "resource-env-ref" element....

Any comments from the gurus on my crude theories ;-)?

Wolfgang

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4240434#4240434

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4240434



More information about the jboss-dev-forums mailing list