Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

access remote session ejb on remote server  RSS feed

 
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!