2015-11-06 60 views
7

我已經寫一些代碼,其中我正在消耗另一個web服務和發送至使用WebServiceTemplate該web服務的請求。 但是,我收到以下例外代碼trgiggers異常。 我已經檢查了Spring Core的lib's &一切看起來不錯,但不知道爲什麼這個服務拋出這樣的異常。無法加載「類路徑資源[組織/ springframework的/ WS /客戶端/核心/ WebServiceTemplate.properties]

ApplicationContxt:

<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"> 
    <property name="soapVersion"> 
     <util:constant static-field="org.springframework.ws.soap.SoapVersion.SOAP_12" /> 
    </property> 
</bean> 

<bean id="manageContactService" class="com.canaldigital.tsi.managecontacts.serviceprovider.ManageContactService"> 
    <property name="manageContactsWSTemplate" ref="manageContactsWSTemplate" /> 
</bean> 

    <bean name="manageContactsWSTemplate" class="org.springframework.ws.client.core.WebServiceTemplate"> 
    <constructor-arg ref="messageFactory" /> 

    <property name="defaultUri" value="http://tsi-vip-abc.com:7111/abc_v2/ProxyService?WSDL" /> 

    <property name="marshaller" ref="manageContactMarshaller" /> 
    <property name="unmarshaller" ref="manageContactUnmarshaller" /> 

</bean> 

服務:

public class ManageContactService extends WebServiceGatewaySupport { 

     private WebServiceTemplate manageContactsWSTemplate;   
     public WebServiceTemplate getManageContactsWSTemplate() { 
    return manageContactsWSTemplate; 
} 
public void setManageContactsWSTemplate(WebServiceTemplate manageContactsWSTemplate) { 
    this.manageContactsWSTemplate = manageContactsWSTemplate; 
} 
    public void sendNPSReminder(String phoneNum, String customerNum, String countryCode) { 


      SendNPSReminderRequestType sendNPSReminderRequest = new SendNPSReminderRequestType(); 
      Contact contact = new Contact();    
      sendNPSReminderRequest.setCountryCode(CountryCodeCV.NO); 
      contact.setPhone(new BigInteger(phoneNum));    
      sendNPSReminderRequest.setContact(contact); 
      sendNPSReminderRequest.setCustomerNumber(customerNum); 

      try{ 

       JAXBElement<SendNPSReminderResponseType> response = (JAXBElement<SendNPSReminderResponseType>) manageContactsWSTemplate.marshalSendAndReceive(sendNPSReminderRequest); 
      }catch (Exception e) { 

       e.printStackTrace(); 
      } 

    } 

    } 

堆棧跟蹤:

java.lang.IllegalStateException: Could not load 'class path resource [org/springframework/ws/client/core/WebServiceTemplate.properties]': class path resource [org/springframework/ws/client/ 
ore/WebServiceTemplate.properties] cannot be opened because it does not exist 
     at org.springframework.ws.support.DefaultStrategiesHelper.<init>(DefaultStrategiesHelper.java:78) 
     at org.springframework.ws.support.DefaultStrategiesHelper.<init>(DefaultStrategiesHelper.java:88) 
     at org.springframework.ws.client.core.WebServiceTemplate.initDefaultStrategies(WebServiceTemplate.java:338) 
     at org.springframework.ws.client.core.WebServiceTemplate.<init>(WebServiceTemplate.java:130) 
     at org.springframework.ws.client.core.support.WebServiceGatewaySupport.<init>(WebServiceGatewaySupport.java:65) 
     at com.canaldigital.tsi.managecontacts.serviceprovider.ManageContactService.<init>(ManageContactService.java:24) 
     at com.canaldigital.tsi.managecontacts.utils.CDCommonTasksJob.launch(CDCommonTasksJob.java:97) 
     at sun.reflect.GeneratedMethodAccessor2044.invoke(Unknown Source) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
     at java.lang.reflect.Method.invoke(Method.java:597) 
     at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:64) 
     at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:53) 
     at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:82) 
     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:440) 
     at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) 
     at java.lang.Thread.run(Thread.java:662) 
+0

你是否仔細檢查過你的bean聲明中的所有拼寫?我不確定它會不會破壞整個聲明,但是你可能在'unmarshaller'屬性中有一個拼寫錯誤(與'marshaller'相比)。 – Gorbles

+0

我無法找到拼寫錯誤init。你能否明確提到這個錯誤? – user3548196

+0

\t user3548196

回答

4

該資源spring-ws-core依賴的一部分,所以它必須工作開箱即用,但是,我猜你正在使用WLS 11(當你標記它)。因此,您可能沒有使用您擁有的Spring依賴項,而是將其封裝到WebLogic中。

儘量避免這種使用WEB-INF/weblogic.xml描述如下:

<?xml version="1.0" encoding="UTF-8"?> 
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app"> 

    <container-descriptor> 
     <prefer-application-packages> 
      <package-name>org.springframework.*</package-name> 
     </prefer-application-packages> 

     <prefer-application-resources> 
      <resource-name>org.springframework.*</resource-name> 
     </prefer-application-resources> 
    </container-descriptor> 

</weblogic-web-app> 

有了這個配置,你告訴WLS使用你的包和資源org.springframework.*

希望它有幫助!

+0

這是我的weblogic.xml現在: :WebLogic的web應用程序 \t的xmlns:WLS =「HTTP:// xmlns.oracle.com/weblogic/weblogic-web-app「> \t \t \t \t 我收到錯誤,此屬性不能爲true。 – user3548196

+0

@ user3548196您不能將'prefer-web-inf-classes'與'prefer-application-packages'和/或prefer-application-resources'結合使用。看到這個:https://docs.oracle.com/cd/E24329_01/web.1211/e21049/weblogic_xml.htm#WBAPP659 – malaguna