External EJB reference
External EJB reference
Note:: if we are calling remote ejb methods from servlets that we can Omit to specify any thing regarding ejb's in web.xml and jboss-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<servlet>
<servlet-name>AServlet</servlet-name>
<servlet-class>AServlet</servlet-class>
</servlet>
<ejb-ref>
<ejb-ref-name>ejb/BHome</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>BHome</home>
<remote>B</remote>
</ejb-ref>
<ejb-ref>
<ejb-ref-name>ejb/RemoteBHome</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>BHome</home>
<remote>B</remote>
</ejb-ref>
</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<!-- A reference to an EJB in the same server with a custom JNDI binding -->
<ejb-ref>
<ejb-ref-name>ejb/BHome</ejb-ref-name>
<jndi-name>someapp/ejbs/beanB</jndi-name>
</ejb-ref>
<!-- A reference to an EJB in an external server -->
<ejb-ref>
<ejb-ref-name>ejb/RemoteBHome</ejb-ref-name>
<jndi-name>jnp://otherserver/application/beanB</jndi-name>
</ejb-ref>
</jboss-web>
NOTE: this will tell jboss where to look for bean B. You also have to tell jboss what bean B is: in case of an external ejb-reference to another application be sure to include bean B's home and remote interface in servlet war.
An EJB reference is called external when the bean B comes from another application unit, which may even be deployed on another server.In this case, you cannot rely on the standard <ejb-link> tag in web.xml since there the beans are not covered in the same file. Instead, you must provide the full JNDI name of the bean B in jboss-web.xml. A full name is of the form:
Note:: if we are calling remote ejb methods from servlets that we can Omit to specify any thing regarding ejb's in web.xml and jboss-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<servlet>
<servlet-name>AServlet</servlet-name>
<servlet-class>AServlet</servlet-class>
</servlet>
<ejb-ref>
<ejb-ref-name>ejb/BHome</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>BHome</home>
<remote>B</remote>
</ejb-ref>
<ejb-ref>
<ejb-ref-name>ejb/RemoteBHome</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>BHome</home>
<remote>B</remote>
</ejb-ref>
</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<!-- A reference to an EJB in the same server with a custom JNDI binding -->
<ejb-ref>
<ejb-ref-name>ejb/BHome</ejb-ref-name>
<jndi-name>someapp/ejbs/beanB</jndi-name>
</ejb-ref>
<!-- A reference to an EJB in an external server -->
<ejb-ref>
<ejb-ref-name>ejb/RemoteBHome</ejb-ref-name>
<jndi-name>jnp://otherserver/application/beanB</jndi-name>
</ejb-ref>
</jboss-web>
NOTE: this will tell jboss where to look for bean B. You also have to tell jboss what bean B is: in case of an external ejb-reference to another application be sure to include bean B's home and remote interface in servlet war.
Comments
Post a Comment