aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes access remote session ejb on remote server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "access remote session ejb on remote server" Watch "access remote session ejb on remote server" New topic
Author

access remote session ejb on remote server

Yi Meng
Ranch Hand

Joined: May 07, 2003
Posts: 270
I have one session ejb deployed on serverA with jndi name: ejb/MySLSBRemoteHome

I have one web client deployed on serverB with the following DD segment:

Both are running weblogic 8.12.

web.xml
<ejb-ref>
<ejb-ref-name>test/myejb</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>test.MySLSBHome</home>
<remote>test.MySLSBRemote</remote>
</ejb-ref>


weblogic.xml

<reference-descriptor>
<ejb-reference-description>
<ejb-ref-name>test/myejb</ejb-ref-name>
<jndi-name>ejb/MySLSBRemoteHome</jndi-name>
</ejb-reference-description>
</reference-descriptor>


index.jsp
Properties prop = new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
prop.put(Context.PROVIDER_URL,"t3://severA:7001");

Context initial = new InitialContext(prop);
Object objref = initial.lookup("java:comp/env/test/myejb");

MySLSBHome home =
(MySLSBHome)PortableRemoteObject.narrow(objref,
MySLSBHome.class);

MySLSBRemote bean = home.create();


Now the problem is that i get an exception:

javax.naming.LinkException: . Root exception is javax.naming.NameNotFoundExcept
ion: Unable to resolve 'ejb/MySLSBRemoteHome' Resolved ejb; remaining name 'MySLSBRemoteHome'

But when i change the lookup to initial.lookup("ejb/MySLSBRemoteHome"); it will work. But i am supposed to use "java:comp/env/test/myejb", right?

Can anyone of you help me out? Thanks in advance


Meng Yi
Malli Raman
Ranch Hand

Joined: Nov 07, 2001
Posts: 312
Hi,

JNDI Name is used for looking up the EJB Home objects. The EJB Reference name is used to indicate that you are referring the EJB's with the given name(i.e test/myEjb). Suppose if you are calling two entity bean methods inside your session bean, you have to indicate the two ejb reference names for this two Entity Beans for better packaging and if you want to use the Entity beans the if you have to get the home object by their JNDI lookups and <B>NOT BY their ejb reference names </B>.

Regards,
M.S.Raman
Yi Meng
Ranch Hand

Joined: May 07, 2003
Posts: 270
Originally posted by Malli Raman:
Hi,

JNDI Name is used for looking up the EJB Home objects. The EJB Reference name is used to indicate that you are referring the EJB's with the given name(i.e test/myEjb). Suppose if you are calling two entity bean methods inside your session bean, you have to indicate the two ejb reference names for this two Entity Beans for better packaging and if you want to use the Entity beans the if you have to get the home object by their JNDI lookups and <B>NOT BY their ejb reference names </B>.

Regards,
M.S.Raman


I am just using a JSP(servlet) to call my SLSB on a remote server......

There is no EJB-EJB communication involved at all.
Malli Raman
Ranch Hand

Joined: Nov 07, 2001
Posts: 312
Originally posted by Yi Meng:


I am just using a JSP(servlet) to call my SLSB on a remote server......

There is no EJB-EJB communication involved at all.


EJB Reference name is basically used for packaging purpose only. In the application while creating the EAR file, you have to declare EJB reference name (which is used to identify that EJB/Web(in your case) component is linked with the EJB Component.

Regards,
M.S.Raman
Yi Meng
Ranch Hand

Joined: May 07, 2003
Posts: 270
In my case, i do not even have a ear file.

I have the ejb jar deployed at serverA and a web component war deployed at serverB with the client jar......
Malli Raman
Ranch Hand

Joined: Nov 07, 2001
Posts: 312
Originally posted by Yi Meng:
In my case, i do not even have a ear file.

I have the ejb jar deployed at serverA and a web component war deployed at serverB with the client jar......


EJB-LINK is used to refer the another EJB's in the DD.

Please this url

http://www.coderanch.com/t/314270/EJB-JEE/java/when-java-comp-env-lookup
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: access remote session ejb on remote server