How to configure mapping in Spring MVC and Tomcat - spring

im trying configure SpringMVC project and i have error when compile
WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/test/home.jsp] in DispatcherServlet with name 'appServlet'
I have a jsp page here: /test/src/main/webapp/WEB-INF/views/home.jsp
This is my code:
/test/src/main/webapp/WEB-INF/web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/root-context.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<filter>
<filter-name>charsetFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>charsetFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
/test/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<annotation-driven />
<resources mapping="/resources/**" location="/resources/" />
<beans:bean
name="test"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<beans:import resource="controllers.xml" />
</beans:beans>

don't use jsp extension directly map it as html for example
<display-name>appServlet</display-name>
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
and then in your controller map file without extention:
#RequestMapping(value="/home.html", method=RequestMethod.GET)
public ModelAndView indexView(){
ModelAndView mv = new ModelAndView("test/home");
return mv;
}
in this example as soon as the user hits /home.html Dispatcher servlet will resolve it and retrieve /test/home.jsp
Hope it helps.

Related

Spring MVC RequestMapping couldn't be resolved

I want to revise my codes to make it leaner. My intentions are as below:
I wrote a RedirectServlet to handle all the redirection, so I use the url-pattern /pages/* to make it distinguish from original dispatcherServlet's request mapping.
I also mapped the url pattern of dipatcherServlet to /do/** since it conflicts with the redirectServlet due to reasons unknown to me. But it brings me more problems to solve.
the #RequestMapping annotation in all my controller might be a problem. I want to specify path with more than one seperator,just like /do/user/signup. But there's a problem there the path can't be resolve correctly, and it returns a 404 page, which frustrates me a great deal.
something like:
type Status report
message /do/user/login
description The requested resource is not available.
So much about my casse, I want to know :
how to configure spring mvc environment, so that I can redirect to pages without writes a function in controller,just like :
#RequestMapping("submitArticleView")
public String submitArticleView(Model model){
model.addAttribute("article",new Article());
return "submitArticleView";
}
I want something like and return a page.
how to use #RequestMapping in a lean way.
Thanks in advance.
my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>plainart</display-name>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-servlet.xml /WEB-INF/applicationContext.xml /WEB-INF/hibernateContext.xml</param-value>
</context-param>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value></param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/do/**</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>Redirector</servlet-name>
<servlet-class>cn.edu.xmu.plainart.controller.Redirector</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Redirector</servlet-name>
<url-pattern>/pages/*</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<filter-name>SpringOpenEntityManagerInViewFilter</filter-name>
<filter-class>
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>SpringOpenEntityManagerInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
dispatcher-servlet.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:annotation-config />
<context:component-scan base-package="cn.edu.xmu.plainart" />
<mvc:annotation-driven />
<mvc:interceptors>
<mvc:interceptor>
<!-- Intercepting specific URL -->
<mvc:mapping path="/authenticate/**" />
<bean id= "myInterceptor"
class="cn.edu.xmu.plainart.controller.AuthenticationInterceptor" />
</mvc:interceptor>
</mvc:interceptors>
<!--
<mvc:resources mapping="/resources/**" location="/resources/theme_default/" />
-->
<mvc:resources mapping="/resources/**" location="/resources/" />
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- one of the properties available; the maximum file size in bytes -->
<property name="maxUploadSize" value="100000000"/>
</bean>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
<property name="prefix">
<value>/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>
editorController.java
#Controller
#RequestMapping("/do/editor")
public class EditorController {
#Autowired
private UploadService uploadService;
#Autowired
private InformationService infoService;
#RequestMapping(value ="/submitArticle", method =RequestMethod.POST)
public #ResponseBody
String submitArticle(#ModelAttribute("article") Article article,BindingResult result,HttpServletRequest request){
Editor editor = (Editor) request.getAttribute("LOGGEDIN_USER");
article.setAuthor(editor);
Position pos = new Position("index",10.0);
pos.appendInfo(article);
article.setPos(pos);
ServletContext context = request.getServletContext();
article = uploadService.uploadArticleInfo(article);
String path = uploadService.uploadArticle(article.getTitle()+article.getId(), article.getContent(),context);
System.out.println(path);
return path;
}
#RequestMapping(value="/submitAd",method = RequestMethod.POST)
public #ResponseBody
String submitAd(#ModelAttribute("ad")Advertisement ad,BindingResult result,#RequestParam("pic") MultipartFile file,HttpServletResponse response, HttpServletRequest request,HttpSession session) throws IllegalStateException, IOException, URISyntaxException{
Editor editor = (Editor)session.getAttribute("LOGGEDIN_USER");
ad.setCommitter(editor);
Position pos = new Position("bottom",5.0);
pos.appendInfo(ad);
ad.setPos(pos);
String name ="/uploads/figure/"+file.getOriginalFilename();
name = request.getServletContext().getResource(name).toString();
System.out.println(name);
File tosave = new File(name);
file.transferTo(tosave);
ad.setPic(name);
uploadService.uploadAdInfo(ad);
return name;
}
}

"/" maps to /WEB-INF/pages/ -- why?

For some reason /WEB-INF/pages seems to have become a root folder. Any request to / goes to /pages/. For instance, the following request goes to /pages/index.jsp.
That's a bit of a problem because I've also got a /WEB-INF/secure folder, which I don't get how to reach.
Why is this...?
#RequestMapping("/")
public String printWelcome(ModelMap model) {
return "index";
}
web.xml
<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">
<display-name>Spring MVC Application</display-name>
<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>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext-security.xml
/WEB-INF/springmvc-config.xml
</param-value>
</context-param>
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
Edit as per request:
<?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:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="com.springapp.mvc.service"/>
<mvc:annotation-driven/>
<mvc:resources mapping="/css/**" location="/css/"/>
<!--
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/pages/"/>
<property name="suffix" value=".jsp"/>
</bean>
-->
</beans>
Can we see your Spring servlet bean config as well?
Probably you have an InternalResourceViewResolver pointing at /WEB-INF/pages/.
For example, look for something like this:
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:viewClass="org.springframework.web.servlet.view.JstlView"
p:prefix="/WEB-INF/pages/"
p:suffix=".jsp" />

Spring Static Resource Mapping

I have been followed by this error since I started using Spring
I can't handle static content
My dispatcher-servlet configuration
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<import resource="applicationContext.xml"/>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp" />
<mvc:resources mapping="/captcha/*" location="/resources/captcha/" />
<mvc:annotation-driven />
<mvc:default-servlet-handler/>
</beans>
My web configuration
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.css</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.js</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.js</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.gif</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.jpg</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.PNG</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>Login.jsp</welcome-file>
</welcome-file-list>
</web-app>
Finally the image I want to add is
<img src="<c:url value="/resources/captcha/13.PNG"/>"/>
But my log displays this:
01:19:10,801 DEBUG RequestMappingHandlerMapping:220 - Looking up handler method for path /resources/captcha/35.png
01:19:10,803 DEBUG RequestMappingHandlerMapping:230 - Did not find handler method for [/resources/captcha/35.png]
01:19:10,803 DEBUG SimpleUrlHandlerMapping:169 - Matching patterns for request [/resources/captcha/35.png] are [/**]
01:19:10,804 DEBUG SimpleUrlHandlerMapping:194 - URI Template variables for request [/resources/captcha/35.png] are {}
01:19:10,805 DEBUG SimpleUrlHandlerMapping:124 - Mapping [/resources/captcha/35.png] to HandlerExecutionChain with handler [org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler#eea824] and 1 interceptor
01:19:10,805 DEBUG DispatcherServlet:912 - Last-Modified value for [/project/resources/captcha/35.png] is: -1
01:19:10,805 DEBUG DispatcherServlet:999 - Null ModelAndView returned to DispatcherServlet with name 'dispatcher': assuming HandlerAdapter completed request handling
01:19:10,806 DEBUG DispatcherServlet:966 - Successfully completed request
Am I missing more configuration?
Thanks
When you try to access
/resources/captcha/13.PNG
It is mapped to default servlet by virtue of
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.PNG</url-pattern>
</servlet-mapping>
It is not mapped to /resources/captcha/ because the resources looks for paths which have the pattern of type http://localhost:8080/captcha/* and not the ones with http://localhost:8080/resources/captcha/* so to handle such requests, you need to have a view resolver to respond to /resources/* pattern
something like
#RequestMapping(path = '/resources/*')
public Object handler(){...}
My guess is you want to render the PNG image as a static resource and you should probably have <img src="<c:url value="/resources/captcha/13.PNG"/>"/>.
NOTE: I am not sure what I suggested works or not. I am answering solely based on my memory and have not tested any of the situations you mentioned.

i am facing Detected cyclic loading exception

i am getting the following exception
Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [cxf.xml]
Offending resource: file [C:\Documents and Settings\ashriv5\odin\CXFRestfulTutorial\cxf.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Detected cyclic loading of file
below is the cxf.xml file
<?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:jaxrs="http://cxf.apache.org/jaxrs"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd">
<import resource="cxf.xml" />
<jaxrs:server id="base" address="/rest">
<jaxrs:serviceBeans>
<ref bean="StudentService" />
</jaxrs:serviceBeans>
</jaxrs:server>
<bean id="StudentService" class="com.student.ChangeStudentDetailsImpl" />
</beans>
below is my web.xml file
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>CXFRestfulTutorial</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/cxf.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<servlet>
<display-name>Apache-Axis Servlet</display-name>
<servlet-name>AxisServlet</servlet-name>
<servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/servlet/AxisServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>*.jws</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<servlet>
<display-name>Axis Admin Servlet</display-name>
<servlet-name>AdminServlet</servlet-name>
<servlet-class>org.apache.axis.transport.http.AdminServlet</servlet-class>
<load-on-startup>100</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>AdminServlet</servlet-name>
<url-pattern>/servlet/AdminServlet</url-pattern>
</servlet-mapping>
</web-app>

spring security No WebApplicationContext found

I am new to spring security
I have web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext-security.xml
</param-value>
</context-param>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>*.html</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>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
applicationContext-security.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
<http auto-config="true">
<intercept-url pattern="/register.html" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<intercept-url pattern="/*" access="ROLE_USER, ROLE_ADMIN" />
<logout logout-url="/logout"/>
</http>
<beans:bean id="myUserDetailsService" class="labas.spring.service.UserDetailsImp"/>
<authentication-manager>
<authentication-provider user-service-ref='myUserDetailsService'/>
</authentication-manager>
some why when I run it I get
java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
what is wrong?
You haven't declared the root webapp context - you've added the contextConfigLocation, but not the listener that uses it:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

Resources