You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Younsoo <sh...@tmax.co.kr> on 2002/05/02 07:35:42 UTC

A problem in Axis Beta2 when the EJB is called

  I implemented a webservice with EJB in the Axis beta1. There is a problem in Axis beta2.
When the EJB webservice is called, the axis returns a error message. My EJB webservice
has 4 operations ( deposit, withdraw, getBalance, and getFormattedBalance )
Here is the error message :

AXIS error
Sorry, something seems to have gone wrong... here are the details:
No such operation 'getBalance'



  I read the Axis beta2 source code and found the reason why the error occurred. The error position
is RPCProvider.java , "processMessage" method.

                .    .    .    .    .
                .    .    .    .    .
                .    .    .    .    .
// This may have changed, so get it again...
// FIXME (there should be a cleaner way to do this)
operation = msgContext.getOperation();

if (operation == null) {
    QName qname = new QName(body.getNamespaceURI(),
                           body.getName());
    operation = serviceDesc.getOperationByElementQName(qname);
}

if (operation == null) {
   throw new AxisFault(JavaUtils.getMessage("noSuchOperation",
                                            methodName));  <<<== Error occurs in this place.
}

// Create the array we'll use to hold the actual parameter
// values.  We know how big to make it from the metadata.
Object[]     argValues  =  new Object [operation.getNumParams()];
                .    .    .    .    .
                .    .    .    .    .
                .    .    .    .    .

  I think that "server-config.wsdd" file is parsed in WSDDDeployment's constructor, and <service> element's
contents are parsed into WSDDService class.

public WSDDDeployment(Element e)
    throws WSDDException
{
    super(e);

    Element [] elements = getChildElements(e, "handler");
    int i;
                .    .    .    .    .
                .    .    .    .    .
                .    .    .    .    .
    elements = getChildElements(e, "service");
    for (i = 0; i < elements.length; i++) {
        WSDDService service = new WSDDService(elements[i]);
        deployService(service);
    }
                .    .    .    .    .
                .    .    .    .    .
                .    .    .    .    .
}

  When WSDDService instance created, WSDDService constructor parses <service> element and calls validateDescriptors () method. A <service> element's subelement, <parameter name="className" value="xxx"/>'s value, java class is loaded.

public void validateDescriptors()
{
    String className = this.getParameter("className");
    if (className != null) {
        try {
            // Will this always be the right classloader?
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            Class cls = cl.loadClass(className); <<== <parameter name="className" value="xxx">'s xxx class is loaded.
            desc.setImplClass(cls);
            initTMR();
            String encStyle = (desc.getStyle() == ServiceDesc.STYLE_RPC) ?
                Constants.URI_CURRENT_SOAP_ENC : "";
            desc.setTypeMapping((TypeMapping)tmr.getTypeMapping(encStyle));
        } catch (Exception ex) {
        }
    }
                .    .    .    .    .
                .    .    .    .    .
                .    .    .    .    .
}

  As you can see above source, the loaded class, cls is set into ServiceDesc.( desc.setImplClass(cls); ) In setImplClass ()
method operations(xxx class's methods) are instantiated into OperationDesc class.

public void setImplClass(Class implClass) {
    if (this.implClass != null)
        throw new IllegalArgumentException(
                JavaUtils.getMessage("implAlreadySet"));

    this.implClass = implClass;
    if (Skeleton.class.isAssignableFrom(implClass)) {
        isSkeletonClass = true;
        loadSkeletonOperations(); <<== OperationDesc instances are set.
    }
}

  Here is my "server-config.wsdd" file's part . There is no <parameter name="className"> subelement in EJB <service>.
Therefore OperationDesc instances couldn't be created.
msgContext.getOperation() and serviceDesc.getOperationByElementQName(qname) in RPCProvider.java ,
"processMessage" method couldn't retrieve OperationDesc instance.
So AxisFault(JavaUtils.getMessage("noSuchOperation", methodName)) is thrown.

<!-- As you can see, this is a webservice using general java class -->
 <service name="Add" provider="java:RPC">
  <parameter name="allowedMethods" value="*"/>
  <parameter name="scope" value="Request"/>
  <parameter name="className" value="samples.TestWS.WebServiceTest"/>
 </service>
<!-- a webservice using EJB -->
 <service name="MyAccount" provider="java:EJB">
  <parameter name="allowedMethods" value="*"/>
  <parameter name="jndiURL" value="localhost"/>
  <parameter name="scope" value="request"/>
  <parameter name="beanJndiName" value="TestAccount"/>
  <parameter name="homeInterfaceName" value="testaccount.TestAccountHome"/>
 </service>

How can I make a webservice using EJB?