Java – unable to load ‘classpath resource [org / springframework / WS / client / core / webservicetemplate. Properties]
•
Java
I wrote some code where I was using another web service and sending a request to the web service using the web service template
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>
Services:
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();
}
}
}
Stack trace:
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)
Solution
This resource is part of a spring WS core dependency, so it must be out of the box, but I guess you're using WLS 11 (when you tag it) Therefore, instead of using spring dependencies owned by spring, you may package spring into Weblogic
Try using WEB-INF / Weblogic XML descriptors avoid this, as follows:
<?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>
With this configuration, you tell WLS to use your packages and resources for org springframework.*.
Hope to help you!
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
