axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Måns Tånneryd <m...@tanneryd.com>
Subject RE: About java.lang.InstantiationException.
Date Mon, 24 May 2004 18:44:27 GMT
The default behaviour of axis when running wsdl2java with serverside="yes"
(-s or --server-side) is to generate an implementation template for you.
This template is registered in the generated deploy.wsdd file, in your case
it would be
<parameter name="className"
value="com.idx.sage.wsstubs.InboxRetrievalServiceSoapBindingImpl"/>

unless you selected skeleton deployment. If you did, the skeleton class
would be in the deploy.wsdd and the generated implementation template would
be instantiated in the skeleton. What all this comes down to is that your
implementation class must implement the interface generated by wsdl2java
(com.idx.sage.wsstubs.InboxRetrievalServiceJP) and the classname of your
implementation must be in the deploy.wsdd file. To accomplish this you
could:

1. Put your implementation in the implementation template created for you by
axis.

2. Create your own implementation class, make it implement
com.idx.sage.wsstubs.InboxRetrievalServiceJP and modify the deploy.wsdd file
to reflect your choice of classname.

3. Use skeleton deployment and patch the skeleton class to instantiate your
implementation (which is still required to implement
com.idx.sage.wsstubs.InboxRetrievalServiceJP ).

4. Write your implementation in any class of your choice and use the
wonderful new feature ( self glorification here!! :-) ) of wsdl2java
available in 1.2 as of may 11 ( option -c or --implementationClassName ) .
When using this option you need to be careful when selecting your
implementation classname so that the name of the generated interface does
not equal the name of your implementation. (Your class still needs,
formally, to implement the generated interface but since java does not
enforce you to use the implements syntax you really don't have to have that
statement in your implementation class. Since the generated interface is
generated from information in your implementation to begin with the method
signatures will match anyway, which is all that matters.) Check out the unit
test ws-axis/java/test/wsdl/webref for an example.

Not beeing all to familiar with the architectural truths of axis I hope I
haven't lied too much in this posting and hopefully it can be of some help
to you in your quest for truth, understanding and everlasting happiness :-).

/Måns



  -----Original Message-----
  From: Bing_Wu@idx.com [mailto:Bing_Wu@idx.com]
  Sent: den 24 maj 2004 18:34
  To: Måns Tånneryd
  Cc: axis-dev@ws.apache.org
  Subject: RE: About java.lang.InstantiationException.



  Hi, Måns,

  I have some entry in the WSDD file like the following:

   <service name="InboxRetrievalService" provider="java:RPC">
    <parameter name="allowedMethods" value="*"/>
    <parameter name="className"
value="com.idx.lw.inbox.InboxRetrievalService"/>
    <beanMapping
languageSpecificType="java:com.idx.lw.webservices.util.CISContext"
qname="ns1:CISContext" xmlns:ns1="http://util.webservices.lw.idx.com"/>
    <beanMapping
languageSpecificType="java:com.idx.lw.inbox.InboxRetrievalBean"
qname="ns5:InboxRetrievalBean"
xmlns:ns5="http://inbox.webservices.lw.idx.com"/>
   </service>

  It works for the concrete class, i.e., if InboxRetrievalService is a
concrete class.

  I see your point and what I missed here.

  So I am wondering what fix I should make now.


  Thanks a lot.

  Bing



       Måns Tånneryd <mans@tanneryd.com>
        05/23/2004 01:58 PM


                To:        <axis-dev@ws.apache.org>
                cc:        <Bing_Wu@idx.com>
                Subject:        RE: About java.lang.InstantiationException.



  Hello again Bing!

  I see no server side generation in your wsdl2java... How did you deploy
your service implementation?

  /Måns
  -----Original Message-----
  From: Bing_Wu@idx.com [mailto:Bing_Wu@idx.com]
  Sent: den 21 maj 2004 20:47
  To: axis-dev@ws.apache.org
  Subject: RE: About java.lang.InstantiationException.


  Thanks a lot for your response, Mans.

  I submitted an email to the group twice before with very specific
information. I guess the email was too long to get any reply. -:)

  Here is my old email message:

  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 the following 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 used the following to generate the stub classes:

  <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.

  BTW, if I used a concrete class, it works just fine.

  Thanks!

  Bing


       Mans Tanneryd <mans@tanneryd.com>
        05/21/2004 11:30 AM
        Please respond to axis-dev

               To:        <axis-dev@ws.apache.org>
               cc:
               Subject:        RE: About java.lang.InstantiationException.




  Hi Bing!

  Could you be a little more specific? What were the names of your interface
and your implementation classes? What options did you use when running
java2wsdl and wsdl2java? How did you "use" the stub classes?

  /Måns
  -----Original Message-----
  From: Bing_Wu@idx.com [mailto:Bing_Wu@idx.com]
  Sent: den 21 maj 2004 18:34
  To: axis-user@ws.apache.org; axis-dev@ws.apache.org
  Subject: About java.lang.InstantiationException.


  Hi,

  I created a Java interface and several Java classes which implement the
interface. I used Java2WSDL to generate the WSDL from the interface. Then I
used WSDL2Java to generate the stub classes.

  When I used the stub classes, 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, not based on one of my implementation classes.

  I am wondering what I am doing wrong and how to fix it here? Or we just
can't use an interface for the web service directly, i.e., dynamic
invocation not supported.

  Thanks!

  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