Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with InternalResourceViewResolver and Winstone

i have a problem with my spring project.

Here is my web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" 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">

    <servlet>
        <servlet-name>greenmine</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>greenmine</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>
            index.jsp
        </welcome-file>
    </welcome-file-list>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/greenmine-servlet.xml
        </param-value>
    </context-param>

    <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>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
</web-app>

and my greenmine-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:security="http://www.springframework.org/schema/security"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context-3.0.xsd
       http://www.springframework.org/schema/security
       http://www.springframework.org/schema/security/spring-security-3.0.3.xsd
       http://www.springframework.org/schema/mvc
       http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

    <context:component-scan base-package="at.tripwire.greenmine.controller" />
    <context:component-scan base-package="at.tripwire.greenmine.domain.dao" />
    <context:component-scan base-package="at.tripwire.greenmine.service" />
    <context:component-scan base-package="at.tripwire.greenmine.module" />

    <mvc:annotation-driven />
    <mvc:resources location="/css/" mapping="/css/**" />
    <mvc:resources location="/images/" mapping="/images/**" />
    <mvc:resources location="/js/" mapping="/js/**" />

    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
        <property name="prefix" value="/WEB-INF/jsp/" />
        <property name="suffix" value=".jsp" />
    </bean>

    <!-- Hibernate Configuration -->
    <bean id="dataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName">
            <value>com.mysql.jdbc.Driver</value>
        </property>
        <property name="url">
            <value>jdbc:mysql://localhost/greenmine</value>
        </property>
        <property name="username">
            <value>root</value>
        </property>
        <property name="password">
            <value>root</value>
        </property>
    </bean>

    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="annotatedClasses">
            <list>
                <value>at.tripwire.greenmine.domain.Project</value>
                <value>at.tripwire.greenmine.domain.Profile</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
            </props>
        </property>
        <property name="dataSource">
            <ref bean="dataSource" />
        </property>
    </bean>

    <!-- Spring Security -->
    <security:http auto-config="true" use-expressions="true">
        <security:intercept-url pattern="/login"
            access="permitAll" />
        <security:intercept-url pattern="/j_spring_security_check"
            access="permitAll" />
        <security:intercept-url pattern="/css/**"
            filters="none" />
        <security:intercept-url pattern="/js/**"
            filters="none" />
        <security:intercept-url pattern="/images/**"
            filters="none" />
        <security:intercept-url pattern="/**"
            access="isAuthenticated()" />
        <security:form-login login-page="/login"
            login-processing-url="/j_spring_security_check" default-target-url="/projects"
            authentication-failure-url="/login?error=1" />
        <security:logout logout-success-url="/login"
            logout-url="/logout" />
    </security:http>

    <security:authentication-manager>
        <security:authentication-provider
            user-service-ref="profileUserDetailsService">
            <security:password-encoder hash="md5" />
        </security:authentication-provider>
    </security:authentication-manager>
</beans>

next: my LoginController.java

@Controller
public class LoginController {

    @RequestMapping("/login")
    public ModelAndView handleLoginForm(HttpServletRequest request) {
        String errParam = request.getParameter("error");
        ModelAndView mv = new ModelAndView("login/login");
        if(errParam != null) {
            mv.addObject("error", "Benutzer oder Kennwort unzul&auml;ssig");
        }
        return mv;
    }
}

I am using Winstone Servlet Engine v0.9.10. When i goto http://localhost:8080/login it puts following error:

14.04.2011 21:48:13 org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNUNG: No mapping found for HTTP request with URI [/WEB-INF/jsp/login/login.jsp] in DispatcherServlet with name 'greenmine'

but login.jsp is in WEB-INF/jsp/login/login.jsp

hope anyone can help me. i am already searching for two weeks.

like image 751
endian Avatar asked Nov 05 '22 23:11

endian


1 Answers

following tag solved my problem:

<mvc:default-servlet-handler/>
like image 92
endian Avatar answered Nov 14 '22 23:11

endian