Application context Error in JBoss Seam -Spring Integration - spring

I wish to know that if all the configurations I'd done is correct? If you need any of the configuration file please ask for it. Thanks. I am new to this kind of question. :)
Hi , the problem I encountered s something like: when the Spring bean is initializing and it start to inject seam component into it, but the seam component isn't there during server startup and I got the java.lang.IllegalStateException: No application context active.
Error logs and configurations are provided below:
error log:
13:35:34,698 ERROR [DispatcherServlet] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springController' defined in ServletContext resource [/WEB-INF/NUSLibraries-servlet.xml]: Cannot resolve reference to bean 'ActionPortalStaticPage' while setting bean property 'portalStaticPage'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ActionPortalStaticPage': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: No application context active
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanD efinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessar y(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyVa lues(AbstractAutowireCapableBeanFactory.java:1325)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(Ab stractAutowireCapableBeanFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(Ab stractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(Abst ractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactor y.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultS ingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory. java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.ja va:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingleton s(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitializati on(AbstractApplicationContext.java:895)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ActionPortalStaticPage': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: No application context active
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryB ean(FactoryBeanRegistrySupport.java:149)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBea n(FactoryBeanRegistrySupport.java:109)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(Abstr actBeanFactory.java:1429)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory. java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.ja va:190)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanD efinitionValueResolver.java:322)
... 89 more
Caused by: java.lang.IllegalStateException: No application context active
at org.jboss.seam.Component.forName(Component.java:1945)
at org.jboss.seam.Component.getInstance(Component.java:2005)
at org.jboss.seam.Component.getInstance(Component.java:1983)
at org.jboss.seam.Component.getInstance(Component.java:1977)
at org.jboss.seam.Component.getInstance(Component.java:1972)
at org.jboss.seam.ioc.spring.SeamTargetSource.getTarget(SeamTargetSource.java:85)
at org.jboss.seam.ioc.spring.SeamFactoryBean.createInstance(SeamFactoryBean.java:97)
at org.springframework.beans.factory.config.AbstractFactoryBean.getObject(AbstractFactoryBean.j ava:146)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryB ean(FactoryBeanRegistrySupport.java:142)
... 94 more
13:35:34,714 ERROR [[/frontend]] StandardWrapper.Throwable
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springController' defined in ServletContext resource [/WEB-INF/NUSLibraries-servlet.xml]: Cannot resolve reference to bean 'ActionPortalStaticPage' while setting bean property 'portalStaticPage'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ActionPortalStaticPage': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: No application context active
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanD efinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessar y(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyVa lues(AbstractAutowireCapableBeanFactory.java:1325)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(Ab stractAutowireCapableBeanFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(Ab stractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(Abst ractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactor y.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultS ingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory. java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.ja va:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingleton s(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitializati on(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationCo ntext.java:425)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServle t.java:442)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServle t.java:458)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet. java:339)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1048)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:950)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4122)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4421)
at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployme nt.java:310)
at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java: 142)
at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:461)
at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118)
at org.jboss.web.deployers.WebModule.start(WebModule.java:97)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAd apter.java:117)
at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployA ction.java:70)
at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProf ileAction.java:53)
at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractPro fileService.java:403)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.jav a:348)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1633)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:935)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1083 )
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:985)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:775)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:540)
at org.jboss.system.server.profileservice.repository.AbstractProfileService.registerProfile(Abs tractProfileService.java:308)
at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap .java:256)
at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)
at org.jboss.Main.boot(Main.java:221)
at org.jboss.Main$1.run(Main.java:556)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ActionPortalStaticPage': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: No application context active
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryB ean(FactoryBeanRegistrySupport.java:149)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBea n(FactoryBeanRegistrySupport.java:109)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(Abstr actBeanFactory.java:1429)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory. java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.ja va:190)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanD efinitionValueResolver.java:322)
... 89 more
Caused by: java.lang.IllegalStateException: No application context active
at org.jboss.seam.Component.forName(Component.java:1945)
at org.jboss.seam.Component.getInstance(Component.java:2005)
at org.jboss.seam.Component.getInstance(Component.java:1983)
at org.jboss.seam.Component.getInstance(Component.java:1977)
at org.jboss.seam.Component.getInstance(Component.java:1972)
at org.jboss.seam.ioc.spring.SeamTargetSource.getTarget(SeamTargetSource.java:85)
at org.jboss.seam.ioc.spring.SeamFactoryBean.createInstance(SeamFactoryBean.java:97)
at org.springframework.beans.factory.config.AbstractFactoryBean.getObject(AbstractFactoryBean.j ava:146)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryB ean(FactoryBeanRegistrySupport.java:142)
... 94 more
13:35:34,714 ERROR [[/frontend]] Servlet /frontend threw load() exception
java.lang.IllegalStateException: No application context active
at org.jboss.seam.Component.forName(Component.java:1945)
at org.jboss.seam.Component.getInstance(Component.java:2005)
at org.jboss.seam.Component.getInstance(Component.java:1983)
at org.jboss.seam.Component.getInstance(Component.java:1977)
at org.jboss.seam.Component.getInstance(Component.java:1972)
at org.jboss.seam.ioc.spring.SeamTargetSource.getTarget(SeamTargetSource.java:85)
at org.jboss.seam.ioc.spring.SeamFactoryBean.createInstance(SeamFactoryBean.java:97)
at org.springframework.beans.factory.config.AbstractFactoryBean.getObject(AbstractFactoryBean.j ava:146)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryB ean
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>frontend</display-name>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.seam</url-pattern>
</servlet-mapping>
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>blueSky</param-value>
</context-param>
<listener>
<listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
</listener>
<filter>
<filter-name>Seam Filter</filter-name>
<filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Seam Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>Seam Resource Servlet</servlet-name>
<servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Seam Resource Servlet</servlet-name>
<url-pattern>/seam/resource/*</url-pattern>
</servlet-mapping>
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<security-constraint>
<display-name>Restrict raw XHTML Documents</display-name>
<web-resource-collection>
<web-resource-name>XHTML</web-resource-name>
<url-pattern>*.xhtml</url-pattern>
</web-resource-collection>
<auth-constraint/>
</security-constraint>
<servlet>
<servlet-name>NUSLibraries</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>NUSLibraries</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
My application-context.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:mvc="http://www.springframework.org/schema/mvc"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:seam="http://jboss.com/products/seam/spring"
xmlns:context="http://www.springframework.org/schema/context"
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/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://jboss.com/products/seam/spring-seam
http://jboss.com/products/seam/spring-seam-2.1.xsd">
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
<property name="suffix">
<value>.xhtml</value>
</property>
</bean>
<!-- Controller -->
<bean id="springController" class="org.domain.frontend.controller.SpringController">
<property name="portalStaticPage" ref="ActionPortalStaticPage">
</property>
</bean>
<seam:instance name="ActionPortalStaticPage" id="ActionPortalStaticPage"/>
<bean id="handlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<value>
/*/*=springController
</value>
</property>
</bean>
</beans>
My Controller:
package org.domain.frontend.controller;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.StringTokenizer;
import javax.persistence.NoResultException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.domain.frontend.session.ActionPortalStaticPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.support.RequestContextUtils;
#Controller
#Transactional
public class SpringController{
static Logger log = Logger.getLogger("SpringController");
private ActionPortalStaticPage portalStaticPage;
public void setPortalStaticPage(ActionPortalStaticPage portalStaticPage) {
this.portalStaticPage = portalStaticPage;
}
#RequestMapping("/*/{param}")
public ModelAndView langzh(HttpServletRequest request, HttpServletResponse response, #PathVariable("param") String param) throws Exception {
List<String> params = new ArrayList<String>();
try{
log.info("param("+param+")");
StringTokenizer st = new StringTokenizer(param,"-");
while (st.hasMoreTokens()) {
params.add(st.nextToken());
}
portalStaticPage.setTitle(params.toString());
log.info("portalStaticPage("+portalStaticPage.getTitle()+")");
return new ModelAndView("index");
}
catch(Exception ex){
ex.printStackTrace();
return new ModelAndView(params.get(0));
}
}
}
Thanks for every precious comment! Perhaps I m not doing it in the correct way.
Thank you

I can't see where your applicationContext is initialized. In a spring webapp I added
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
to web.xml which loads WEB-INF/applicationContext.xml.
I'm not sure whether this is recommended/required with seam integration.

Related

No candidate found for Autowired bean

At a customer, I'm working on an application that requires auditing. These auditing records should be viewable in a web page and I'm modifying the currently existing data to do just that.
Maven compiles the code without errors, but when calling the webpage to display the audit records, I receive the following exception
04-Jan-2017 15:22:25.133 WARNING [http-nio-7443-exec-7] org.glassfish.jersey.server.spring.AutowiredInjectResolver.getBeanFromSpringContext No qualifying bean of type 'my.company.app.audit.service.IAuditService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
04-Jan-2017 15:22:25.167 WARNING [http-nio-7443-exec-7] org.glassfish.jersey.internal.Errors.logErrors The following warnings have been detected: WARNING: Unknown HK2 failure detected:
MultiException stack 1 of 3
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'my.company.app.audit.service.IAuditService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
MultiException stack 2 of 3
java.lang.IllegalArgumentException: While attempting to resolve the dependencies of my.company.app.audit.rest.resources.AuditResource errors were found
MultiException stack 3 of 3
java.lang.IllegalStateException: Unable to perform operation: resolve on my.company.app.audit.rest.resources.AuditResource
The application class
package my.company.app.audit;
public class AuditApplication extends ResourceConfig {
public AuditApplication() {
register(AuditResource.class);
}
}
The Resource class
package my.company.app.audit.rest.resources;
#Path(AUDIT_RESOURCE_LINK)
#Produces({ MediaType.APPLICATION_JSON })
public class AuditResource extends AbstractResource {
#Autowired
private IAuditService auditService; // Commenting out this line results in the exception no longer popping up
}
The Service class
package my.company.app.audit.service;
import org.springframework.stereotype.Service;
#Service
public class AuditService implements IAuditService {
}
Audit application specific config: audit-config.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:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd">
<context:annotation-config/>
<context:component-scan base-package="my.company.app.audit"/>
<jpa:repositories base-package="my.company.app.audit" transaction-manager-ref="txManager"/>
<aop:aspectj-autoproxy/>
</beans>
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"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0" metadata-complete="true">
<display-name>foo web_audit</display-name>
<!-- SESSION -->
<session-config>
<session-timeout>30</session-timeout>
<cookie-config>
<name>WEB_AUDIT</name>
<path>/</path>
<http-only>true</http-only>
<secure>true</secure>
</cookie-config>
</session-config>
<!-- SPRING -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:applicationContext.xml,
classpath:foo-json-serialization-beans.xml,
classpath:foo-dao-jpa-beans.xml,
classpath:foo-dao-jpa-vendor-adapter-beans.xml,
classpath:spring/foo-jpa-services-common.xml,
classpath:audit-config.xml,
classpath:iam-config.xml
</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<!-- FILTER -->
<filter>
<filter-name>securityHeadersFilter</filter-name>
<filter-class>my.company.fooshared.web.filter.SecurityHeadersFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>securityHeadersFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>SSOFilter</filter-name>
<filter-class>my.company.fooshared.webaccess.filter.WebAccessFilter</filter-class>
<init-param>
<param-name>acsUrl</param-name>
<param-value>/acs</param-value>
</init-param>
<init-param>
<param-name>logoutUrl</param-name>
<param-value>/logout</param-value>
</init-param>
<init-param>
<param-name>authRequestUrl</param-name>
<param-value>/authRequest</param-value>
</init-param>
<init-param>
<param-name>spProviderId</param-name>
<param-value>screeningutility-ci.browse.companynet.sipn.company.com</param-value>
</init-param>
<init-param>
<param-name>idProviderSSOUrl</param-name>
<param-value>https://idp.companynet.sipn.company.com/idp/profile/SAML2/POST/SSO</param-value>
</init-param>
<init-param>
<param-name>cacertPath</param-name>
<param-value>/var/lib/tomcat/cacert/</param-value>
</init-param>
<init-param>
<param-name>keystoreFile</param-name>
<param-value>/var/lib/tomcat/jks/suchannel.jks</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>SSOFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- JERSEY -->
<servlet>
<servlet-name>Jersey2Dispatcher</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>my.company.app.audit.AuditApplication</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey2Dispatcher</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<error-page>
<location>/error.html</location>
</error-page>
</web-app>
I took a resembling module as example to build my code on. That other module works fine, so I must be missing something...
Any suggestion is welcome.
When adding default constructors and setting breakpoints inside them, I notice that the constructor of the AuditService class is never called.
Autowiring the class itself instead of the implemented interface solved this issue. I have no explanation of why the interface didn't work.
Edit
I have probably found the cause of the issue.
While modifying the code, I introduced some new modules in maven. Those new modules are child-modules of the module that initially contained the code.
Old situation: New siuation:
audit-module audit-module
|- src |- persistence
|- target | |- src
|- pom.xml | |- target
| |- pom.xml
|- service
| |- src
| |- target
| |- pom.xml
|- web
| |- src
| |- target
| |- pom.xml
|- pom.xml
But other modules that were relying on the old audit-module were not updated and thus were refering to the parent of the new modules. This is likely the cause that the AuditService class was not loaded properly by Spring

I am getting a HTTP Status 500 - Servlet.init() for servlet HelloWorld threw exception

Looked int other posts of "Servlet.init() for servlet " didnt help.
This is not a Maven or Gradle, so no pom.This is a plain simple spring project, which I am still struggling with. Below the snippets is the actuall error.
Hellocontroller.java.
package controller;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.*;
//import com.sun.javafx.collections.MappingChange.Map;
public class Hellocontroller implements Controller {
#Override
public ModelAndView handleRequest(HttpServletRequest req,
HttpServletResponse res) throws Exception {
String name = req.getParameter("name");
Map m = new HashMap();
m.put("msg", "Hello ...."+name);
ModelAndView mav =new ModelAndView("success",m);
return mav;
}
}
HelloWorld-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xmlns="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/context http://www.springframework.org/schema/context/spring-context.xsd">
<bean name="./hello.ds" class="controller.Hellocontroller">
</bean>
<bean class="org.springframework.web.servlet.InternalViewResolver">
<property name="prefix" value="/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 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">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>*.ds</url-pattern>
</servlet-mapping>
</web-app>
success.jsp
${msg}
index.jsp
<h1>HelloWorld</h1>
<form action ="./hello.ds">
NAME:<input type = "text" name="name">
SUBMIT<input type = "submit" value="sayHello">
</form>
Errors:
type Exception report
message Servlet.init() for servlet HelloWorld threw exception
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet.init() for servlet HelloWorld threw exception
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501
root cause
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.web.servlet.InternalViewResolver] for bean with name 'org.springframework.web.servlet.InternalViewResolver#0' defined in ServletContext resource [/WEB-INF/HelloWorld-servlet.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.web.servlet.InternalViewResolver
org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1208)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:570)
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1277
There's an error in your configuration. The class org.springframework.web.servlet.InternalViewResolver doesn't exist (could it be you copy/pasted this from an ancient spring mvc example?).
Try replacing it with org.springframework.web.servlet.view.InternalResourceViewResolver. I cannot guarantee it works, but it's worth trying.

#PostConstuct does not appear to work and #autowire gives an error

I am new to spring and am creating a spring web application.
The application I'm writing has a Class PreLoadService. In this class is a method defined with #PostConstruct that calls a DAO to load the data. The DAO instance is declared in the class with the #autowired.
The Controller for the JSP then declares an instance of the PreLoadService and calls the getter to retrieve the data that should have been loaded in the #PostConstruct. The data is never loaded and an exception is also thrown on the #autowired.
Since this did not work I tried a simple Hello World version to write a message and received the same issue. I will post this. In the WEB_INF folder I have a web.xml and a spring3-servlet.xml. In the SRC folder I have an applicationContext.xml. I am running on Tomcat 7.
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>Spring3MVC</display-name>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>root.webpath</param-value>
</context-param>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>spring3</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring3</servlet-name>
<url-pattern>*.html</url-pattern>
<url-pattern>/</url-pattern>
</servlet-mapping></web-app>
spring3-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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
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/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-3.0.xsd">
<!--will allow Spring to load all the components from package and all its child packages-->
<mvc:annotation-driven />
<context:component-scan
base-package="com.nikki.spring3.controller" />
<!-- will resolve the view and add prefix string /WEB-INF/jsp/ and suffix .jsp to the view in ModelAndView. -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
applicationContext.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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
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/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-3.0.xsd">
<mvc:annotation-driven/>
<context:component-scan base-package="com.nikki.spring3">
<context:exclude-filter expression="org.springframework.stereotype.Controller" type="annotation"/>
</context:component-scan>
<bean id="helloWorldService"
class="com.nikki.spring3.beansit.HelloWorldService">
<property name="message" value="Preloading Init Config and Data" />
HelloWorldService
public class HelloWorldService {
private String message;
public void setMessage(String message){
this.message = message;
}
public String getMessage(){
System.out.println("Your Message : " + message);
return message;
}
#PostConstruct
public void init(){
System.out.println("Bean is going through init.");
}
#PreDestroy
public void destroy(){
System.out.println("Bean will destroy now.");
}
}
HelloWorldController
#Controller
public class HelloWorldController {
#Autowired
HelloWorldService helloWorldService;
/* RequestMapping annotation tells Spring that this Controller should
* process all requests beginning with /hello in the URL path.
* That includes /hello/* and /hello.html.
*/
#RequestMapping("/hello")
public ModelAndView helloWorld() {
String message =helloWorldService.getMessage();
//"Hello World, Spring 3.0!";
return new ModelAndView("hello", "message", message);
}
}
Error Message
Exception
SEVERE: StandardWrapper.Throwable org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0':
Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'helloWorldController':
Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException:
Could not autowire field: com.nikki.spring3.beansit.HelloWorldService com.nikki.spring3.controller.HelloWorldController.helloWorldService;
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:
No matching bean of type [com.nikki.spring3.beansit.HelloWorldService] found for dependency:
expected at least 1 bean which qualifies as autowire candidate for this dependency.
Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
I appreciate any help. Thanks.
If you have config files other than xxx-servlet.xml you need to let know spring that these files exists. To do that you have to use contextConfigLocation along with ContextLoadListener. Try to add the following lines in your web.xml. If the applicationContext.xml exists in WEB-INF folder of the project use the following.
<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>
I think you had your applicationContext.xml under src folder. In that case use as below
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext.xml</param-value>
</context-param>
Try creating an interface for HelloWorldService and autowire with that interface in your controller. Spring create bean of proxy of class HelloWorldService, so HelloWorldService itself may not be available to be autowired. Try it.
in your case you want to inject a bean that has not yet created
add #Service
#Service
public class HelloWorldService { ...... }

Setting up Vaadin and Spring 3 - Autowiring fails (annotations)

I'm having some trouble using the #Autowire annotation of spring 3 in a vaadin application.
I have made a tiny test project with just a button which executes a method in an autowired service class.
I'm getting a NullPointerException when I click the button, because the service is never injected.
I have annotated the service with #Service("calculationService")
This is my application class:
package vaadinBaas;
// imports
public class MyVaadinApplication extends Application {
private Window window;
private CalculationService calculationService;
#Autowired
public void setCalculationService(CalculationService calculationService) {
this.calculationService = calculationService;
}
#Override
public void init() {
window = new Window("Show me the magic");
setMainWindow(window);
Button button = new Button("Click Me");
button.addListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
window.addComponent(new Label(String.valueOf(calculationService.multiply(10, 10))));
}
});
window.addComponent(button);
}
}
This is my spring application context:
<?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:ct="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/context
http://www.springframework.org/schema/context/spring-context.xsd">
<ct:component-scan base-package="vaadinBaas" />
<ct:annotation-config />
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>
<bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor"/>
</beans>
And finally 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"
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>Vaadin Web Application</display-name>
<context-param>
<description>Vaadin production mode</description>
<param-name>productionMode</param-name>
<param-value>false</param-value>
</context-param>
<servlet>
<servlet-name>Vaadin Application Servlet</servlet-name>
<servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
<init-param>
<param-name>application</param-name>
<param-value>vaadinBaas.MyVaadinApplication</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Vaadin Application Servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext.xml</param-value>
</context-param>
</web-app>
Am I missing something obvious here?
Try annotating MyVaadinApplication with Component annotation. Since MyVaadinApplication is not considered as spring managed class the Autowire didnt work for you. Also you need to load the bean definition xml using ClassPathXmlApplicationContext and try calling getBean(MyVaadinApplication.class) so that all the autowiring happens automatically

a very simple spring security 3 example don't work?

a very simple spring security 3 example that i found on the net give me a strage ecxeption in jboss!
ecxeption with log:
01:04:19,150 ERROR [ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.SecurityFilterChain#0' while setting bean property 'sourceList' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.SecurityFilterChain#0': Cannot resolve reference to bean 'org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0' while setting constructor argument with key [10]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Unsupported configuration attributes: [USER_NORMAL]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.SecurityFilterChain#0': Cannot resolve reference to bean 'org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0' while setting constructor argument with key [10]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Unsupported configuration attributes: [USER_NORMAL]
01:04:19,152 ERROR [[/SinaP]] Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.SecurityFilterChain#0' while setting bean property 'sourceList' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.SecurityFilterChain#0': Cannot resolve reference to bean 'org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0' while setting constructor argument with key [10]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Unsupported configuration attributes: [USER_NORMAL]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
01:04:19,152 ERROR [[/SinaP]] Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.SecurityFilterChain#0' while setting bean property 'sourceList' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.SecurityFilterChain#0': Cannot resolve reference to bean 'org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0' while setting constructor argument with key [10]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Unsupported configuration attributes: [USER_NORMAL]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
Caused by: java.lang.IllegalArgumentException: Unsupported configuration attributes: [USER_NORMAL]
01:04:19,153 ERROR [StandardContext] Error listenerStart
01:04:19,153 ERROR [StandardContext] Context [/SinaP] startup failed due to previous errors
01:04:19,153 INFO [[/SinaP]] Closing Spring root WebApplicationContext
01:04:19,171 ERROR [AbstractKernelController] Error installing to Start: name=jboss.web.deployment:war=/SinaP state=Create mode=Manual requiredState=Installed
org.jboss.deployers.spi.DeploymentException: URL file:/C:/jboss-IIIII/server/default/tmp/5c4o12-ydfhap-grdgg7xq-1-grdgglsf-9m/SinaP.war/ deployment failed
DEPLOYMENTS IN ERROR:
Deployment "vfszip:/C:/jboss-IIIII/server/default/deploy/SinaP.war/" is in error due to the following reason(s): org.jboss.deployers.spi.DeploymentException: URL file:/C:/jboss-IIIII/server/default/tmp/5c4o12-ydfhap-grdgg7xq-1-grdgglsf-9m/SinaP.war/ deployment failed
my web.xml file :
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" 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>PersianJava</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>Home.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-security.xml
/WEB-INF/spring-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>
<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>/</url-pattern>
</servlet-mapping>
</web-app>
spring security 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:aop="http://www.springframework.org/schema/aop"
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:jms="http://www.springframework.org/schema/jms"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:oxm="http://www.springframework.org/schema/oxm"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.1.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.1.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.1.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd">
<security:authentication-manager>
<security:authentication-provider>
<security:password-encoder hash="md5"></security:password-encoder>
<security:user-service>
<security:user name="sina" password="2253857" authorities="USER_NORMAL"/>
</security:user-service>
</security:authentication-provider>
</security:authentication-manager>
<security:http auto-config="true" access-denied-page="/WEB-INF/denied.jsp" >
<security:intercept-url pattern="/**" access="USER_NORMAL"/>
</security:http>
</beans>
every bit of helps will make me greatfull
Not sure but I think role names in Spring security must start with ROLE_ prefix.
You must set below code:
<bean id="roleVoter" class="org.acegisecurity.vote.RoleVoter">
<property name="rolePrefix" value="ROLE_"/>
</bean>
and start your roles with ROLE_ or any other that you define it to value tag

Resources