Title: RE: Exposing EJBs as web services...

I played with the EJB as web service quite a bit with Axis. Here is the result of my findings:

1) With Axis you can configure which methods are exposed when you deploy the web service. In the EJB case, what you expose to the web service client is the remote interface (Axis server act as the EJB client). You can decide to expose the methods inherited from EJBObject by the remote interface if you want to.

2) Axis session (when service is declared with a session scope in the wsdd) are maintained by caching the web service implementation object using the HTTPSession object. For the EJB, it means that the EJB client object (Axis server act as the EJBClient) is the object which is cached. But the current EJBProvider has no support for any kind of EJB error recovery. If the EJB session is timing out, your web service in the current web service session is broken. You have no way form the web service client to ask Axis to "refresh" the cached service implementation object. I also tried with stateful EJB. If a runtime exception in the stateful bean implementation is occurring, EJB spec states that stateful bean is discarded. But Axis EJB provider does not handle that at all (it does not try to detect runtime exception and then discarded the cached object).

You can look at a the code of the current EJBProvider for Axis (xml-axis-beta2/java/src/org/apache/axis/providers/java/EJBProvider.java). It is pretty straightforward to understand. But for production application using EJBs as web service implementation with Axis, this provider needs to be improved.

Thomas


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 14, 2002 6:12 AM
To: [EMAIL PROTECTED]
Subject: RE: Exposing EJBs as web services...



Exposing an EJB as a web service sounds very interesting.

Does anyone know how session state is maintained?  If the EJB's methods are
actually exposed to Axis clients, how is session timeout state handled?
When a session is completed (say it's a stateful session bean), how does
Axis know that the session and the bean need to be destroyed?

-Mark

--------------------------------------------------
There is no spoon.
--------------------------------------------------


                                                                                                                
                    "Hurst, Cyrus"                                                                              
                    <Cyrus_Hurst@tvra       To:     "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>     
                    tings.com>              cc:                                                                 
                                            Subject:     RE: Exposing EJBs as web services...                   
                    06/13/2002 06:02                                                                            
                    PM                                                                                          
                    Please respond to                                                                           
                    axis-user                                                                                   
                                                                                                                
                                                                                                                




Hello,

           To solve the NoClassDefFoundErrors I had to copy the Remote and
Home
interfaces for my EJB and any classes that the                     Remote
interface has
dependencies on into the axis/WEB-INF/classes/ directory . Once I got thru
that I kept
      getting unknown operation(on both client and server console)  on the
exposed method of the EJB . So I
      wrote and deployed  a class
       as a web-service(using provider="java:RPC")  that basically acts as
a
delegate to the EJB . I used the
       same client code to test it and it ran fine . I undeployed that
web-service and re-deployed the other
     web-service using provider ="java:EJB"  and I still get the unkown
operation on the method of the EJB.
     My deployment descriptors are as follows:

For RPC -
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
           xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
           xmlns:xsi="http:/www.w3.org/2000/10/XMLSchema-instance">
           <service name="AssociateInfo" provider="java:RPC">
                     <parameter name="className" value="TestCprEJBClient"
/>
                     <parameter name="allowedMethods"
value="getAssociateIDFromDMZID" />
           </service>
</deployment>

For EJB -
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
            xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
            xmlns:xsi="http:/www.w3.org/2000/10/XMLSchema-instance">
    <service name="AssociateInfo" provider="java:EJB">
        <parameter name="beanJndiName" value="jndi/ejb/AssociateSessionEJB"
/>
        <parameter name="homeInterfaceName"
value="com.nielsenmedia.lrs.cpr.associate.AssociateSessionHome" />
        <parameter name="allowedMethods" value="getAssociateIDFromDMZID"/>
        <parameter name="jndiURL" value="t3://d2loc:9023" />
        <parameter name="jndiContextClass"
value="weblogic.jndi.WLInitialContextFactory" />
    </service>
</deployment>

As you can see I'm using the same operation name for both styles . In the
delegate class(TestCprEJBClient) I use the same parameters in the EJB wsdd
to do  jndi lookup, create Home interface, etc .... Am I missing something?


Thanks,
-Cyrus




-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 12, 2002 6:01 PM
To: [EMAIL PROTECTED]
Subject: RE: Exposing EJBs as web services...


Exception messages can just be serialized and passed form one client to
another.
May be trying to write an independent EJB client and making it work first
can be a good idea. It will remove the Axis piece. This EJB client should
be
able to work only with the Home and remote interface in the classpath. If
you are still getting some exceptions on the weblogic console, it means
that
your bean is not correctly deployed.
-----Original Message-----
From: Hurst, Cyrus [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 12, 2002 5:41 PM
To: '[EMAIL PROTECTED]'
Subject: RE: Exposing EJBs as web services...


  Both ..On the client console I get :
      weblogic.rmi.extensions.RemoteRuntimeException - with nested
exception:
    [java.lang.NoClassDefFoundError:
com/nielsenmedia/lrs/cpr/common/CPREnterpriseException]
        at
org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:13


4)
        at
org.apache.axis.encoding.DeserializationContextImpl.endElement(Deserializati


onCo
        at
org.apache.xerces.parsers.SAXParser.endElement(SAXParser.java:1403)
        at
org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLValidator


.jav
        at
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XM


LDoc
        at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.


java
        at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1081)

        at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
        at
org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationCon


text
        at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:455)
        at org.apache.axis.Message.getSOAPEnvelope(Message.java:321)
        at org.apache.axis.client.Call.invoke(Call.java:1954)
        at org.apache.axis.client.Call.invoke(Call.java:1707)
        at org.apache.axis.client.Call.invoke(Call.java:1635)
        at org.apache.axis.client.Call.invoke(Call.java:1184)
        at TestCprRpcClient.main(TestCprRpcClient.java:36)
[INFO] Call - -Mapping Exception to AxisFault
<weblogic.rmi.extensions.RemoteRuntimeExcepti
on:
[java.lang.NoClassDefFoundError:
com/nielsenmedia/lrs/cpr/common/CPREnterpriseException]>
weblogic.rmi.extensions.RemoteRuntimeException - with nested exception:
[java.lang.NoClassDefFoundError:
com/nielsenmedia/lrs/cpr/common/CPREnterpriseException]


 On the server(running Weblogic 6.1)  console I get :

   weblogic.rmi.extensions.RemoteRuntimeException - with nested exception:
[java.lang.NoClassDefFoundError:
com/nielsenmedia/lrs/cpr/common/CPREnterpriseException]
        at weblogic.rmi.internal.ProxyStub.invoke(ProxyStub.java:60)
        at $Proxy56.lookup(Unknown Source)
        at
weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:323)
        at javax.naming.InitialContext.lookup(InitialContext.java:350)
        at
org.apache.axis.providers.java.EJBProvider.getEJBHome(EJBProvider.java:300)

        at
org.apache.axis.providers.java.EJBProvider.getNewServiceObject(EJBProvider.j


ava:109)
        at
org.apache.axis.providers.java.JavaProvider.getServiceObject(JavaProvider.ja


va:126)
        at
org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:234)
        at
org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:


71)
        at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:154)
        at org.apache.axis.SimpleChain.invoke(SimpleChain.java:121)
        at org.apache.axis.server.AxisServer.invoke(AxisServer.java:288)
        at
org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:576)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java


:265)
        at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java


:200)
        at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo


ntext.java:2456)
        at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java


:2039)
        at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
        at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
  Thanks again ,
-Cyrus

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 12, 2002 5:35 PM
To: [EMAIL PROTECTED]
Subject: RE: Exposing EJBs as web services...


From Axis or from the EJB container? If both output are logged at the same
place you might not be able to make the difference.
Thomas
-----Original Message-----
From: Hurst, Cyrus [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 12, 2002 5:24 PM
To: '[EMAIL PROTECTED]'
Subject: RE: Exposing EJBs as web services...


 Thats what I thought but when I only copied Remote and Home interface I
kept getting NoClassDefFoundError on  helper classes,
 user defined exceptions, etc ...
-Cyrus
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 12, 2002 5:16 PM
To: [EMAIL PROTECTED]
Subject: RE: Exposing EJBs as web services...


In the case of a web service implemented using EJBs, the Axis server will
behave as an EJB client. Only the EJB client classes are required for the
web service to work (meaning the Remote and Home interface).
-----Original Message-----
From: Hurst, Cyrus [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 12, 2002 4:59 PM
To: [EMAIL PROTECTED]
Subject: Exposing EJBs as web services...


 Hello,
    I am trying to expose an existing stateless session bean as a web
service .  I
 basically followed the example(creating the client and wsdd)  given in the

Wrox Axis(pg 255) .  The book
 says to only copy the Remote and Home interface for the EJB into
axis\WEB-INF\classes\ .
 Is this true or do I need to copy all classes the EJB has dependencies on?



 Thanks,
-Cyrus



Reply via email to