Skip to Content
author's profile photo Former Member
Former Member

Is it possible access local ejb in the web dynpro? Only remotly works.

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 ItÂ’s 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)

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 25, 2007 at 02:13 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 24, 2007 at 08:26 AM

    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 herehttp://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html#getInterfaces()">here> )

    regards

    franz

    reward points if useful

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 21, 2007 at 03:04 PM

    Hi,

    It is possible! Have a look at the WebDynpro Java Tutorials, how to use EJBs in Web Dynpro Java (Using" target="_blank">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).

    Regards,

    Daniel

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      I've already seem this tutorial and others about using web dynpro with jsp and jndi... My application doesn't have a java project to implement the command design patterns, then the code that I put in the first post is from the web dynpro mainController.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.