on 01-20-2012 12:59 AM
hi experts!
I have created j2ee application with remote EJB interface.
@Stateless
@Remote(CommonPortType.class)
public class CommonServiceImpl implements CommonPortType {
...
}
When I try to call this EJB from test console application
public static void main(String[] args) {
// TODO Auto-generated method stub
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");
props.put(Context.PROVIDER_URL, "....:50204");
props.put(Context.SECURITY_PRINCIPAL, "....");
props.put(Context.SECURITY_CREDENTIALS, "...");
try {
Context ctx = new InitialContext(props);
Object o = ctx.lookup("evola.ru/presale~bnk_ejb_ear/REMOTE/CommonServiceImpl");
CommonPortType ref = (CommonPortType) PortableRemoteObject.narrow(o, CommonPortType.class);
List<DictionaryItem> values = ref.getDictionaryValues();
System.out.println("succeed");
} catch (Exception e) {
e.printStackTrace();
}
}
I'm getting the error:
java.lang.ClassCastException
at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:229)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
at ru.evola.util.jpa.TestClass.main(TestClass.java:29)
Caused by: java.lang.ClassCastException: com.sap.engine.services.jndi.implclient.ClientContext cannot be cast to org.omg.CORBA.Object
at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:212)
... 2 more
on line PortableRemoteObject.narrow(...).
Narrowing doesn't work.
Can anybody explain me where I'm wrong?
P.S. Interfaces on server and client are the same.
According to http://help.sap.com/saphelp_nw73/helpdata/en/49/09439068d4105ee10000000a42189d/frameset.htm
You create the InitialContext object by specifying the JNDI properties. In addition to the standard properties you have to set the new property: props.put(Context.URL_PKG_PREFIXES, "com.sap.engine.services"), which is obligatory when you use the EJB lookup scheme.
....
And the lookup string is built incorrect. To get correct lookup string go to ejbexplorer as described here
http://help.sap.com/saphelp_nw73/helpdata/en/0c/a3a8a6a9754bea9b962a5f285c7475/frameset.htm
select remote and there will be lookup path you can use in remote client.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The problem is not so simple as seems in the beginning.
I have added
props.put(Context.URL_PKG_PREFIXES, "com.sap.engine.services");
in properties and fixed a ClassNotFoundException bug in bean constructor. Now this code works fine ONLY in standalone console app.
But when I try to call the same code on server (in other EJB) it doesn't work. Still have ClassCastException.
I suppose the problem is in the difference of injected classes for javax.rmi.PortableRemoteObject:
in standalone console application is used com.sun.corba.se.impl.javax.rmi.PortableRemoteObject,
on server is used com.sap.engine.services.cross.PortableRemoteObjectContainer
Has anybody some intentions for this?
SAP NW 7.3
JVM 1.6_26
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
> But when I try to call the same code on server (in other EJB) it doesn't work. Still have ClassCastException.
> I suppose the problem is in the difference of injected classes for javax.rmi.PortableRemoteObject:
> in standalone console application is used com.sun.corba.se.impl.javax.rmi.PortableRemoteObject,
> on server is used com.sap.engine.services.cross.PortableRemoteObjectContainer
EJB is on the server1, standalone remote client works but remote client in EJB located on server2 doesn't?
Hi,
if the both EJBs (calling and the called one) are on the same server, you probably are caught by an issue of SAP NetWeaver's lookup implementation. Solution is to put an "application reference" from one EAR to the other (direction does not matter). See my description in this message:
If on the same server, the @Remote modifies the lookup string but not the object returned by lookup().
Regards
Rolf
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.