cancel
Showing results for 
Search instead for 
Did you mean: 

java.lang.ClassCastException on Java Client Proxy

Former Member
0 Kudos

Hi Guys.

I'm trying to call a Java Proxy Client from a J2SE application. The code I'm using is the following :


OaCuentasPorCobrarReplicar_PortTypeHome queryOutHome;
OaCuentasPorCobrarReplicar_PortTypeRemote queryOutRemote;
OaCuentasPorCobrarReplicar_PortType iaMaestroDeProveedoresReplicar_PortTypeHome;
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,"com.sap.engine.services.jndi.InitialContextFactoryImpl");
p.put(Context.PROVIDER_URL,"devxi:50004");
p.put(Context.SECURITY_PRINCIPAL,"duztariz");
p.put(Context.SECURITY_CREDENTIALS,"inicio");


Context ctx = new InitialContext(p);
Object ref = ctx.lookup("java:comp/env/ejb/cuentasPorCobrar");
queryOutHome = (OaCuentasPorCobrarReplicar_PortTypeHome) PortableRemoteObject.narrow(ref,OaCuentasPorCobrarReplicar_PortTypeHome.class);
queryOutRemote = queryOutHome.create();

And when executed I'm getting this error :

java.lang.ClassCastException

at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(Unknown Source)

at javax.rmi.PortableRemoteObject.narrow(Unknown Source)

at cobeca.com.ve.traductor.api.Traductor.main(Traductor.java:114)

Caused by: java.lang.ClassCastException: com.sap.engine.services.jndi.persistent.UnsatisfiedReferenceImpl

... 3 more

The EJB is on a Unix machine, and my J2SE application is on my windows workstation.

Could u show me the light at the end of the tunnel?

Best Regards

David.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

That error occurs when the line of code above is executed :


queryOutHome = (OaCuentasPorCobrarReplicar_PortTypeHome) PortableRemoteObject.narrow(ref,OaCuentasPorCobrarReplicar_PortTypeHome.class);

I´ve included the .jar file containing the stub classes into my NWDS project.

Best Regards

David

stefan_grube
Active Contributor
0 Kudos

This line is wrong:

Object ref = ctx.lookup("java:comp/env/ejb/cuentasPorCobrar");

You have to use the JNDI name here.

Regards

Stefan

Former Member
0 Kudos

Hi David,

i am also facing a same problem,plz let me no once u solved this problem

Regards,

Vino

Former Member
0 Kudos

Hi Stefan.

Thanks for your reply.

That's exactly the JNDI name of the bean.

Best Regards,

David.

stefan_grube
Active Contributor
0 Kudos

In this case, write:

Object ref = ctx.lookup("cuentasPorCobrar");

nothing else.

See also this guide for more details:

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/d06315a6-e66e-2910-039c-ba8bbbd2...

Regards

Stefan