on 01-28-2009 11:05 AM
Hai,
I had created a java class that includes the EJB in it
The code is given below :
Properties props = new Properties();
try
{
props.put (Context.INITIAL_CONTEXT_FACTORY,"com.sap.engine.services.jndi.InitialContextFactoryImpl");
props.put(Context.PROVIDER_URL, "<server name >:<server port>");
}
catch (Exception e1)
{
System.out.println("Exception 1 -
> "+e1.getMessage());
}
try
{
Context ctx = new InitialContext(props);
Object o = ctx.lookup("sap.com/DivEAR/LOCAL/com.sap.sdn.ejb.DivLocalHome");
System.out.println("Test");
DivHome home = (DivHome)PortableRemoteObject.narrow(o,DivHome.class);
Div dref = home.create();
System.out.println(dref.Divide(20,4));
}
catch (Exception e2)
{
e2.printStackTrace();
}
But it gives the following Error :
com.sap.engine.services.jndi.persistent.exceptions.NamingException: Exception while trying to get InitialContext. [Root exception is com.sap.engine.interfaces.cross.DestinationException: cannot establish connection with any of the available instances:
192.168.1.37:50200 Reason: Cannot open connection on host: 192.168.1.37 and port: 50200]
at com.sap.engine.services.jndi.InitialContextFactoryImpl.getInitialContext(InitialContextFactoryImpl.java:455)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:197)
at com.sap.sdn.client.DivisionClient.main(DivisionClient.java:44)
Caused by: com.sap.engine.interfaces.cross.DestinationException: cannot establish connection with any of the available instances:
192.168.1.37:50200 Reason: Cannot open connection on host: 192.168.1.37 and port: 50200
at com.sap.engine.interfaces.cross.Destination.getNextAvailableBroker(Destination.java:53)
at com.sap.engine.interfaces.cross.Destination.getRemoteBroker(Destination.java:33)
at com.sap.engine.services.jndi.InitialContextFactoryImpl.getInitialContext(InitialContextFactoryImpl.java:340)
... 5 more
Can anyone help me solve the problem.
Regards,
R.Jude Silvester.
Edited by: Jude Silvester on Jan 28, 2009 12:06 PM
Hi Jude,
1) First goto command prompt, type command: ping 192.168.1.37
It will tell you whether the system is up or not.
2) Ask the basis team for checking the required port at the server.
Regards.
Rajat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hai Rajat,
I pinged and got replied from Server.
Now i tried the following Code :
try{
Properties props=new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sap.engine.services.jndi.InitialContextFactoryImpl");
props.put(Context.PROVIDER_URL, "sapsrv02:50200");
wdContext.currentContextElement().setExc("No Exception : ");
Context ctx = new InitialContext(props);
Object o = ctx.lookup("sap.com/DivEAR/REMOTE/com.sap.sdn.ejb.Div");
}
catch (Exception e)
{
wdContext.currentContextElement().setExc("Exception : "+e.getMessage());
}
got the Error :
Path to object does not exist at REMOTE, the whole lookup name is sap.com/DivEAR/REMOTE/com.sap.sdn.ejb.Div.
Can you please help me solve this problem.
Regards,
Jude
Hi Jude,
did you try to find your object in the JNDI browser? If it doesn't exist in the repository there, you will never find it via this lookup. What I did was
- deploy the service
- go to JNDI browser in NWA (under "Problem management")
- Search context objects for your service name
- Select the correct context and use the "Object Name" of it (hard to say which one is yours, because I did this with a client proxy using a LOCAL interface)
Maybe this gives you a hint.
Regards,
Jörg
Hi Jude,
You won't get any difference in the result whether you use IP address or system name but did you check whether the port 50200 is open or not?
Regards.
Rajat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jude,
The error message is :
"Cannot open connection on host: 192.168.1.37 and port: 50200"
1) Are you passing the parameters that are required, correctly?
2) Also check whether you are able to ping the 192.168.1.37 system or not.
3) Check for the required service is running or not (port is open or not). Most probably the port 50200 is not up on the machine 192.168.1.37
Hope it resolves your problem.
Regards.
Rajat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hai,
I had given the server name instead of ipadress and then also it is showing the same error.
code is :
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sap.engine.services.jndi.InitialContextFactoryImpl");
props.put(Context.PROVIDER_URL, "localhost:50004");
try {
Context ctx = new InitialContext(props);
Object o = ctx.lookup(
"sap.com/HelloWorldEAR/REMOTE/HelloWorldBean/com.sap.sdn.ejb.HelloWorldRemote");
HelloWorldRemote helloRef = (HelloWorldRemote)
PortableRemoteObject.narrow(o, HelloWorldRemote.class);
String msg = helloRef.sayHello("Friend");
System.out.println(msg);
} catch (Exception e) {
e.printStackTrace();
}
Can you please help to solve this problem.
Regards,
Jude
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.