users@glassfish.java.net

Re: Call remote EJB3 module from web application.

From: <glassfish_at_javadesktop.org>
Date: Mon, 17 Dec 2007 09:36:20 PST

Hi cheng,

Thanks for your response, here are the descriptors and lookup code.

[b]ejb-jar.xml of deployed EJB in app1.ear[/b]
<session>
    <description>UserBeanSession</description>
    <display-name>UserBeanSession</display-name>
    <ejb-name>UserBean</ejb-name>
    <home>com.ssi.session.UserBeanHome</home>
    <remote>com.ssi.session.UserBean</remote>
    <ejb-class>com.ssi.session.UserBeanSession</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    <resource-ref>
        <res-ref-name>SecurityDS</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>
</session>

[b]Jboss.xml of deployed EJB in app1.ear[/b]
<session>
    <ejb-name>UserBean</ejb-name>
    <jndi-name>ejb/UserAdmin/UserBean</jndi-name>
    <clustered>True</clustered>
    <cluster-config>
        <partition-name>
      ${jboss.partition.name:DefaultPartition}</partition-name>
        <home-load-balance-policy>
              org.jboss.ha.framework.interfaces.RoundRobin
        </home-load-balance-policy>
        <bean-load-balance-policy>
              org.jboss.ha.framework.interfaces.RoundRobin
        </bean-load-balance-policy>
    </cluster-config>
    <resource-ref>
        <res-ref-name>SecurityDS</res-ref-name>
        <jndi-name>java:/SecurityDS</jndi-name>
    </resource-ref>
</session>

[b]Web.xml for Servlet in app2.ear[/b]
<ejb-ref>
    <ejb-ref-name>ejb/UserAdmin/UserBean</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <home>com.ssi.session.UserBeanHome</home>
    <remote>com.ssi.session.UserBean</remote>
</ejb-ref>

[b]Jboss-web.xml for Servlet in app2.ear[/b]
<jboss-web>
    <ejb-ref>
        <ejb-ref-name>ejb/UserAdmin/UserBean</ejb-ref-name>
               <jndi-name>UserBean</jndi-name>
    </ejb-ref>
</jboss-web>

[b]Lookup code[/b]

InitialContext ctx = new InitialContext();
Object obj = null;
try {
    obj = ctx.lookup("ejb/UserAdmin/UserBean);
} catch (Exception e) {
    logger.log(Level.ERROR, e.getMessage(), e);
}
UserBeanHome home = (UserBeanHome)obj;
UserBean remote = (UserBean) home.create();


Thanks again for your help.

Bob
[Message sent by forum member 'bpet36' (bpet36)]

http://forums.java.net/jive/thread.jspa?messageID=250424