axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bing...@idx.com
Subject Question about java.lang.InstantiationException.
Date Wed, 12 May 2004 16:13:53 GMT
Hi,

I defined an interface: com.idx.lw.webservices.inbox.InboxRetrievalService 
like the following:

public interface InboxRetrievalService {
    public String getInboxList(CISContext cisContext, InboxRetrievalBean 
inboxRetrieval) throws CISException;
}

where class CISException extends RemoteException implements Serializable;

I then created a class: 
com.idx.lw.webservices.inbox.InboxRetrievalServiceJP like the following:

public class InboxRetrievalServiceJP implements InboxRetrievalService {
    public InboxRetrievalServiceJP() throws CISException {
    ......
    }

    public String getInboxList(CISContext cisContext, InboxRetrievalBean 
inboxRetrieval) throws CISException {
    ...... 
    }
}

I used Ant to generate the WSDL file:

<target name="generate-inboxRetrieval-wsdl" 
depends="compile-inboxRetrieval" unless="inboxRetrieval.wsdl.uptodate">
    <delete file="${axis-gen}/${inboxRetrieval-wsdl-file}"/>
    <java classname="org.apache.axis.wsdl.Java2WSDL" 
classpath="${all-jars}" fork="on">
        <arg value="-o${axis-gen}/${inboxRetrieval-wsdl-file}"/>
        <arg 
value="-l${axis-host}/cis-inbox/services/InboxRetrievalService"/>
        <arg 
value="-n${axis-host}/cis-inbox/services/InboxRetrievalService"/>
        <arg value="-PInboxRetrievalServiceJP"/>
        <arg value="-SInboxRetrievalServer"/>
        <arg value="com.idx.lw.webservices.inbox.InboxRetrievalService"/>
    </java>
</target>

then I generated the stub classes from WSDL:

<target name="generate-inboxRetrieval-stubs" 
depends="generate-inboxRetrieval-wsdl">
    <java classname="org.apache.axis.wsdl.WSDL2Java" 
classpath="${all-jars}" fork="on">
        <arg value="-v"/>
        <arg value="-o${axis-gen}/src"/>
        <arg value="-pcom.idx.sage.wsstubs"/>
        <arg value="-t"/>
        <arg value="${axis-gen}/${inboxRetrieval-wsdl-file}"/>
    </java>
</target>

I then created an unit test as following:

public class InboxRetrievalWebServiceTest extends TestCase {
    ......
    public InboxRetrievalWebServiceTest(java.lang.String testName) {
        super(testName);

        try {
            ......
            inboxRetrieval = new 
com.idx.sage.wsstubs.InboxRetrievalBean();
            inboxRetrievalService = new 
InboxRetrievalServerLocator().getInboxRetrievalService();
            ......
        }
        catch (javax.xml.rpc.ServiceException jre) {
            if (jre.getLinkedCause() != null)
                jre.getLinkedCause().printStackTrace();
            throw new junit.framework.AssertionFailedError("JAX-RPC 
ServiceException caught: " + jre);
        }
        catch (CISException e1) {
            throw new junit.framework.AssertionFailedError("CISException 
Exception caught: " + e1);
        }
        catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void testGetInboxList() {
        try {
            ......
            inboxRetrievalService.getInboxList(cisContext, 
inboxRetrieval);
            ......
        }
        catch (CISException e) {
            e.printStackTrace();
        }
        catch (IOException e) {
            e.printStackTrace();
        }
    }
}

When I run my unit test, I got the following error:

AxisFault
 faultCode: 
{http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode: 
 faultString: java.lang.InstantiationException: 
com.idx.lw.webservices.inbox.InboxRetrievalService
 faultActor: null
 faultNode: null
 faultDetail: 
        stackTrace: java.lang.InstantiationException: 
com.idx.lw.webservices.inbox.InboxRetrievalService

This seems to me that the Axis tried to create an object based on the 
interface InboxRetrievalService, not based on the actual implementation 
InboxRetrievalServiceJP.

Could you please tell me what I am doing wrong and how to fix it? Or we 
just can't use an interface for the web service directly.

BTW, if I used a concrete class directly to generate WSDL, it works just 
fine.

Regards!

Bing

----------------------------------------------------
NOTICE OF CONFIDENTIALITY
----------------------------------------------------
The information in this email, including attachments, may be confidential and/or privileged
and may contain confidential health information.  This email is intended to be reviewed only
by the individual or organization named as addressee.  If you have received this email in
error please notify IDX immediately - by return message to the sender or to security@idx.com
- and destroy all copies of this message and any attachments.   Please note that any views
or opinions presented in this email are solely those of the author and do not necessarily
represent those of IDX.  Confidential health information is protected by state and federal
law, including, but not limited to, the Health Insurance Portability and Accountability Act
of 1996 and related regulations. 


Mime
View raw message