javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service

17,012

I've created java classes from wsdl with org.apache.cxf.tools.wsdlto.WSDLToJava. While creating an instance of the service, I had exact same exception at runtime:

org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service

Previous code:

URL wsdlURL = new URL("http://example.com/my_service.asmx");
MyWS mailWS = new MyWS(wsdlURL); // Exception is thrown here

Solution was weird. I've just added ?wsdl next to service address:

URL wsdlURL = new URL("http://example.com/my_service.asmx?wsdl");
MyWS mailWS = new MyWS(wsdlURL);
Share:
17,012
Venu Goli
Author by

Venu Goli

Updated on June 05, 2022

Comments

  • Venu Goli
    Venu Goli almost 2 years

    I need desperate help to figure out the reason for the failure in creating the service.

    My application is developed using Eclipse tool and it runs well there. It uses cxf-3.1.7 library collection. A console program that initializes the process to create the service to the API. Everything looks good and fine.

    I am trying to deploy the code in another machine. I installed the necessary jre and other files. I created a batch file with all the necessary path and classpath settings. I need to run the batch file on a daily base, so that it pulls the data regularly. But, when I run the batch file, it fails to create the service with the above error message.

    Can someone suggest me the reason if I am going wrong somewhere or any solution to get the service created. This is the batch file I have:

    set path=C:\Program Files\Java\jdk1.8.0_91\bin 
    set classpath=cxf-core-3.1.7.jar;cxf-rt-frontend-simple-3.1.7.ja‌​r;sqljdbc42.jar;cxf-‌​rt-frontend-jaxws-3.‌​1.7.jar;wsdl4j-1.6.3‌​.jar;cxf-rt-wsdl-3.1‌​.7.jar;xmlschema-cor‌​e-2.2.1.jar;lib*.jar‌​;. 
    java com.strongmail.services.v2.MailingService_MailingServicePort‌​_Client 
    pause
    

    Thanks in advance.

    • Michael Shopsin
      Michael Shopsin over 6 years
      Could we see your batch file?
    • Venu Goli
      Venu Goli over 6 years
      This is the batch file I have. set path=C:\Program Files\Java\jdk1.8.0_91\bin set classpath=cxf-core-3.1.7.jar;cxf-rt-frontend-simple-3.1.7.ja‌​r;sqljdbc42.jar;cxf-‌​rt-frontend-jaxws-3.‌​1.7.jar;wsdl4j-1.6.3‌​.jar;cxf-rt-wsdl-3.1‌​.7.jar;xmlschema-cor‌​e-2.2.1.jar;lib*.jar‌​;. java com.strongmail.services.v2.MailingService_MailingServicePort‌​_Client pause
  • SuRa
    SuRa almost 5 years
    Thanks. Faced same issue and this help me.
  • user3094331
    user3094331 over 3 years
    Even I have added ?WSDL next to my service still I am getting the above error ? Can you please let me in which scenario we can get the above error