Could not load 'class path resource [org/springframework/ws/client/core/WebServiceTemplate.properties]
Asked Answered
R

1

7

I have written some code in which i am consuming another webService and sending a request to that webservice using WebServiceTemplate. But i am getting the following exception when that code trgiggers. I have checked the lib's of Spring Core & everything seems ok but dont know why this service is throwing such exception.

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> 

Service:

 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();
            }

    }

    }

StackTrace:

    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)
Rodrigo answered 6/11, 2015 at 11:32 Comment(6)
Have you double-checked all spelling in your bean declaration? I'm not sure that it would break the whole declaration, but you might have a spelling mistake in the unmarshaller property (compared to the marshaller).Lathy
I could not find the spelling mistake init. Can you please clearly mention that mistake?Rodrigo
<oxm:jaxb2-marshaller id="manageContactMarshaller" contextPath="com.canaldigital.tsi.managecontacts.gsd.managecustomer" /> <oxm:jaxb2-marshaller id="manageContactUnmarshaller" contextPath="com.canaldigital.tsi.managecontacts.gsd.managecustomer" />Rodrigo
<property name="marshaller" ref="manageContactMarshaller" /> vs. <property name="unmarshaller" ref="manageContactunmarshaller" />Lathy
There is no spelling mistake i have clearly checked.Rodrigo
That's alright then, sorry, was just suggesting something that didn't match up. Can't think of anything else obvious! :)Lathy
R
4

That resource is part of spring-ws-core dependency, so it must work out of the box, but, I guess your are using WLS 11 (as you tagged it). So, it is possible that you are not using the spring dependency you have but instead spring packaged into WebLogic.

try to avoid this using WEB-INF/weblogic.xml descriptor as following:

<?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 are telling WLS to use your packages and resources for org.springframework.*.

Hope it helps!

Rimarimas answered 10/11, 2015 at 9:5 Comment(2)
This is my weblogic.xml now: <?xml version="1.0" encoding="UTF-8"?> <wls:weblogic-web-app xmlns:wls="xmlns.oracle.com/weblogic/weblogic-web-app"> <wls:container-descriptor> <wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes> </wls:container-descriptor> </wls:weblogic-web-app> I am getting the error that this property cannot be true.Rodrigo
@Rodrigo you can not use prefer-web-inf-classes in combination with prefer-application-packages and/or prefer-application-resources. see this: docs.oracle.com/cd/E24329_01/web.1211/e21049/…Rimarimas

© 2022 - 2024 — McMap. All rights reserved.