Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

EJB Error: Unable to look up a remote EJB

I am getting the following error when I am trying to look up a remote EJB from another EJB.

Error occurs while the EJB Scheme Context Factory trying to resolve an EJB with scheme ejb:/appName=qp.org/testremotecidear, jarName=qp.org~testcidremoteejb.jar, beanName=TestCIDRemoteEJb, interfaceType=remote, interfaceName=com.qp.cid.ejb.TestCIDRemoteEJbRemote. Check server's trace files for more details.

[EXCEPTION]

javax.naming.NamingException: Error occurs while the EJB Object Factory trying to resolve JNDI reference Reference Class Name: EJB Reference

Type: schemeLookup

Content: true

Type: interfaceType

Content: remote

Type: remote

Content: com.qp.cid.ejb.TestCIDRemoteEJbRemote

Type: ejb-link

Content: TestCIDRemoteEJb

Type: appName

Content: qp.org/testremotecidear

Type: clientAppName

Content: qp.org/testremotecidear

Type: ejb-jar

Content: qp.org~testcidremoteejb.jar

java.lang.ClassCastException: cannot assign instance of com.sap.engine.services.rmi_p4.P4ProxyWrapper to field com.sap.engine.services.ejb3.runtime.SerializedClientProxy.interfaces of type [Ljava.lang.Class; in instance of com.sap.engine.services.ejb3.runtime.SerializedClientProxy

at java.io.ObjectStreamClass$FieldReflector.setObjFieldValues(ObjectStreamClass.java:2054)

at java.io.ObjectStreamClass.setObjFieldValues(ObjectStreamClass.java:1227)

at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1999)

at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1917)

at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1793)

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1338)

at java.io.ObjectInputStream.readObject(ObjectInputStream.java:358)

at com.sap.engine.services.rmi_p4.reflect.P4InvocationHandler.readResult(P4InvocationHandler.java:302)

at com.sap.engine.services.rmi_p4.reflect.P4InvocationHandler.invokeInternal(P4InvocationHandler.java:138)

at com.sap.engine.services.rmi_p4.reflect.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:52)

at com.sun.proxy.$Proxy906.resolveReference(Unknown Source)

at com.sap.engine.services.ejb3.runtime.impl.EJBObjectFactory.getObjectInstance(EJBObjectFactory.java:197)

at com.sap.engine.services.ejb3.runtime.impl.EJBObjectFactory.getObjectInstance(EJBObjectFactory.java:109)

at com.sap.engine.services.ejb3.runtime.impl.JNDIejbResolverContext.lookup(JNDIejbResolverContext.java:122)

at javax.naming.InitialContext.lookup(InitialContext.java:392)

at javax.naming.InitialContext.lookup(InitialContext.java:392)

Can you please let me know what could be the problem.

The code for the EJB method that invokes this remote EJB is as follows:

    public String callCIDRemoteBean(String tempMessage){

 

    String retMessage = "PID EJB Message:"+tempMessage;

    String cidejbMessage = "";

 

    String providerUrl = "<hostname>:<port>";

    String securityPrincipal = "<user>";

    String securityCredentials = "<password>";

 

    Properties props = new Properties();

 

    try{      

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

    props.put(Context.PROVIDER_URL, providerUrl);

   

    props.put(Context.SECURITY_PRINCIPAL, securityPrincipal);

    props.put(Context.SECURITY_CREDENTIALS, securityCredentials);

    // props.put("force_remote", "true");

    props.put(Context.URL_PKG_PREFIXES, "com.sap.engine.services");  

    InitialContext ctx = new InitialContext(props);

    System.err.println("After the InitialContext");

    Object obj = ctx.lookup("ejb:/appName=qp.org/testremotecidear, jarName=qp.org~testcidremoteejb.jar, beanName=TestCIDRemoteEJb, interfaceType=remote, interfaceName=com.qp.cid.ejb.TestCIDRemoteEJbRemote");

    System.err.println("Class name-"+ obj.getClass().getName());

   

    System.err.println("After calling remote EJB: cidejbMessage"+cidejbMessage);

    }catch (Exception e) {

    System.err.println("Inside Exception");    

    e.printStackTrace();

    }

    return retMessage + ": "+cidejbMessage;

    }

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question