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.