on 09-21-2007 12:53 PM
When I try create an EJB by the localHome it throws a ClassCastException.
Context jndi = new InitialContext();
MainSessionLocalHome beanLocalHome = (MainSessionLocalHome) jndi.lookup("localejbs/weg.net/atrapp/MainSessionBean");
MainSession session = (MainSession) beanLocalHome.create();
However if I invoke it remotely then Its working perfectly.
Context jndi = new InitialContext();
Object obj = (Object) jndi.lookup("weg.net/atrapp/MainSessionBean");
MainSessionHome beanHome = (MainSessionHome) PortableRemoteObject.narrow(obj, MainSessionHome.class);
MainSession session = (MainSession) beanHome.create();
Follow the detailed information about the exception.
java.lang.ClassCastException
at net.weg.atr.wd.MainView.onActiononActiveLocal(MainView.java:171)
at net.weg.atr.wd.wdp.InternalMainView.wdInvokeEventHandler(InternalMainView.java:148)
at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)
at com.sap.tc.webdynpro.progmodel.controller.Action.fire(Action.java:67)
at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.doHandleActionEvent(WindowPhaseModel.java:420)
at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.processRequest(WindowPhaseModel.java:132)
at com.sap.tc.webdynpro.clientserver.window.WebDynproWindow.processRequest(WebDynproWindow.java:335)
at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:143)
at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doProcessing(ApplicationSession.java:313)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessingStandalone(ClientSession.java:759)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessing(ClientSession.java:712)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doProcessing(ClientSession.java:261)
at com.sap.tc.webdynpro.clientserver.session.RequestManager.doProcessing(RequestManager.java:149)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:62)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:53)
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:401)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:365)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:944)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:266)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
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:100)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
Hi
Try this if you can see <b>MainSessionLocal</b> interface and declare all your methods in that
Context jndi = new InitialContext();
MainSessionLocalHome beanLocalHome = (MainSessionLocalHome) jndi.lookup("localejbs/weg.net/atrapp/MainSessionBean");
MainSessionLocal session = (MainSessionLocal) beanLocalHome.create();
Regards
Abhijith YS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello
maybe there is something wrong with the ejb-refs in the deployment descriptor, looks like the jndi lookup returns a wrong EJB Home Object
try this:
Context jndi = new InitialContext();
Object beanLocalHome = jndi.lookup("localejbs/weg.net/atrapp/MainSessionBean");
System.out.println (beanLocalHome.getClass().getName());
(or replace System.out by something you can have a look at)
Then you will see the type of Object returned by jndi lookup for further error research.
I think the object returned by the jndi lookup is a wrapper generated by the ejb container, maybe you need a call to getInterfaces() too, to see which Interfaces are implemented by the returned BeanHome Object. (hava a look <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html#getInterfaces()">here</a> )
regards
franz
reward points if useful
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I checked it but I didn't identify any problem, except by the strange name of the implementation...
beanLocalHome.getClass().getName()
net.weg.atr.model.session.MainSessionLocalHomeImpl0_0
beanLocalHome.getClass().getInterfaces()
[0]
interface net.weg.atr.model.session.MainSessionLocalHome
[1]
interface com.sap.engine.services.ejb.exceptions.SessionExceptionConstants
[2]
interface com.sap.engine.interfaces.ejb.serialization.EJBSerializable
Hello
try the solution from Abhijith YS (reply above, I think this is correct solution)
check line with MainSessionLocal - your code uses the class MainSession
Context jndi = new InitialContext();
MainSessionLocalHome beanLocalHome = (MainSessionLocalHome) jndi.lookup("localejbs/weg.net/atrapp/MainSessionBean");
MainSessionLocal session = (MainSessionLocal) beanLocalHome.create();
if this also doesn't work, check which class/interfaces are implemented by the Object returned from beanLocalHome.create.
And check your deployment descriptor, maybe there is something wrong with the declaration of the ejb interfaces
Regards
franz
Message was edited by:
Franz Ferner
My code was using the tip of the Abhijith YS and the same problem are hapening.
The descriptor is with default values, build by the plugin... <home>net.weg.atr.model.session.MainSessionHome</home>
<remote>net.weg.atr.model.session.MainSession</remote>
<local-home>net.weg.atr.model.session.MainSessionLocalHome</local-home>
<local>net.weg.atr.model.session.MainSessionLocal</local>
<ejb-class>net.weg.atr.model.session.MainSessionBean</ejb-class>
Hi,
It is possible! Have a look at the WebDynpro Java Tutorials, how to use EJBs in Web Dynpro Java (<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/1f5f3366-0401-0010-d6b0-e85a49e93a5c">Using EJBs in Web Dynpro Applications</a>).
Regards,
Daniel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
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.