cancel
Showing results for 
Search instead for 
Did you mean: 

EJB lookup - ClassCastException

Former Member
0 Kudos

Hello,

i am always getting a ClassCastException while casting the looked up object from the initial context.

I tried this from a client Application with the appropriate Properties for the InitialContext and also from a webdynpro application. In both i got the same exception.

Maybe i am missing some references or libraries here.

Any ideas?

the session bean i am using works fine. i have build a web service on top of this bean to ensure this.

Thanx

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Stefan,

Thanks for this hint. Everything works fine now.

Best regards

Former Member
0 Kudos

Hi Stefan,

Yes, thank you for the VERY helpful answer!

Regards,

Georgi

Former Member
0 Kudos

Thank you for answering. I tried your hint with the telnet administrator --> Ok.

Also i tried the new lookup String in the webdynpro application. This resides in following Stacktrace:

An error has occurred:

"Failed to process the request."

Please contact your system administrator.

-


Hide details

Web Dynpro product information:

Product: null, Vendor: SAP AG, Version: null, Build ID: 6.3004.00.0000.20040209174308.0000, Build Date: Sun Feb 29 12:12:10 CET 2004

-


Error stacktrace:

java.lang.IllegalArgumentException: object is not an instance of declaring class

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:324)

at com.sap.engine.services.rmi_p4.reflect.LocalInvocationHandler.invokeInternal(LocalInvocationHandler.java:61)

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

at $Proxy3.create(Unknown Source)

at com.sap.examples.welcome.ResultView.onPlugFromStartView(ResultView.java:167)

at com.sap.examples.welcome.wdp.InternalResultView.wdInvokeEventHandler(InternalResultView.java:275)

at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:97)

at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.navigate(ClientApplication.java:740)

at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleActionEvent(WebDynproMainTask.java:339)

at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:538)

at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:49)

at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:239)

at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doWebDynproProcessing(DispatcherServlet.java:130)

at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:92)

at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:42)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:373)

at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:250)

at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:319)

at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:297)

at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:696)

at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:221)

at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)

at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:146)

at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)

at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)

at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)

at java.security.AccessController.doPrivileged(Native Method)

at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)

at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:140)

Regards

Former Member
0 Kudos

Hi Stefan,

please ensure, that you have declared a sharing reference to the (server-)application which contains the object you want to look up in the WD application.

To declare a sharing reference: go to the properties of the web dynpro project (contextmenu of project) -> Web Dynpro References, Tab "Sharing references".

The reference name must be exactly the same as you see in the Visual Admin for the application, for example "local/usemeas~reference".

Hope that helps.

Regards

Stefan

Former Member
0 Kudos

Sorry i forgot the stack trace for the webdynpro app

Here it is:

java.lang.ClassCastException: com.sit.ps.ejb.OSysControllerHome

at com.sap.engine.services.cross.PortableRemoteObjectContainer.narrow(PortableRemoteObjectContainer.java:164)

at com.sap.engine.system.PortableRemoteObjectProxy.narrow(PortableRemoteObjectProxy.java:24)

at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134) at com.sap.examples.welcome.ResultView.onPlugFromStartView(ResultView.java:166)

at com.sap.examples.welcome.wdp.InternalResultView.wdInvokeEventHandler(InternalResultView.java:275)

at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:97)

at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.navigate(ClientApplication.java:740)

at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleActionEvent(WebDynproMainTask.java:339)

at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:538)

at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:49)

at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:239)

at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doWebDynproProcessing(DispatcherServlet.java:130)

at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:92)

at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:42)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:373)

at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:250)

at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:319)

at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:297)

at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:696)

at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:221)

at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)

at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:146)

at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)

at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)

at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)

at java.security.AccessController.doPrivileged(Native Method)

at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)

at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:140)

Former Member
0 Kudos

Hi Benny,

here is the code for the remote Client lookup to my Bean:

Properties p = new Properties();

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

p.put(Context.PROVIDER_URL, "192.168.0.123:50004");

p.put(Context.SECURITY_PRINCIPAL, "Administrator");

p.put(Context.SECURITY_CREDENTIALS, "fggt0815");

Context initialContext = new InitialContext(p);

Object obj = initialContext.lookup("sap.com/EAIPurchasing");

PurchasingHome home = (PurchasingHome) PortableRemoteObject.narrow(obj, PurchasingHome.class);

Purchasing bean = home.create();

String result = bean.storeOrder(orderAsXml);

i am getting the following stack trace:

java.lang.ClassCastException

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

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

at EJBClient.lookup(EJBClient.java:59)

at EJBClient.main(EJBClient.java:77)

Exception in thread "main"

the coding for my webdynpro is nearly the same (lookup remote interface of Bean), but i just call

Context ctx = new InitialContext();

Beat Regards

Former Member
0 Kudos

Hi Stefan,

I'm not a 100% sure, but I think the lookup string you're using is not correct. By default, the lookup string is constructed as: <app provider name>/<application name>/<bean name>, where sap.com is the default provider name for apps deployed on WebAS Java; <application name> is the name of the application the bean is deployed with.

Anyway, you can test the lookup string you use in your code now using the Telnet administrator of Web AS Java. Just connect a telnet client to <your host>, port 50008. Login with your user/password. Then use the JUMP command to jump to the server where the bean resides. Then execute ADD NAMING to add the shell commands of the Naming services. Then execute the LOOKUP command for your lookup string to see whether the system can lokk your bean up. If you get an error there, adjust the lookup string in your code.

Hope that helps,

Ivo.

Benny
Product and Topic Expert
Product and Topic Expert
0 Kudos

Could you get the code parts here and also the exception?

Regards,

Benny