Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

lookup error

Status
Not open for further replies.

svgkraju

Programmer
Joined
Dec 26, 2002
Messages
2
Location
US
Hi,
I am using jdeveloper 9.0.3.
I have downloaded jdev903_pre and unziped and executed jdevw.

I had just created a simple session bean (TSession) and to test it a client has been created. The code is as following:

package Samplemypackage1;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import mypackage1.TSession;
import mypackage1.TSessionHome;
import javax.naming.NamingException;

public class TSessionClient
{
public static void main(String [] args)
{
TSessionClient tSessionClient = new TSessionClient();
try
{
Context context = getInitialContext();
TSessionHome tSessionHome = (TSessionHome)PortableRemoteObject.narrow(context.lookup("TSession"), TSessionHome.class);
TSession tSession;

// Use one of the create() methods below to create a new instance
// tSession = tSessionHome.create( );
tSession = tSessionHome.create();


// Call any of the Remote methods below to access the EJB
// tSession.PrintGiven( java.lang.String str );
tSession.PrintGiven("raju");
}
catch(Throwable ex)
{
ex.printStackTrace();
}

}

private static Context getInitialContext() throws NamingException
{
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
env.put(Context.SECURITY_PRINCIPAL, "admin");
env.put(Context.SECURITY_CREDENTIALS, "welcome");
env.put(Context.PROVIDER_URL, "ormi://localhost:23891/current-workspace-app");

return new InitialContext(env);
}
}

When I run this I got the following error message:

javax.naming.NamingException: Lookup error: java.net.ConnectException: Connection refused: connect; nested exception is:
java.net.ConnectException: Connection refused: connect

java.lang.Object com.evermind.server.rmi.RMIContext.lookup(java.lang.String)

RMIContext.java:134

java.lang.Object javax.naming.InitialContext.lookup(java.lang.String)

InitialContext.java:350

void Samplemypackage1.TSessionClient.main(java.lang.String[])

TSessionClient.java:18

Process exited with exit code 0.

Any idea how to resolve this? Do I need to set any environment variables before using ejbs?

regds
-raju
 
Before running the client program, make sure you right-click and run your TSession bean. This will cause your EJB to be deployed to the embedded OC4J.

Then your client program should be able to locate and use it.

r
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top