File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Local EJB call -  Naming Exception 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 "Local EJB call -  Naming Exception" Watch "Local EJB call -  Naming Exception" New topic
Author

Local EJB call - Naming Exception

poonks Arasu
Greenhorn

Joined: Jun 20, 2002
Posts: 6
I am using weblogic 7.0 and i am making an local call on ejb using a client in the same environment.I am getting this exception while lookup.
Is there anything i missed in client program/ejb descriptors/weblogic descriptors.
javax.naming.NameNotFoundException: Unable to resolve 'HelloLocalHome' Resolved: '' Unresolved:'HelloLocalHome' ; remaining name 'HelloLocalHome'
at weblogic.rmi.internal.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:109)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:262)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:229)
at weblogic.jndi.internal.ServerNamingNode_WLStub.lookup(Unknown Source)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:338)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:333)
at javax.naming.InitialContext.lookup(Unknown Source)
at examples.HelloClients.main(HelloClients.java:37)
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
We would need to see the deployment descriptors (both ejb-jar.xml and the vendor-specific one).


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
poonks Arasu
Greenhorn

Joined: Jun 20, 2002
Posts: 6
Hi i am giving same
EJB DESCRIPTOR:
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>Hello</ejb-name>
<home>examples.HelloHome</home>
<remote>examples.Hello</remote>
<ejb-class>examples.HelloBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<ejb-local-ref>
<ejb-ref-name>Hello</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home>examples.HelloLocalHome</local-home>
<local>examples.HelloLocal</local>
</ejb-local-ref>
</session>
</enterprise-beans>
</ejb-jar>
VENDOR SPECIFIC DESCRIPTOR:
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>Hello</ejb-name>
<reference-descriptor>
<ejb-local-reference-description>
<ejb-ref-name>Hello</ejb-ref-name>
<jndi-name>HelloLocalHome</jndi-name>
</ejb-local-reference-description>
</reference-descriptor>
<clients-on-same-server>true</clients-on-same-server>
<jndi-name>HelloHome</jndi-name>
<local-jndi-name>HelloLocalHome</local-jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8904

Send us the lookup code as well.


Groovy
poonks Arasu
Greenhorn

Joined: Jun 20, 2002
Posts: 6
Hi
I am providing the lookup code
Client lookup :
Properties props = System.getProperties();
Context ctx = new InitialContext(props);
examples.HelloLocalHome home = (examples.HelloLocalHome)ctx.lookup("HelloLocalHome");
HelloLocal hello = home.create();
System.out.println(hello.hello());
hello.remove();
Calling code
java
-Djava.security.policy=../java.policy
-Djava.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
-Djava.naming.provider.url=t3:ip ort
examples.HelloClient
thanks,
poonks
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Poonks,
(btw, you might want to change your name to comply with the 'Ranch naming policy)
Your code should use the following lookup string:

Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Hey, wait a minute. Are you calling a local interface from a remote standalone client? That isn't even supposed to work.
poonks Arasu
Greenhorn

Joined: Jun 20, 2002
Posts: 6
Lasse,
Can you please throw more light into it.
Am I supposed to call this from servlet/EJB only
(I will chnage name to comply with the 'Ranch naming policy)
Thanks,
poonks
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
You can call the EJB from a standalone client but you'll have to use a remote interface instead of the local interface.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
That would require some changes to your client-side code:

...and ofcourse your deployment descriptors need to be changed to using <ejb-ref> instead of <ejb-local-ref>, <home> instead of <local-home>, etc.
poonks Arasu
Greenhorn

Joined: Jun 20, 2002
Posts: 6
Thanks Lasse,
Actually we am planning to call Local interface one EJB from another EJB in same M/c.So initially i am trying out how to call local interface.Can you please clarify me Instead of a standalone call can i do the same call from another EJB.
Thanks in advance
poonks
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
You can call a local interface from another EJB as long as the calling EJB is in the same .ear as the target EJB.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Local EJB call - Naming Exception
 
Similar Threads
EJB Client code Error : NameNotFoundException
Unable to resolve JMS TOPIC Name
when calling EJb , i am getting exception (javax.naming.LinkException)
Naming Exception 'Unable to resolve ...'
Entity Bean Not getting Bound to JNDI in WLS 6.1