Page 2 of 2 FirstFirst 12
Results 11 to 20 of 20

Thread: Spring MVC 3 + Spring-WS 2 + Spring Security 3 + Tiles

  1. #11

    Default

    My mistake again, I actually tried with that 's' in the URL.

    The URLs that work are things like:

    https://localhost:8443/myapp (for login)
    https://localhost:8443/home
    https://localhost:8443/customer/new

    etc.

    I'm expecting a huge facepalm when I find the error

  2. #12
    Join Date
    Jan 2011
    Posts
    26

    Default

    Just see if the solution to this problem works for you:
    http://forum.springsource.org/showthread.php?t=10880

    (Setting alwaysUseFullPath property to true in the SimpleUrlHandlerMapping bean).

  3. #13
    Join Date
    Dec 2010
    Posts
    315

    Default

    @npintos, thanks for following the tutorial I wrote

    Can you try disabling your Spring Security config? (Just comment it out from the web.xml).

    Also when I combine Spring Security, WS, and MVC, the url-mapping I use for Security is /* but for the MVC and WS I use a child mapping like /web/*

    In fact, when I just use Security and MVC (no WS) I encounter issues with Tiles when both are mapped to /*. Maybe it's conflicting with something. I still haven't figured out the exact reason but I was able to solve it by mapping the MVC/WS to a child path

  4. #14

    Default

    Vithun,

    Thanks for the suggestion! but it did not work

    skram,

    No, thanks to you for such a thorough tutorial!

    If I understood well, you suggested:

    web.xml: a child mapping for the servlet, root mapping for security
    Code:
    <servlet-mapping> 
        <servlet-name>myapp</servlet-name> 
        <url-pattern>/hs/*</url-pattern>           
    </servlet-mapping>
    
    <filter-mapping>
      <filter-name>springSecurityFilterChain</filter-name>
      <url-pattern>/*</url-pattern>
    </filter-mapping>
    security.xml: left untouched ()excerpt below
    Code:
    <http auto-config="true" use-expressions="true">
      	<!-- Allow everyone access to images, javascript and stylesheets -->
      	<intercept-url pattern="/resources/**" access="permitAll" />
    
      	<intercept-url pattern="/ws" 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" />
      	 
      	<!-- Force every controller to use SSL (https) -->
        <intercept-url pattern="/*" access="hasRole('ROLE_USER')" requires-channel="https"/>
    myapp-servlet.xml (left untouched, excerpt)
    Code:
    <!-- Maps '/' requests to the 'home' view -->
    <mvc:view-controller path="/" view-name="home"/>
    <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources/ directory -->
    <mvc:resources mapping="/resources/**" location="/resources/" />
    <!-- Package where the controllers reside -->
    <context:component-scan base-package="org.mycompany.myapp" /> 
    <!-- Views resolver: Tiles  -->
    <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
    </bean>
    <!-- Tiles Configuration and Definitions -->
    <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
    <property name="definitions">
    	<list>
    		<value>/WEB-INF/definitions/tiles-defs.xml</value>
    	</list>
    </property>
    </bean>
    
    <!-- Interceptor defined elsewhere -->
    <bean id="handlerMapping"
    class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
        <property name="interceptors">
            <ref bean="localeChangeInterceptor" />
        </property>
    </bean>
    And mvc-ws-integration.xml (left untouched):
    Code:
    <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="mappings">
    			<value>
    				/ws=messageDispatcher
    				/ws/authentication.wsdl=authentication
    			</value>
    		</property> 
    </bean>
    Even with this modifications (well, I only changed the mappings in web.xml), the WS part is still not working. I can access my webapp with https://localhost:8443/myapp/hs/, but I keep getting a:
    Code:
    WARN [org.springframework.web.servlet.PageNotFound] - <N
    o mapping found for HTTP request with URI [/myapp/hs/ws/authentication.wsdl]
    in DispatcherServlet with name 'myapp'>
    Do you think any of the configuration lines in bold is clashing with another?

    I've spent the past two days with trial and error, I never expected this configuration to be so troublesome (and so undocumented)

    Thanks both for your help!

  5. #15

    Default

    Oh, forgot to mention: disabling security in web.xml does not help either

  6. #16
    Join Date
    Dec 2010
    Posts
    315

    Wink

    I tried adding all the differing configurations you've made in my sample app and everything works.

    The only different configuration is I have not enable any SSL support. What happens when you disable SSL?

    By the way out of topic, there's a specific View Resolver for Tiles 2:
    Code:
    <!-- Convenience subclass of UrlBasedViewResolver that supports TilesView (i.e. Tiles definitions) and custom subclasses of it. -->
    	<!-- Don't forget to set the order if you declared other ViewResolvers -->
    	<!-- See http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/web/servlet/view/tiles2/TilesViewResolver.html  -->
    	<bean id="tilesviewResolver" class="org.springframework.web.servlet.view.tiles2.TilesViewResolver" 
    			p:order="0"/>
    Though it wouldn't really matter

    I'll be honest with you. It also took me days to figure out how to glue together MVC and WS. It's a pain.

    Have you tried adding the extra configurations you did in your app to the sample tutorial and see if it works?

    Are you able to access the WSDL at
    https://localhost:8080/myapp/hs/ws/authentication.wsdl
    (Note it's 8080) when SSL is disabled?

    A quick Google search, I've found some people having problems with Web Services when https is enabled. See http://tugdualgrall.blogspot.com/200...-services.html
    (Check the comments)

    At the end it seems to be a mapping problem. So simple that we can't find it

  7. #17

    Default

    Skram,

    I managed to make it all work (MVC+WS+Security) with two servlets, following the configuration files of the airline project and starting from scratch.

    Thanks a lot for your comments and help, and keep doing those great tutorials!

    Cheers,

    Nacho

  8. #18

    Default Did you solve the problem?

    I have a very similar problem (see http://forum.springsource.org/showthread.php?t=104116)
    . I have a working spring-ws project where I tried to add MVC, using the krams example.

    But I have the same problem as you. And I dont use security.

    Did you solve the problem?

  9. #19

    Default

    Hi Thomas,

    As I mentioned in my last post, the solution was to do it the other way: using two servlets, instead of one (as in the krams example).

    Look for the airline example project (I'm not sure if it came with Spring-MVC or Spring-WS), I reproduced its configuration in my project and it worked immediatly

    Good luck, do not surrender!

    Nacho

  10. #20

    Default

    Hi

    I tried it with mixed success.

    If I have both servlets my web service works, but the mvc gives me 405 not allowed.

    But if I comment the web.xml code for web service, then mvc runs.

    My modified web.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <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>Archetype Created Web Application</display-name>

    <servlet>
    <servlet-name>spring-ws2</servlet-name>
    <servlet-class>org.springframework.ws.transport.http.Messag eDispatcherServlet</servlet-class>
    </servlet>

    <servlet-mapping>
    <servlet-name>spring-ws2</servlet-name>
    <url-pattern>/*</url-pattern>
    </servlet-mapping>

    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/spring-wsmvc-application-config.xml</param-value>
    </context-param>

    <listener>
    <listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>
    </listener>

    <servlet>
    <servlet-name>spring-wsmvc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
    <init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/spring-wsmvc-servlet-config.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
    <servlet-name>spring-wsmvc</servlet-name>
    <url-pattern>/competence/*</url-pattern>
    </servlet-mapping>

    </web-app>

Tags for this Thread

Posting Permissions

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