cancel
Showing results for 
Search instead for 
Did you mean: 

Remote EJB Call from J2EE Application

Former Member
0 Kudos

Hi,

I have been trying to call a remote ejb from the web module project in my j2ee application. I have added the client jar of the bean to my project. and trying to get the ejb like the following.

Context ctx = new InitialContext();
ejbLocalHome orderHome = (ejbLocalHome) ctx.lookup("corbaname:iiop:xx.xx.xx.xx:xxxx#xxx/xxx/xxxx/xxx/xxxxxHome");
return orderHome.create();

When i deploy my applicatoin to the portal, and call it from the browser, i get the following exception.


[Ljava.lang.StackTraceElement;@1855b95
org.omg.CORBA.BAD_PARAM: string_to_object() failed : Could not connect to host and port xxxxxx:9100, useSSL=false.  vmcid: 0x0  minor code: 10  completed: No
Invalid URL or IOR: corbaloc:iiop:10.20.10.192:2809/NameService

How do you call a remote ejb? What is wrong above?

Thank you.

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

HI Mehmet Ecevit,

Sorry for the delay. Is it working? If not try giving

InitialContext ctx = new InitialContext();

without giving any parameters to initialcontext.

I don't understand your url string you have passed in the lookup parameter.

Hope this helps.

Sumathi

Former Member
0 Kudos

i am using sap application server 2004s. i deploy my ear to this portal

i have just added the following code

properties.put("force_remote", "true");

and now i get:

com.sap.engine.interfaces.cross.DestinationException:

cannot establish connection with any of the available instances:

10.xx.xx.192:2809 Reason: Cannot open connection on host: and port:

Exception while trying to get InitialContext.

i was given the url (corbaname:iiop:xx.xx.xx.xx:xxxx#xxx/xxx/xxxx/xxx/xxxxxHome) and as they said, "set ims service url as the ejb".

where should i use the corbaname nad iiop pre-names? is this the reason what i get the above exception?

Former Member
0 Kudos

Hi Mehmet Ecevit,

Please recheck if the url string exactly matches the jndi name provided in the vendor specific xml file.

Which server you are you using? My code for initial Context lookup is only for WebLogic Server...

The lookup name (ctx.lookup) should be the same as given in your (ejb-jar.xml within the <ejb-name> tag) Are you sure, it is matches the one given in ejb-jar.xml

Hope this helps

Sumathi

Former Member
0 Kudos

Thank you, Sumathi

I have changed my code like the following;

		Properties properties = new Properties();
		properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");
		properties.put(Context.PROVIDER_URL, "corbaname:iiop:xx.xx.xx.xx:2809");
		
		Context ctx = new InitialContext(properties);
		Object hm = ctx.lookup("nodes/xxx/xxx/server1/ejb/com/xxx/xxx/facade/xxxxHome");
		xxxLocalHome orderHome = (xxxLocalHome) PortableRemoteObject.narrow(hm, xxxLocalHome.class);

but i got the following exception;

java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory

so i change it as:

properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");

now, it works but i get the following exception, now:

[Ljava.lang.StackTraceElement;@17e1b25<br>null<br>Path to object does not exist at nodes, the whole lookup name is

nodes/xxxx/servers/xxx/ejb/xxx/xxx/host/facade/xxxHome.

and also, changing the ip or port doesn't make any effect. i can not figure out what's wrong?

Former Member
0 Kudos

Hi Mehmet Ecevit,

Following is what i used to call remote ejb and it worked:

1. Create the context;

properties = new Properties();

properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");

properties.put(Context.PROVIDER_URL, "t3://localhost:7001");

Context ctx = new InitialContext(properties);

2. Get the Home object

Object hm = ctx.lookup("EMP_HOME_KEY");

EmployeeHome empHome = PortableRemoteObject.narrow(hm, EmployeeHome.class);

3. Get the Component (or Remote or EJBObject)

Employee emp = empHome.create();

4. Call the business method

emp.abc();

Hope this helps

Sumathi