title: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'marshaller' defined in class
body: <p>I’m trying develop SOAP web service client using spring-ws-2.2.0 &amp; spring-boot-1.1.8 in a standalone app, but I get this error:</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with 
  
  name 'marshaller' defined in class pcc_load.ApexConfiguration: Invocation of init method
   failed; nested exception is org.springframework.oxm.UncategorizedMappingException:
   Unknown JAXB exception; nested exception is javax.xml.bind.JAXBException: Provider com.sun.xml.internal.bind.v2.ContextFactory could not be instantiated: 
  
  javax.xml.bind.JAXBException: "pcc_load/src/com/company/dept/apex/stubs/ObjectFactory.java" doesnt contain ObjectFactory.class or jaxb.index
   - with linked exception:
  
  [javax.xml.bind.JAXBException: "pcc_load/src/com/company/department/apex/stubs/ObjectFactory.java" doesnt contain ObjectFactory.class or jaxb.index]
  </code></pre>
  
  <p>I created all the stubs using ant &amp; the wsdl without any error, here is the wsdl:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
      xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema"
      xmlns:s0="PCCDATA_APEX_WS" xmlns:tns1="dsws.businessobjects.com"
      targetNamespace="PCCDATA_APEX_WS" xmlns="http://schemas.xmlsoap.org/wsdl/"
      name="BIServices"&gt;
      &lt;types&gt;
          &lt;s:schema elementFormDefault="qualified" targetNamespace="PCCDATA_APEX_WS"&gt;
              &lt;s:simpleType name="Operator"&gt;
                  &lt;s:restriction base="s:string"&gt;
                      &lt;s:enumeration value="EQUAL" /&gt;
                      &lt;s:enumeration value="GREATER" /&gt;
                      &lt;s:enumeration value="GREATER_OR_EQUAL" /&gt;
                      &lt;s:enumeration value="LESS" /&gt;
                      &lt;s:enumeration value="LESS_OR_EQUAL" /&gt;
                      &lt;s:enumeration value="NOT_EQUAL" /&gt;
                      &lt;s:enumeration value="INLIST" /&gt;
                      &lt;s:enumeration value="NOT_INLIST" /&gt;
                  &lt;/s:restriction&gt;
              &lt;/s:simpleType&gt;
              &lt;s:complexType name="FilterCondition"&gt;
                  &lt;s:sequence&gt;
                      &lt;s:element name="value" type="s:string" /&gt;
                      &lt;s:element name="operator" type="s0:Operator" /&gt;
                  &lt;/s:sequence&gt;
              &lt;/s:complexType&gt;
              &lt;s:complexType name="LovValueIndex"&gt;
                  &lt;s:sequence&gt;
                      &lt;s:element name="valueofPrompt" type="s:string" /&gt;
                      &lt;s:element name="index" type="s:string" /&gt;
                  &lt;/s:sequence&gt;
              &lt;/s:complexType&gt;
              &lt;s:complexType name="DrillFilter"&gt;
                  &lt;s:sequence&gt;
                      &lt;s:element name="dimension" type="s:string" /&gt;
                      &lt;s:element name="value" type="s:string" /&gt;
                      &lt;s:element name="operator" type="s0:Operator" /&gt;
                  &lt;/s:sequence&gt;
              &lt;/s:complexType&gt;
              &lt;s:element name="GetReportBlock_PCCDATA_APEX_WS"&gt;
                  &lt;s:complexType&gt;
                      &lt;s:sequence&gt;
                          &lt;s:element name="login" type="s:string" minOccurs="0"
                              nillable="true" /&gt;
                          &lt;s:element name="password" type="s:string" minOccurs="0"
                              nillable="true" /&gt;
                          &lt;s:element name="_Business_Segment__Multiple__Optional_"
                              type="s0:LovValueIndex" minOccurs="0" maxOccurs="unbounded"
                              nillable="true" /&gt;
                          &lt;s:element name="resetState" type="s:boolean" minOccurs="0"
                              nillable="true" /&gt;
                          &lt;s:element name="refresh" type="s:boolean" minOccurs="0"
                              nillable="true" /&gt;
                          &lt;s:element name="getFromLatestDocumentInstance" type="s:boolean"
                              minOccurs="0" nillable="true" /&gt;
                          &lt;s:element name="getFromUserInstance" type="s:boolean"
                              minOccurs="0" nillable="true" /&gt;
                          &lt;s:element name="turnOutputToVTable" type="s:boolean"
                              minOccurs="0" nillable="true" /&gt;
                          &lt;s:element name="closeDocument" type="s:boolean"
                              minOccurs="0" nillable="true" /&gt;
                          &lt;s:element name="startRow" type="s:int" minOccurs="0"
                              nillable="true" /&gt;
                          &lt;s:element name="endRow" type="s:int" minOccurs="0"
                              nillable="true" /&gt;
                      &lt;/s:sequence&gt;
                  &lt;/s:complexType&gt;
              &lt;/s:element&gt;
              &lt;s:simpleType name="DrillOperation"&gt;
                  &lt;s:restriction base="s:string"&gt;
                      &lt;s:enumeration value="UP" /&gt;
                      &lt;s:enumeration value="DOWN" /&gt;
                  &lt;/s:restriction&gt;
              &lt;/s:simpleType&gt;
              &lt;s:complexType name="DrillPath"&gt;
                  &lt;s:sequence&gt;
                      &lt;s:element name="from" type="s:string" /&gt;
                      &lt;s:element name="value" type="s:string" /&gt;
                      &lt;s:element name="drillOperation" type="s0:DrillOperation" /&gt;
                  &lt;/s:sequence&gt;
              &lt;/s:complexType&gt;
              &lt;s:element name="Drill_PCCDATA_APEX_WS"&gt;
                  &lt;s:complexType&gt;
                      &lt;s:sequence&gt;
                          &lt;s:element name="login" type="s:string" minOccurs="0"
                              nillable="true" /&gt;
                          &lt;s:element name="password" type="s:string" minOccurs="0"
                              nillable="true" /&gt;
                          &lt;s:element name="drillPath" type="s0:DrillPath"
                              minOccurs="0" maxOccurs="unbounded" nillable="true" /&gt;
                          &lt;s:element name="filter" type="s0:DrillFilter"
                              minOccurs="0" maxOccurs="unbounded" nillable="true" /&gt;
                          &lt;s:element name="_Business_Segment__Multiple__Optional_"
                              type="s0:LovValueIndex" minOccurs="0" maxOccurs="unbounded"
                              nillable="true" /&gt;
                          &lt;s:element name="resetState" type="s:boolean" minOccurs="0"
                              nillable="true" /&gt;
                          &lt;s:element name="refresh" type="s:boolean" minOccurs="0"
                              nillable="true" /&gt;
                          &lt;s:element name="getFromLatestDocumentInstance" type="s:boolean"
                              minOccurs="0" nillable="true" /&gt;
                          &lt;s:element name="getFromUserInstance" type="s:boolean"
                              minOccurs="0" nillable="true" /&gt;
                          &lt;s:element name="turnOutputToVTable" type="s:boolean"
                              minOccurs="0" nillable="true" /&gt;
                          &lt;s:element name="closeDocument" type="s:boolean"
                              minOccurs="0" nillable="true" /&gt;
                          &lt;s:element name="startRow" type="s:int" minOccurs="0"
                              nillable="true" /&gt;
                          &lt;s:element name="endRow" type="s:int" minOccurs="0"
                              nillable="true" /&gt;
                      &lt;/s:sequence&gt;
                  &lt;/s:complexType&gt;
              &lt;/s:element&gt;
              &lt;s:complexType name="TRow"&gt;
                  &lt;s:sequence&gt;
                      &lt;s:element name="cell" type="s:anyType" maxOccurs="unbounded"
                          nillable="true" /&gt;
                  &lt;/s:sequence&gt;
              &lt;/s:complexType&gt;
              &lt;s:complexType name="TTable"&gt;
                  &lt;s:sequence&gt;
                      &lt;s:element name="row" maxOccurs="unbounded" type="s0:TRow" /&gt;
                  &lt;/s:sequence&gt;
              &lt;/s:complexType&gt;
              &lt;s:complexType name="THeader"&gt;
                  &lt;s:sequence&gt;
                      &lt;s:element name="row" maxOccurs="unbounded" type="s0:TRow" /&gt;
                  &lt;/s:sequence&gt;
              &lt;/s:complexType&gt;
              &lt;s:complexType name="TFooter"&gt;
                  &lt;s:sequence&gt;
                      &lt;s:element name="row" maxOccurs="unbounded" type="s0:TRow" /&gt;
                  &lt;/s:sequence&gt;
              &lt;/s:complexType&gt;
              &lt;s:element name="GetReportBlock_PCCDATA_APEX_WSResponse"&gt;
                  &lt;s:complexType&gt;
                      &lt;s:sequence&gt;
                          &lt;s:element name="table" type="s0:TTable" /&gt;
                          &lt;s:element name="headers" type="s0:THeader" /&gt;
                          &lt;s:element name="footers" type="s0:TFooter" /&gt;
                          &lt;s:element name="user" type="s:string" /&gt;
                          &lt;s:element name="documentation" type="s:string" /&gt;
                          &lt;s:element name="documentname" type="s:string" /&gt;
                          &lt;s:element name="lastrefreshdate" type="s:dateTime" /&gt;
                          &lt;s:element name="creationdate" type="s:dateTime" /&gt;
                          &lt;s:element name="creator" type="s:string" /&gt;
                          &lt;s:element name="isScheduled" type="s:boolean" /&gt;
                          &lt;s:element name="scheduleStartTime" type="s:dateTime" /&gt;
                          &lt;s:element name="scheduleEndTime" type="s:dateTime" /&gt;
                          &lt;s:element name="tableType" type="s:string" /&gt;
                          &lt;s:element name="nbColumns" type="s:int" /&gt;
                          &lt;s:element name="nbLines" type="s:int" /&gt;
                          &lt;s:element name="message" type="s:string" /&gt;
                      &lt;/s:sequence&gt;
                  &lt;/s:complexType&gt;
              &lt;/s:element&gt;
              &lt;s:element name="Drill_PCCDATA_APEX_WSResponse"&gt;
                  &lt;s:complexType&gt;
                      &lt;s:sequence&gt;
                          &lt;s:element name="table" type="s0:TTable" /&gt;
                          &lt;s:element name="headers" type="s0:THeader" /&gt;
                          &lt;s:element name="footers" type="s0:TFooter" /&gt;
                          &lt;s:element name="user" type="s:string" /&gt;
                          &lt;s:element name="documentation" type="s:string" /&gt;
                          &lt;s:element name="documentname" type="s:string" /&gt;
                          &lt;s:element name="lastrefreshdate" type="s:dateTime" /&gt;
                          &lt;s:element name="creationdate" type="s:dateTime" /&gt;
                          &lt;s:element name="creator" type="s:string" /&gt;
                          &lt;s:element name="isScheduled" type="s:boolean" /&gt;
                          &lt;s:element name="scheduleStartTime" type="s:dateTime" /&gt;
                          &lt;s:element name="scheduleEndTime" type="s:dateTime" /&gt;
                          &lt;s:element name="tableType" type="s:string" /&gt;
                          &lt;s:element name="nbColumns" type="s:int" /&gt;
                          &lt;s:element name="nbLines" type="s:int" /&gt;
                          &lt;s:element name="message" type="s:string" /&gt;
                      &lt;/s:sequence&gt;
                  &lt;/s:complexType&gt;
              &lt;/s:element&gt;
              &lt;s:element name="QaaWSHeader"&gt;
                  &lt;s:complexType&gt;
                      &lt;s:sequence&gt;
                          &lt;s:element name="sessionID" type="s:string" minOccurs="0"
                              maxOccurs="1" nillable="true" /&gt;
                          &lt;s:element name="serializedSession" type="s:string"
                              minOccurs="0" maxOccurs="1" nillable="true" /&gt;
                          &lt;s:element name="ClientType" type="s:string" minOccurs="0"
                              maxOccurs="1" nillable="true" /&gt;
                          &lt;s:element name="AuditingObjectID" type="s:string"
                              minOccurs="0" maxOccurs="1" nillable="true" /&gt;
                          &lt;s:element name="AuditingObjectName" type="s:string"
                              minOccurs="0" maxOccurs="1" nillable="true" /&gt;
                      &lt;/s:sequence&gt;
                  &lt;/s:complexType&gt;
              &lt;/s:element&gt;
          &lt;/s:schema&gt;
      &lt;/types&gt;
      &lt;message name="GetReportBlock_PCCDATA_APEX_WSSoapIn"&gt;
          &lt;part name="parameters" element="s0:GetReportBlock_PCCDATA_APEX_WS" /&gt;
          &lt;part name="request_header" element="s0:QaaWSHeader" /&gt;
      &lt;/message&gt;
      &lt;message name="GetReportBlock_PCCDATA_APEX_WSSoapOut"&gt;
          &lt;part name="parameters" element="s0:GetReportBlock_PCCDATA_APEX_WSResponse" /&gt;
      &lt;/message&gt;
      &lt;message name="Drill_PCCDATA_APEX_WSSoapIn"&gt;
          &lt;part name="parameters" element="s0:Drill_PCCDATA_APEX_WS" /&gt;
          &lt;part name="request_header" element="s0:QaaWSHeader" /&gt;
      &lt;/message&gt;
      &lt;message name="Drill_PCCDATA_APEX_WSSoapOut"&gt;
          &lt;part name="parameters" element="s0:Drill_PCCDATA_APEX_WSResponse" /&gt;
      &lt;/message&gt;
      &lt;portType name="BIServicesSoap"&gt;
          &lt;operation name="GetReportBlock_PCCDATA_APEX_WS"&gt;
              &lt;documentation&gt;&lt;/documentation&gt;
              &lt;input message="s0:GetReportBlock_PCCDATA_APEX_WSSoapIn" /&gt;
              &lt;output message="s0:GetReportBlock_PCCDATA_APEX_WSSoapOut" /&gt;
          &lt;/operation&gt;
          &lt;operation name="Drill_PCCDATA_APEX_WS"&gt;
              &lt;documentation&gt;&lt;/documentation&gt;
              &lt;input message="s0:Drill_PCCDATA_APEX_WSSoapIn" /&gt;
              &lt;output message="s0:Drill_PCCDATA_APEX_WSSoapOut" /&gt;
          &lt;/operation&gt;
      &lt;/portType&gt;
      &lt;binding name="BIServicesSoap" type="s0:BIServicesSoap"&gt;
          &lt;soap:binding transport="http://schemas.xmlsoap.org/soap/http"
              style="document" /&gt;
          &lt;operation name="GetReportBlock_PCCDATA_APEX_WS"&gt;
              &lt;documentation&gt;&lt;/documentation&gt;
              &lt;soap:operation soapAction="PCCDATA_APEX_WS/GetReportBlock_PCCDATA_APEX_WS"
                  style="document" /&gt;
              &lt;input&gt;
                  &lt;soap:header message="s0:GetReportBlock_PCCDATA_APEX_WSSoapIn"
                      part="request_header" use="literal"&gt;
                      &lt;soap:headerfault message="s0:GetReportBlock_PCCDATA_APEX_WSSoapIn"
                          part="request_header" use="literal" /&gt;
                  &lt;/soap:header&gt;
                  &lt;soap:body use="literal" parts="parameters" /&gt;
              &lt;/input&gt;
              &lt;output&gt;
                  &lt;soap:body use="literal" /&gt;
              &lt;/output&gt;
          &lt;/operation&gt;
          &lt;operation name="Drill_PCCDATA_APEX_WS"&gt;
              &lt;documentation&gt;&lt;/documentation&gt;
              &lt;soap:operation soapAction="PCCDATA_APEX_WS/Drill_PCCDATA_APEX_WS"
                  style="document" /&gt;
              &lt;input&gt;
                  &lt;soap:header message="s0:Drill_PCCDATA_APEX_WSSoapIn"
                      part="request_header" use="literal"&gt;
                      &lt;soap:headerfault message="s0:Drill_PCCDATA_APEX_WSSoapIn"
                          part="request_header" use="literal" /&gt;
                  &lt;/soap:header&gt;
                  &lt;soap:body use="literal" parts="parameters" /&gt;
              &lt;/input&gt;
              &lt;output&gt;
                  &lt;soap:body use="literal" /&gt;
              &lt;/output&gt;
          &lt;/operation&gt;
      &lt;/binding&gt;
      &lt;service name="PCCDATA_APEX_WS"&gt;
          &lt;documentation&gt;&lt;/documentation&gt;
          &lt;port name="BIServicesSoap" binding="s0:BIServicesSoap"&gt;
              &lt;soap:address
                  location="http://xyz.test.app.company.com:8080/dswsbobje/qaawsservices/queryasaservice/biws?cuid=AQyF0wiLGyhNgX41XOXwiEs&amp;amp;authType=secEnterprise&amp;amp;locale=en&amp;amp;timeout=60&amp;amp;ConvertAnyType=true" /&gt;
          &lt;/port&gt;
      &lt;/service&gt;
  &lt;/definitions&gt;
  </code></pre>
  
  <p><strong>I used this tutorial/guide from spring:</strong></p>
  
  <p><a href="https://spring.io/guides/gs/consuming-web-service/" rel="nofollow">https://spring.io/guides/gs/consuming-web-service/</a></p>
  
  <p><strong>Here is my main:</strong></p>
  
  <pre><code>import org.springframework.context.ApplicationContext;
  import org.springframework.boot.SpringApplication;
  
  public class main {
  
      public static void main (String [] args)
      {
  
  
      ApplicationContext ctx = SpringApplication.run(ApexConfiguration.class);
  
          apexClient newApexClient = ctx.getBean(apexClient.class);
  
          newApexClient.callDrillPCCDATAAPEXWS();
  
      }
  
  }
  </code></pre>
  
  <p><strong>Here is my Jaxb2Marshaller configuration class:</strong></p>
  
  <pre><code>import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.oxm.jaxb.Jaxb2Marshaller;
  @Configuration
  public class ApexConfiguration {
  
      @Bean
      public Jaxb2Marshaller marshaller() {
          Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
          /* I tried these values but getting the same error?
           *  1) "apex.wsdl" 
           *  or 
           *  2) "/apex.wsdl"
                  3) "com.company.dept.apex.stubs"
           *   or 
           *  4) fully qualified package that stubs are generated in "com.company.dept.apex.stubs.ObjectFactory"
           */
          marshaller.setContextPath("apex.wsdl");
          return marshaller;
      }
  
      @Bean
      public apexClient weatherClient(Jaxb2Marshaller marshaller) {
          apexClient client = new apexClient();
          client.setDefaultUri("http://xyz.test.app.company.com:8080");
          client.setMarshaller(marshaller);
          client.setUnmarshaller(marshaller);
          return client;
      }
  }
  </code></pre>
  
  <p><strong>Here is the actual client web service implementation &amp; request calls:</strong></p>
  
  <pre><code>import javax.xml.bind.JAXBElement;
  import org.springframework.ws.client.core.WebServiceTemplate;
  import org.springframework.ws.client.core.support.WebServiceGatewaySupport;
  import org.springframework.ws.soap.client.core.SoapActionCallback;
  import org.springframework.beans.factory.InitializingBean;
  import com.company.dept.apex.stubs.DrillPCCDATAAPEXWS;
  import com.company.dept.apex.stubs.DrillPCCDATAAPEXWSResponse;
  import com.company.dept.apex.stubs.GetReportBlockPCCDATAAPEXWS;
  import com.company.dept.apex.stubs.GetReportBlockPCCDATAAPEXWSResponse;
  import com.company.dept.apex.stubs.ObjectFactory;
  
  public class apexClient extends WebServiceGatewaySupport {
  
      private WebServiceTemplate webServiceTemplate;
  
      //ZBIJOB248/testme05 
      public String username="user1234";
      public String pass="pass1234";
      public DrillPCCDATAAPEXWSResponse callDrillPCCDATAAPEXWS()
      {
          setDefaultUri("http://xyz.test.app.company.com:8080/dswsbobje/qaawsservices/queryasaservice/biws?cuid=AQyF0wiLGyhNgX41XOXwiEs&amp;amp;authType=secEnterprise&amp;amp;locale=en&amp;amp;timeout=60&amp;amp;ConvertAnyType=true");
          DrillPCCDATAAPEXWS request = new DrillPCCDATAAPEXWS();
          ObjectFactory objectFactory = new ObjectFactory();
          JAXBElement&lt;String&gt; login = objectFactory.createDrillPCCDATAAPEXWSLogin(username);
          JAXBElement&lt;String&gt; password = objectFactory.createDrillPCCDATAAPEXWSPassword(pass);
          request.setLogin(login);
          request.setPassword(password);
          //
          DrillPCCDATAAPEXWSResponse response = 
                  (DrillPCCDATAAPEXWSResponse) getWebServiceTemplate().marshalSendAndReceive( 
                          request, new SoapActionCallback("http://xyz.test.app.company.com:8080/dswsbobje/qaawsservices/queryasaservice/biws?cuid=AQyF0wiLGyhNgX41XOXwiEs&amp;amp;authType=secEnterprise&amp;amp;locale=en&amp;amp;timeout=60&amp;amp;ConvertAnyType=true"));
  
          return response;
      }
  
  
      public GetReportBlockPCCDATAAPEXWSResponse callGetReportBlockPCCDATAAPEXWSResponse()
      {
          setDefaultUri("http://xyz.test.app.company.com:8080/dswsbobje/qaawsservices/queryasaservice/biws?cuid=AQyF0wiLGyhNgX41XOXwiEs&amp;amp;authType=secEnterprise&amp;amp;locale=en&amp;amp;timeout=60&amp;amp;ConvertAnyType=true");
          GetReportBlockPCCDATAAPEXWS request = new GetReportBlockPCCDATAAPEXWS();
          ObjectFactory objectFactory = new ObjectFactory();
          JAXBElement&lt;String&gt; login = objectFactory.createDrillPCCDATAAPEXWSLogin(username);
          JAXBElement&lt;String&gt; password = objectFactory.createDrillPCCDATAAPEXWSPassword(pass);
          request.setLogin(login);
          request.setPassword(password);
          //
          GetReportBlockPCCDATAAPEXWSResponse response = (GetReportBlockPCCDATAAPEXWSResponse) getWebServiceTemplate().marshalSendAndReceive( 
                  request, new SoapActionCallback("http://xyz.test.app.company.com:8080/dswsbobje/qaawsservices/queryasaservice/biws?cuid=AQyF0wiLGyhNgX41XOXwiEs&amp;amp;authType=secEnterprise&amp;amp;locale=en&amp;amp;timeout=60&amp;amp;ConvertAnyType=true"));
          return response;
  
      }
  
  }//end client
  </code></pre>
  
  <p><strong>It seems the problem is with the value that I’m passing to “marshaller.setContextPath("?");”  its either wrong format or not able to find it.</strong> </p>
  
  <p>1) How can I fix this &amp; any other issue with this implementation?</p>
  
  <p>2) (optional) For the sake of knowledge "marshaller.setContextPath()" &amp; also the "client.setDefaultUri()"?</p>
  
  <p>Thank you all. </p>