Results 1 to 2 of 2

Thread: Spring-WS holidayRequest tutorial example

  1. #1
    Join Date
    Nov 2009
    Posts
    4

    Default Spring-WS holidayRequest tutorial example

    Dear all,

    I'm trying to follow the holidayRequest example of the Chapter 3 "Writing Contract-First Web Services" of the spring tutorial. Unfortunately I receive an exception if I call the WSDL.

    I've started by adding a new "Dynamic Web Project" in Eclipse. Attachment 1 shows the project setup and it's artifacts.

    The spring-ws-servlet.xml file looks as follows:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans">
    
    	<bean id="holidayEndpoint" class="com.mycompany.hr.ws.HolidayEndpoint">
    		<constructor-arg ref="hrService" />
    	</bean>
    
    	<bean id="hrService" class="com.mycompany.hr.service.StubHumanResourceService" />
    
    	<bean
    		class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
    		<property name="mappings">
    			<props>
    				<prop key="{http://mycompany.com/hr/schemas}HolidayRequest">holidayEndpoint</prop>
    			</props>
    		</property>
    		<property name="interceptors">
    			<bean
    				class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor" />
    		</property>
    	</bean>
    
    	<bean id="holiday"
    		class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
    		(1)
    		<property name="schema" ref="schema" />
    		(2)
    		<property name="portTypeName" value="HumanResource" />
    		(3)
    		<property name="locationUri" value="/holidayService/" />
    		(4)
    		<property name="targetNamespace" value="http://mycompany.com/hr/definitions" />
    		(5)
    	</bean>
    
    	<bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema">
    		(2)
    		<property name="xsd" value="/WEB-INF/hr.xsd" />
    	</bean>
    
    </beans>
    The web.xml file looks as follows:

    Code:
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
                 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    	version="2.4">
    
    	<display-name>MyCompany HR Holiday Service</display-name>
    
    	<!-- take especial notice of the name of this servlet -->
    	<servlet>
    		<servlet-name>spring-ws</servlet-name>
    		<servlet-class>
    			org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
    	</servlet>
    
    	<servlet-mapping>
    		<servlet-name>spring-ws</servlet-name>
    		<url-pattern>/*</url-pattern>
    	</servlet-mapping>
    
    </web-app>
    The hr.xsd file looks as follows:

    Code:
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:hr="http://mycompany.com/hr/schemas"
            elementFormDefault="qualified"
            targetNamespace="http://mycompany.com/hr/schemas">
        <xs:element name="HolidayRequest">
            <xs:complexType>
                <xs:all>
                    <xs:element name="Holiday" type="hr:HolidayType"/>                       
                    <xs:element name="Employee" type="hr:EmployeeType"/>
                </xs:all>
            </xs:complexType>
        </xs:element>
        <xs:complexType name="HolidayType">
            <xs:sequence>
                <xs:element name="StartDate" type="xs:date"/>
                <xs:element name="EndDate" type="xs:date"/>                                  
            </xs:sequence>                                                                   
        </xs:complexType>
        <xs:complexType name="EmployeeType">
            <xs:sequence>
                <xs:element name="Number" type="xs:integer"/>
                <xs:element name="FirstName" type="xs:string"/>
                <xs:element name="LastName" type="xs:string"/>                               
            </xs:sequence>                                                                   
        </xs:complexType>
    </xs:schema>
    After exporting to WAR file and deploying to tomcat 6.0 I receive the following java exception when I try to call the WSDL file on http://localhost:8080/holidayService/holiday.wsdl:

    Code:
    27.11.2009 15:48:54 org.springframework.web.servlet.FrameworkServlet initServletBean
    SCHWERWIEGEND: Context initialization failed
    org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.mycompany.hr.ws.HolidayEndpoint] for bean with name 'holidayEndpoint' defined in ServletContext resource [/WEB-INF/spring-ws-servlet.xml]; nested exception is java.lang.ClassNotFoundException: com.mycompany.hr.ws.HolidayEndpoint
    	at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1141)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:524)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1177)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:758)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:422)
    	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
    	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:402)
    	at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:316)
    	at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:282)
    	at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126)
    	at javax.servlet.GenericServlet.init(GenericServlet.java:212)
    	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
    	at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:809)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
    	at java.lang.Thread.run(Thread.java:619)
    Caused by: java.lang.ClassNotFoundException: com.mycompany.hr.ws.HolidayEndpoint
    	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
    	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
    	at org.springframework.util.ClassUtils.forName(ClassUtils.java:211)
    	at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:385)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1138)
    	... 23 more
    I've added two libraries to my project properties which are jdom.jar and spring-ws-1.5.8-all.jar. Do I need to tell s.b. that these files need to be deployed as well? Maybe this could be the reason for above exception?!

    I would appreciate any help on that.

    Cheers,
    Stefan

  2. #2
    Join Date
    Nov 2009
    Posts
    3

    Default holidayService: spring-ws-servlet.xml

    Hi Stefan,

    could you please tell how did you end up with the "spring-ws-servlet.xml" that you posted?

    Trying to follow the tutorial, I only get this:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
    
    </beans>
    At the same time, the tutorial says:
    (You can see the contents of the 'WEB-INF/spring-ws-servlet.xml' file for this example in ???.)
    -- which points to this:

    http://static.springsource.org/sprin....sws-conf-file

    <bean class="org.springframework.ws.server.endpoint.mapp ing.PayloadRootQNameEndpointMapping">
    <property name="mappings">
    <props>
    <prop key="{http://mycompany.com/hr/schemas}HolidayRequest">holidayEndpoint</prop>
    </props>
    </property>
    <property name="interceptors">
    <bean class="org.springframework.ws.server.endpoint.inte rceptor.PayloadLoggingInterceptor"/>
    </property>
    </bean>

    To me, the two don't add up to what you've got.

    To the Spring developers: could you please be more explicit in the tutorial?

    (Alternatively, if somebody shows me how to indeed build a simple Spring WS, I'd be glad to work on the tutorial:-)).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •