• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Problem Accessing Local EJB!!!!!!

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am calling a local stateless session bean from a stateless session bean of remote type.
During look up for the local bean i am getting this error
javax.naming.NameNotFoundException: Context: localhost/nodes/localhost/servers/server1, name: ejb/cbsejb/CBSLocalHome: First component in name CBSLocalHome not found. [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL mg.org/CosNaming/NamingContext/NotFound:1.0]
Whats the problem??
I am using WSAD5.1.1
 
author
Posts: 181
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you set up a Local EJB Resource Reference on the calling Session Bean to the other Bean you are calling?
 
Gaurav Jain
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes i have done it the EJB deployment descriptor in the references tab but the problem still persists.
Just to clarify my parent bean calling bean is CBSSession whic is of remote type and my target bean which is local is CBS and i have set up the reference on CBSSession.
Is that correct?
 
Roland Barcia
author
Posts: 181
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to make sure you are using the <ejb-loc-ref> tag. Also, to use references, make sure you are pre-qualifiying your lookups with java:comp/env
 
Gaurav Jain
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried whatever you had told but now i am getting the following error:
javax.naming.NameNotFoundException: Name comp/env/ejb/cbsejb not found in context "java:".
I am doing the lookup in the following manner:
InitialContext ctx = new InitialContext();
Object obj = ctx.lookup("java:comp/env/ejb/cbsejb/L2LocalHome");
CBSLocalHome objHome = (CBSLocalHome)obj;
CBSLocal objLocal = objHome.create();
objLocal.accessLocal(sUserId);
 
Roland Barcia
author
Posts: 181
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you bind your reference to the real JNDI name your EJB is defined to. If you are using the EJB DD editor, what value do you have for WebSphere Binding for the reference and is it the same as the binding on the Bean tab for the Local EJB.
 
Gaurav Jain
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Roland,
It worked,however i din not have to specify any EJB Resource reference tag,all i did was looked up the bean using the following:
local:ejb/<jndi name>
 
Roland Barcia
author
Posts: 181
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, however, using Resource References will keep the Java Code Portable and is rececomended. Your code now has WebSphere specific namespace in the code when Resources References should hide that from the code.
 
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Gaurav,
I tried the same using Weblogic 7.0. No issues there.
I had written the lookup of the Local Session Bean in one of the business methods of the Remote one. Snippet of the code and both the xml is mentioned below.
Rgds,
Seetesh
public class PlayerBean implements SessionBean
{
......
public String playercall()
{
try
{
Context ic= new InitialContext();
erHome= (ERHome) ic.lookup("JNDIERLocal");
System.out.println("SEETESH 1 : CREATING ER FROM PLAYER");
er = erHome.create();
//er = (ER) PortableRemoteObject.narrow(erHome.create(),ER.class);
System.out.println("SEETESH 2 : CREATED ER FROM PLAYER BEFORE CALLING DISPLAYSEET");
String aaa = er.displaySeet();
System.out.println("SEETESH 3 : AFTER CALLING DISPLAYSEET aaa : "+aaa);
return "success";
}
ejb-jar.xml
-----------
<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC
'-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN'
'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>PlayerEJB</ejb-name>
<home>ejb.stateless.er.PlayerHome</home>
<remote>ejb.stateless.er.Player</remote>
<ejb-class>ejb.stateless.er.PlayerBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<env-entry>
<env-entry-name>WEBL</env-entry-name>
<env-entry-type>java.lang.Double </env-entry-type>
<env-entry-value>10.0</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>INTL</env-entry-name>
<env-entry-type>java.lang.Double </env-entry-type>
<env-entry-value>15.0</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>playerLimit</env-entry-name>
<env-entry-type>java.lang.Integer </env-entry-type>
<env-entry-value>100</env-entry-value>
</env-entry>
</session>
<session>
<ejb-name>EREJB</ejb-name>
<local-home>ejb.stateless.er.ERHome</local-home>
<local>ejb.stateless.er.ER</local>
<ejb-class>ejb.stateless.er.ERBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<env-entry>
<env-entry-name>erLimit</env-entry-name>
<env-entry-type>java.lang.Integer </env-entry-type>
<env-entry-value>300</env-entry-value>
</env-entry>
</session>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>PlayerEJB</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>EREJB</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
<ejb-client-jar>ejb20_SB_local_remote.jar</ejb-client-jar>
</ejb-jar>
weblogic-ejb-jar.xml
---------------------
<?xml version="1.0"?>
<!DOCTYPE weblogic-ejb-jar PUBLIC
'-//BEA Systems, Inc.//DTD WebLogic 7.0.0 EJB//EN'
'http://www.bea.com/servers/wls700/dtd/weblogic-ejb-jar.dtd'>
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>PlayerEJB</ejb-name>
<jndi-name>JNDIPlayer</jndi-name>
</weblogic-enterprise-bean>
<weblogic-enterprise-bean>
<ejb-name>EREJB</ejb-name>
<local-jndi-name>JNDIERLocal</local-jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>
 
Roland Barcia
author
Posts: 181
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't have to use Resource References, but it is recomended. The J2EE spec does not define how to bind an EJB to the real namespace. So WebLogic uses 2 different names in its weblogic-ejb.xml for each Bean type: Local or Remote. WAS binds the EJB to on JNDI name even if it has both a Remote and Local Interface. Inside of WAS, it will be pre-qualified with local:. But if you define a <ejb-loc-ref> and bind it to the JNDI name of the Local EJB, then it will automatically use the local interface based on the <ejb-loc-ref> tag. Although you may get similar code to work in 1 or 2 app servers, resource references are guaranteed to work in any app server.
 
Good night. Drive safely. Here's a tiny ad for the road:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic