Discussions

EJB programming & troubleshooting: Accessing EJB's from WAR!

  1. Accessing EJB's from WAR! (5 messages)

    Folks,
       I have 1 basic question-
    I got a WAR module which 1 JSP init.
    I got a EJB module which has 1 stateless session bean init.

    I deployed both of them separately to the appserver.
    Inside the JSP,i have a JNDI lookup to the session bean in the ejb module and also i put the session bean client jar in the war module(WEB-INF/lib).

    But,when i execute the JSP(thru browser),the JNDI lookup is failing saying that,not able to load the bean.

    I know,if my put both WAR & JAR in the EAR,it will work.But i have a situation,where i got an app that is writen in WAR and i need to extend it...

    any idea...

    thanks,
    u.

    Threaded Messages (5)

  2. Accessing EJB's from WAR![ Go to top ]

    try to inlcude the ejb reomte interfaces and the stub classes in the war module . I did the same thing and it works form me .(jsp accessing an ejb deployed another ear file).

    I tried this on the websphere 5.0 server .

    thanx and regards
    Prajakt
  3. Accessing EJB's from WAR![ Go to top ]

    Depending on which AppServer you are using, I deployed it the same way as you did in WebLogic and it works fine as long as the WAR includes EJB client classes. In some cases, you might need an entry in web.xml in your WAR that reference the EJB. Consult Web.xml DTD.
  4. Accessing EJB's from WAR![ Go to top ]

    if you deploy the ejb in a separate ear than the jsp, the lookup has to be "blabla", and if you deploy both the jsp and the ejb in the same ear, it has to be "java:comp/env/blabla".

    At least this works for me, eventhough i don't realy understand it.
  5. java:comp/env/ namespace[ Go to top ]

    Hi ,

    <Dieter Cailliau>
    if you deploy the ejb in a separate ear than the jsp, the lookup has to be "blabla", and if you deploy both the jsp and the ejb in the same ear, it has to be "java:comp/env/blabla".

    At least this works for me, eventhough i don't realy understand it.
    </Dieter Cailliau>

    There are 2 types of clients in a J2EE environment
    1) J2EE client , one which resides in the same container context (ejb1 refreing to ejb2 within the same ear)
    2) Thin client ,one which resides outside the container context (diff ear or a standalone java client).

    In the case one the client can refr to the ejbs using the logical namespace java:com:/env/ejb2 while in the second case the name should be the fully qualified jndi name.

    I am still looking for the clues whether this is manadted by EJB spec (thought it doesn't seem so ) or is it a industry standard practice .

    hope it helps ....
  6. Hello,

    We have been using ejb's and war files separately. However, our ejb's were deployed on to weblogic server 6.

    we had an application.xml file which contained info about the context root and the uri of the war file and the ejb's tht it was dependent on.

    Maybe, u could try writing the application.xml file. Yet another way would be the path of the jar file in startweblogic.cmd file. Hope this helps!