DronaBlog

Tuesday, July 3, 2018

How to handle NoSuchMethodException exception

Scenario : 
The exception - NoSuchMethodException occurs if the setter or the getter method does not present in classes created during the WSDL skeleton or the client generation.

public class ElectronicAddressRequest {
    protected List<ElectronicAddressSO> electronicAddress;

    public List<ElectronicAddressSO> getElectronicAddress() {
        if (electronicAddress == null) {
            electronicAddress = new ArrayList<ElectronicAddressSO>();
        }
        return this.electronicAddress;
    }


Here is what the ElectronicAddressSO class looks like below :

public class ElectronicAddressSO {

    protected String electronicAddress;
    protected String electronicAddressType;

    public String getElectronicAddress() {
        return electronicAddress;
    }

     public void setElectronicAddress(String value) {
        this.electronicAddress = value;
    }

     public String getElectronicAddressType() {
        return electronicAddressType;
    }

     public void setElectronicAddressType(String value) {
        this.electronicAddressType = value;
    }

}

In the above code, the setter method is not created for the ElectronicAddressRequest if you use the wsdl2j tool to create the skeleton.

Error  :

When you try to run the application you will get the error below.

weblogic.wsee.jaxws.framework.policy.advertisementimpl.AdvertisementHelperImpl registerExtension
WARNING: Registering oracle.j2ee.ws.wsdl.extensions.addressing.AddressingExtensionRegistry extension failed; java.lang.NoSuchMethodException: oracle.j2ee.ws.wsdl.extensions.addressing.AddressingExtensionRegistry.registerSerializersAndTypes(com.ibm.wsdl.extensions.PopulatedExtensionRegistry)
Mar 11, 2015 12:22:12 PM weblogic.wsee.jaxws.spi.WLSServiceDelegate addWsdlDefinitionFeature
SEVERE: Failed to create WsdlDefinitionFeature for wsdl location: http://rmv-eap-spr-d11.ddc.dot.state.ma.us:57453/MARMV_MainFrame_Provider/LicenseUpdateService?wsdl, error: com.sun.xml.ws.wsdl.parser.InaccessibleWSDLException, message: 2 counts of InaccessibleWSDLException.


Solution :
In order to handle this error, add the method below in the ElectronicAddressRequest class :


public void setElectronicAddress(ElectronicAddressSO oElectronicAddressSO) {
        if (null != electronicAddress) {
            electronicAddress.add(oElectronicAddressSO);
        } else {
            List<ElectronicAddressSO> listContactInformation = new ArrayList<ElectronicAddressSO>();
            listContactInformation.add(oElectronicAddressSO);
            this.electronicAddress = listContactInformation;
        }
    }

2 comments:

  1. I use the jdk tool wsimport generate webService client code, and when I run the first line " MyService server = new MyService();" I had the same problem! But I do not understand what are ElectronicAddressRequest class and ElectronicAddressSO class mean...

    ReplyDelete
    Replies
    1. These are classes generated by wsimport tool as per custom definition

      Delete

Please do not enter any spam link in the comment box.

What is ROWID_OBJECT and ORIG_ROWID_OBJECT in Informatica MDM and what is significance?

 In Informatica Master Data Management (MDM), ROWID_OBJECT and ORIG_ROWID_OBJECT are critical identifiers within the MDM data model, parti...