Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB Client code Error : NameNotFoundException  RSS feed

 
Amit More
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Friends,
I am very much new to EJB and this is my first application.
I am using weblogic server 7 . I have deploied the EJB on the server, and now for the client code I am getting the error as :


javax.naming.NameNotFoundException: Unable to resolve 'com.ejb.examples.HelloHome' Resolved: '' Un
resolved:'com' ; remaining name 'com.ejb.examples.HelloHome'
at weblogic.rmi.internal.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:109)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:263)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:230)
at weblogic.jndi.internal.ServerNamingNode_WLStub.lookup(Unknown Source)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:337)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:332)
at javax.naming.InitialContext.lookup(InitialContext.java:345)
at com.ejb.examples.HelloClient.main(HelloClient.java:44)


My client code is as below :

----------------------------------------------------------------------------------------
package com.ejb.examples;

import com.ejb.examples.*;
import java.rmi.Remote;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.*;
import java.util.Properties;

/***
* This class is an example of client code that invokes method on a simple stateless session bean.
*/

public class HelloClient
{
public static void main(String[] args) throws Exception
{


try
{
/**
* Setup properties for JNDI initialization.
*/

Properties props = System.getProperties();

props.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
props.put(Context.PROVIDER_URL,"t3://localhost:7001");

/**
* Obtain JNDI initial context.
*/

System.out.println("1");
Context ctx = new InitialContext(props);
System.out.println("2");

/**
* Get a reference to home object
*/

HelloHome obj = (HelloHome) ctx.lookup("com.ejb.examples.HelloHome");
System.out.println("3");



/**
* Home objects are RMI-IIOP objects and so they must be cast into RMI-IIOP objects.
*/

HelloHome home = (HelloHome)javax.rmi.PortableRemoteObject.narrow(obj, com.ejb.examples.HelloHome.class);

/**
* Use factory to create hello EJB Object.
*/

Hello hello = home.create();

/**
* Call the hello() method.
*/

System.out.println(hello.hello());

hello.remove();
}
catch(Exception e)
{
e.printStackTrace();
}

}
};

------------------------------------------------------------------------------------------------------------


If possible please help me as early as possible.
 
Nagendra Prasad
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What IDE are you using? There should be some place where you specify the JNDI bindings for your bean. In this, you have to provide the JNDI name for your EJB.
 
Amit More
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello
I am using the weblogic-jar.xml file having code as below:
------------------------------
<?xml version="1.0"?>
<!DOCTYPE weblogic-ejb-jar PUBLIC
'-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB//EN'
'http://www.bea.com/servers/wls600/dtd/weblogic-ejb-jar.dtd'>
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>Hello</ejb-name>
<reference-descriptor>
<resource-description>
<res-ref-name>com/ejb/examples</res-ref-name>
<jndi-name>HelloHome</jndi-name>
</resource-description>
</reference-descriptor>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>
-------------
Is this correct method?
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
means that you should doinstead of
 
Amit More
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Lasse Koskela
you are absolutely right.
Its working with that name.
Thanks for your reply.

But now I have one more problem:
If I undeply any ejb object and then shutdown the server and after restarting the server I am seeing the same ejb object which I had undeploy previously as it is. Is there any way to deploy it completely. or server stores its reference somewhere?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!