[jbossws-users] Accesing an EJB from a WS server endpoint

Razvan Deaconescu razvan at anaconda.cs.pub.ro
Wed Oct 1 07:16:21 EDT 2008


Hi!

I am trying (unsuccessfully) to acces an EJB from within a webservice
endpoint in JBoss 4.2.3GA

The EJB is deployed within an ear. The WS endpoint is deployed in a war
file. I am trying to access the WS endpoint using InitalContext's lookup
method:

--
Context initial = new InitialContext();
Object objref = initial.lookup("java:comp/env/ejb/SimpleDB");
---

However, this fails with "EJB not found exception". I probably didn't do
the correct mapping in the WS web.xml file:

---
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"


xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"

  version="2.4">

  <servlet>
    <servlet-name>SecureStore</servlet-name>
    <servlet-class>SecureStore.SecureStoreServer</servlet-class>
  </servlet>


  <servlet-mapping>
          <servlet-name>SecureStore</servlet-name>
          <url-pattern>/SecureStoreServer</url-pattern>
  </servlet-mapping>

  <!-- reference on a remote bean without ejb-link-->
  <ejb-ref>
    <ejb-ref-name>ejb/Op</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <home>org.objectweb.earsample.beans.secusb.OpHome</home>
    <remote>org.objectweb.earsample.beans.secusb.Op</remote>

  </ejb-ref>

  <!-- reference on a remote bean using ejb-link-->
  <ejb-ref>
    <ejb-ref-name>ejb/EjbLinkOp</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>

    <home>org.objectweb.earsample.beans.secusb.OpHome</home>
    <remote>org.objectweb.earsample.beans.secusb.Op</remote>
    <ejb-link>secusb.jar#Op</ejb-link>
  </ejb-ref>

  <!-- reference on a local bean -->
  <ejb-local-ref>
    <ejb-ref-name>ejb/OpLocal</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <local-home>org.objectweb.earsample.beans.secusb.OpLocalHome

    </local-home>
    <local>org.objectweb.earsample.beans.secusb.OpLocal</local>
    <ejb-link>secusb.jar#Op</ejb-link>
  </ejb-local-ref>

</web-app>
---

I have tried all the above reference methods but none of them worked.

Can anyone give me a hint about what I should do?

Regards,
Razvan




More information about the jbossws-users mailing list