Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

j2ee

Status
Not open for further replies.

knowledge123

Technical User
Feb 22, 2005
1
SA
Is it possible to have web based(servlet/jsp) ejb client on different machine i.e web container containing ejb client & ejb container housing ejb beans both running on different machines. If possible how do we do it ?

Further i want use web container & ejb container from different vendors for instance web container of tomcat & ejb container of websphere .

I am also interested in making one bean a client of another bean ... this bean may be hosted on different ejb containers

Thanks in advance


 
It merely all the same question: Accessing a EJB which may run in an external (non-local) Container. Generally you will have to lookup the bean via JNDI and a full url. For JBoss as an example EJB Container a full url would be

"jnp://otherserver/application/beanB"

You have two options:

* EJB References

Declare a EJB reference for you web-app or your EJB. In you ejb-jar.xml e.g.:

<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>Bean A</ejb-name>
<home>AHome</home>
<remote>A</remote>
<ejb-class>ABean</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Container</transaction-type>
<ejb-ref>
<ejb-ref-name>ejb/myBean</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<home>BHome</home>
<remote>B</remote>
</ejb-ref>
</session>

</enterprise-beans>
</ejb-jar>

(For more info see the specification from sun).

Then tell your app server where to look for the externally referenced EJB (here: ejb/myBean). Your application servers' documentation will show how.
For JBOSS e.g. in jboss.xml:

<jboss> <enterprise-beans>
<session>
<ejb-name>Bean A</ejb-name>
<ejb-ref>
<ejb-ref-name>ejb/myBean</ejb-ref-name>
<jndi-name>jnp://otherserver/application/beanB</jndi-name>
</ejb-ref>
</session>
<enterprise-beans>
</jboss>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top