EJB2 resource-ref problems if the application is deployed in EAP6

Solution Verified - Updated -

Issue

  • See an error during deployment
14:36:46,692 ERROR [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "EJB2examples-packaging-ear.ear" was rolled back with the following failure message: {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.comp.EJB2examples-packaging-ear.ejb.ResourceReferenceDbSession.env.Resource1 is missing [jboss.naming.context.java.jboss.resources.Resource1]"]}
  • See a warning during deployment
WARN  [org.jboss.as.ee] (MSC service thread 1-9) JBAS011001: Could not resolve resource-env-ref java:comp/env/jdbc/Resource2
  • Using XDoclet to generate classes and deployment descriptor result in warnings and errors if the application is deployed with EAP6, see examples below

XDoclet annotated source-code:

/**
 * @ejb.bean name="ResourceReferenceDbSession" type="Stateless" ...
 * 
 * @ejb.resource-ref res-ref-name="jdbc/Resource1"
 *                   res-type="javax.sql.DataSource" res-auth="Container"
 *                   jndi-name="java:jboss/datasources/ExampleDS"
 * 
 * @ejb.resource-ref res-ref-name="java:comp/env/jdbc/Resource2"
 *                   res-type="javax.sql.DataSource" res-auth="Container"
 * 
 * @jboss.resource-ref res-ref-name="java:comp/env/jdbc/Resource2"
 *                     resource-name="eclaims_database"
 *                     jndi-name="java:jboss/datasources/ExampleDS"
 */
public class ResourceReferenceDbSessionBean implements javax.ejb.SessionBean {
    public boolean checkResource1() {
        try {
            DataSource ds = (DataSource) new InitialContext().lookup("java:comp/env/jdbc/Resource1");
            return true;
        } catch (NamingException e) { ... }
        return false;
    }
    public boolean checkResource2() {
        try {
            DataSource ds = (DataSource) new InitialContext().lookup("java:comp/env/jdbc/Resource2");
            return true;
        } catch (NamingException e) { ... }
        return false;
    }
}

Resulting deployment descriptor:

<ejb-jar  xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd" version="2.1">
  <enterprise-beans>
    <session >
      <ejb-name>ResourceReferenceDbSession</ejb-name>

      <home>...</home>
      <remote>...</remote>
      <ejb-class>...</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>

      <resource-ref >
         <res-ref-name>jdbc/Resource1</res-ref-name>
         <res-type>javax.sql.DataSource</res-type>
         <res-auth>Container</res-auth>
      </resource-ref>
      <resource-ref >
         <res-ref-name>java:comp/env/jdbc/Resource2</res-ref-name>
         <res-type>javax.sql.DataSource</res-type>
         <res-auth>Container</res-auth>
      </resource-ref>
    </session>
    ...

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 6.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content