8 Replies Latest reply on Jul 5, 2009 3:19 PM by Wolfgang Knauf

    EJBTHREE-1823 - handling of res-type in resource-ref

    Wolfgang Knauf Master

      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 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."

      "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 ;-)?