gpt4 book ai didi

java - 无法加载“类路径资源 [org/springframework/ws/client/core/WebServiceTemplate.properties]

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:29:51 25 4
gpt4 key购买 nike

我编写了一些代码,其中我正在使用另一个网络服务并使用 WebServiceTemplate 向该网络服务发送请求。但是当该代码触发时,我得到以下异常。我已经检查了 Spring Core 的库,一切似乎都正常,但不知道为什么这个服务会抛出这样的异常。

应用程序上下文:

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

最佳答案

该资源是 spring-ws-core 依赖项的一部分,因此它必须开箱即用,但是,我猜您正在使用 WLS 11(如您标记的那样)。因此,您可能没有使用现有的 spring 依赖项,而是将 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.*

希望对您有所帮助!

关于java - 无法加载“类路径资源 [org/springframework/ws/client/core/WebServiceTemplate.properties],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33565847/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com