Spring MVC 3 + Spring-WS 2 + Spring Security 3 + Tiles
Hello,
I'm trying to wire everything to have a web application that can handle Spring MVC and Spring-WS web services, all wrapped under Spring Security and with Tiles as the view technology.
I've followed this excellent tutorial:
http://krams915.blogspot.com/2010/12...ing-3-mvc.html
tried the example code, etc, and it works.
but when I try to do the same on my project, it is not working. Calls to web services seems to get handled by DispatcherServlet:
Error:
Code:
WARN [org.springframework.web.servlet.PageNotFound] - <N
o mapping found for HTTP request with URI [/myapp/ws/authentication.wsdl] in DispatcherServlet with name 'myapp'>
I Know that the xsd is correct and endpoint classes work correctly, because putting them in that tutorial's code acts fine, and I can test them with soapUI.
I thinks this may be some kind of mapping problem.
Below you'll find all my config files, important bits in bold; I put everything for the sake of completeness, this is a very tough technology puzzle :confused:
web.xml:
Code:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext-jpa.xml
/WEB-INF/myapp-security.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
</listener>
<servlet>
<servlet-name>myapp</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/myapp-servlet.xml</param-value>
</init-param>
<init-param>
<param-name>transformWsdlLocations</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>myapp</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
applicationContext-jpa.xml:
Code:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"
...
/>
<!-- JPA EntityManagerFactory -->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
...
</bean>
<!-- Transaction Config -->
<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="entityManagerFactory"
p:dataSource-ref="dataSource"/>
<tx:annotation-driven/><!-- mode="aspectj" transaction-manager="transactionManager"/> -->
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
<!-- Contains the configuration to integrate Spring MVC and Spring WS using the
DispatcherServlet and MessageDispatcher -->
<import resource = "mvc-ws-integration.xml" />
<!-- Contains the Spring WS specific configuration -->
<import resource = "spring-ws.xml" />
</beans>
mvc-ws-integration.xml (taken from the tutorial):
Code:
<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"/>
<bean class="org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter"
p:messageFactory-ref="messageFactory"/>
<bean class="org.springframework.ws.transport.http.WsdlDefinitionHandlerAdapter"/>
<bean id="messageDispatcher" class="org.springframework.ws.server.MessageDispatcher">
<property name="endpointAdapters">
<list>
<ref bean="defaultMethodEndpointAdapter"/>
</list>
</property>
</bean>
<!-- See reference at the beginning of this document -->
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<value>
/ws=messageDispatcher
/ws/authentication.wsdl=authentication
</value>
</property>
</bean>
<!-- See reference at the beginning of this document -->
<bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/>
</beans>
spring-ws.xml (taken from the tutorial):
Code:
<sws:annotation-driven />
<sws:interceptors>
<bean id="validatingInterceptor" class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor"
p:schema="/WEB-INF/xsd/authentication.xsd"
p:validateRequest="true"
p:validateResponse="true"/>
<bean id="loggingInterceptor" class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor"/>
</sws:interceptors>
<sws:dynamic-wsdl id="authentication"
portTypeName="AuthenticationRequest"
locationUri="/"
targetNamespace="http://mycompany.org/myapp/schemas">
<sws:xsd location="/WEB-INF/xsd/authentication.xsd"/>
</sws:dynamic-wsdl>
<bean id="castorMarshaller" class="org.springframework.oxm.castor.CastorMarshaller"
p:mappingLocation="/WEB-INF/castor-mapping.xml" />
<bean id="marshallingPayloadMethodProcessor" class="org.springframework.ws.server.endpoint.adapter.method.MarshallingPayloadMethodProcessor">
<constructor-arg ref="castorMarshaller"/>
<constructor-arg ref="castorMarshaller"/>
</bean>
<bean id="defaultMethodEndpointAdapter" class="org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter">
<property name="methodArgumentResolvers">
<list>
<ref bean="marshallingPayloadMethodProcessor"/>
</list>
</property>
<property name="methodReturnValueHandlers">
<list>
<ref bean="marshallingPayloadMethodProcessor"/>
</list>
</property>
</bean>
</beans>
myapp-security.xml:
Code:
<http auto-config="true" use-expressions="true">
<intercept-url pattern="/resources/**" access="permitAll" />
<!-- Allow everyone access to web services endpoints -->
<intercept-url pattern="/ws/**" access="permitAll" />
<!-- Force login through SSL (https) -->
<intercept-url pattern="/login" access="permitAll" requires-channel="https" />
<intercept-url pattern="/*" access="hasRole('ROLE_USER')" requires-channel="https"/>
<form-login login-page="/login"
authentication-failure-url = "/login/?login_error=1"/>
<remember-me key="myapp-rTy4444454564546546l5tjhdfjhdrKzZ"/>
<logout invalidate-session="true" logout-success-url="/login" logout-url="/logout"/>
<session-management>
<concurrency-control max-sessions="1" error-if-maximum-exceeded="true" />
</session-management>
</http>
<authentication-manager alias="authenticationManager">
<authentication-provider user-service-ref="jdbcUserService" >
</authentication-provider>
</authentication-manager>
<beans:bean id="jdbcUserService"
...
</beans:bean>
</beans:beans>
authentication.xsd:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<schema
xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="qualified"
targetNamespace="http://mycompany.org/myapp/schemas"
xmlns:tns="http://mycompany.org/myapp/schemas">
<element name="username" tns:maxOccurs="1" tns:minOccurs="1">
<simpleType>
<restriction base="string">
<pattern value="([A-Z]|[a-z]|\s|\.)+"/>
<minLength value="3"/>
</restriction>
</simpleType>
</element>
<element name="password" tns:maxOccurs="1" tns:minOccurs="1">
<simpleType>
<restriction base="string">
<pattern value="([A-Z]|[a-z]|\s|\.)+"/>
<minLength value="3"/>
</restriction>
</simpleType>
</element>
<element name="authenticationRequest" tns:maxOccurs="1" tns:minOccurs="1">
<complexType >
<sequence>
<element ref="tns:username" />
<element ref="tns:password" />
</sequence>
</complexType>
</element>
</schema>
for the brave soul that checks these files, if you find some file missing i can post more info.
Thanks,
Nacho