2017-04-19 6 views
1

JSF 2.2.7アプリケーションを開発していますが、Spring Security 4.0.3を統合しようとしています。use-expressionsをtrueに設定すると、Spring Security 4でエラーが発生します

なぜ私はuse-expressionsをtrueに設定すると、私にエラーが発生するのですか?私はそれをfalseにすると、正常に動作し、私は自分のアプリケーションを読み込むことができます。

誰かが私にこれを理解させる助けになることができますか?私はhttp://www.baeldung.com/no-bean-named-springsecurityfilterchain-is-definedを読んで、エラーを解決するために、私のファイルを変更しようとしましたが、私は何かを見逃している必要があり、私はまだ同じ問題を抱えているので...している:/

ここに私のログです:

GRAVE: Exception starting filter springSecurityFilterChain 
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' is defined 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:698) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1175) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:284) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) 
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1060) 
    at org.springframework.web.filter.DelegatingFilterProxy.initDelegate(DelegatingFilterProxy.java:326) 
    at org.springframework.web.filter.DelegatingFilterProxy.initFilterBean(DelegatingFilterProxy.java:235) 
    at org.springframework.web.filter.GenericFilterBean.init(GenericFilterBean.java:199) 
    at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279) 
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260) 
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105) 
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4581) 
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5223) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1439) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1429) 
    at java.util.concurrent.FutureTask.run(Unknown Source) 
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) 
    at java.util.concurrent.AbstractExecutorService.submit(Unknown Source) 
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:953) 
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1439) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1429) 
    at java.util.concurrent.FutureTask.run(Unknown Source) 
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) 
    at java.util.concurrent.AbstractExecutorService.submit(Unknown Source) 
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:953) 
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) 
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) 
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) 
    at org.apache.catalina.startup.Catalina.start(Catalina.java:655) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:355) 
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:495) 

GRAVE: 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.DefaultSecurityFilterChain#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.DefaultSecurityFilterChain#0': Cannot resolve reference to bean 'org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0' while setting constructor argument with key [11]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0': Cannot create inner bean '(inner bean)#5f430c5a' of type [org.springframework.security.web.access.expression.ExpressionBasedFilterInvocationSecurityMetadataSource] while setting bean property 'securityMetadataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#5f430c5a': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.access.expression.ExpressionBasedFilterInvocationSecurityMetadataSource]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Failed to parse expression 'ROLE_ADMIN,ROLE_PROFESSOR' 
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359) 
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108) 
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:382) 
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:157) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1481) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1226) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:753) 
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) 
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444) 
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326) 
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) 
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4735) 
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5197) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1439) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1429) 
    at java.util.concurrent.FutureTask.run(Unknown Source) 
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) 
    at java.util.concurrent.AbstractExecutorService.submit(Unknown Source) 
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:953) 
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1439) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1429) 
    at java.util.concurrent.FutureTask.run(Unknown Source) 
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) 
    at java.util.concurrent.AbstractExecutorService.submit(Unknown Source) 
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:953) 
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) 
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) 
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) 
    at org.apache.catalina.startup.Catalina.start(Catalina.java:655) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:355) 
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:495) 
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#0': Cannot resolve reference to bean 'org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0' while setting constructor argument with key [11]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0': Cannot create inner bean '(inner bean)#5f430c5a' of type [org.springframework.security.web.access.expression.ExpressionBasedFilterInvocationSecurityMetadataSource] while setting bean property 'securityMetadataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#5f430c5a': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.access.expression.ExpressionBasedFilterInvocationSecurityMetadataSource]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Failed to parse expression 'ROLE_ADMIN,ROLE_PROFESSOR' 
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359) 
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108) 
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:382) 
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:157) 
    at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:634) 
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:140) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1143) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1046) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) 
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351) 
    ... 47 more 
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0': Cannot create inner bean '(inner bean)#5f430c5a' of type [org.springframework.security.web.access.expression.ExpressionBasedFilterInvocationSecurityMetadataSource] while setting bean property 'securityMetadataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#5f430c5a': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.access.expression.ExpressionBasedFilterInvocationSecurityMetadataSource]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Failed to parse expression 'ROLE_ADMIN,ROLE_PROFESSOR' 
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:313) 
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:129) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1481) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1226) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) 
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351) 
    ... 61 more 
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#5f430c5a': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.access.expression.ExpressionBasedFilterInvocationSecurityMetadataSource]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Failed to parse expression 'ROLE_ADMIN,ROLE_PROFESSOR' 
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:275) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1143) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1046) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) 
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:299) 
    ... 71 more 
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.access.expression.ExpressionBasedFilterInvocationSecurityMetadataSource]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Failed to parse expression 'ROLE_ADMIN,ROLE_PROFESSOR' 
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163) 
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:122) 
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:267) 
    ... 76 more 
Caused by: java.lang.IllegalArgumentException: Failed to parse expression 'ROLE_ADMIN,ROLE_PROFESSOR' 
    at org.springframework.security.web.access.expression.ExpressionBasedFilterInvocationSecurityMetadataSource.processMap(ExpressionBasedFilterInvocationSecurityMetadataSource.java:61) 
    at org.springframework.security.web.access.expression.ExpressionBasedFilterInvocationSecurityMetadataSource.<init>(ExpressionBasedFilterInvocationSecurityMetadataSource.java:33) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) 
    at java.lang.reflect.Constructor.newInstance(Unknown Source) 
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147) 
    ... 78 more 

マイファイル:

web.xmlの

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee" xmlns:web="http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" 
    version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee"> 
    <display-name>Archetype Created Web 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> 
     <dispatcher>FORWARD</dispatcher> 
     <dispatcher>REQUEST</dispatcher> 
    </filter-mapping> 

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

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

    <listener> 
     <listener-class> 
      org.springframework.web.context.request.RequestContextListener 
     </listener-class> 
    </listener> 

    <context-param> 
     <param-name>contextConfigLocation</param-name> 
     <param-value>/WEB-INF/applicationContext*.xml</param-value> 
    </context-param> 

    <context-param> 
     <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL 
     </param-name> 
     <param-value>true</param-value> 
    </context-param> 

    <context-param> 
     <param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE 
     </param-name> 
     <param-value>true</param-value> 
    </context-param 
    > 
    <context-param> 
     <param-name>javax.faces.SERIALIZE_SERVER_STATE</param-name> 
     <param-value>true</param-value> 
    </context-param> 

    <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>/faces/*</url-pattern> 
    </servlet-mapping> 

    <servlet-mapping> 
     <servlet-name>Faces Servlet</servlet-name> 
     <url-pattern>*.xhtml</url-pattern> 
    </servlet-mapping> 

    <servlet-mapping> 
     <servlet-name>Faces Servlet</servlet-name> 
     <url-pattern>*.jsf</url-pattern> 
    </servlet-mapping> 

</web-app> 

のApplicationContext-のsecurity.xml
<?xml version="1.0" encoding="UTF-8"?> 
<beans:beans xmlns:sec="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-3.1.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.0.xsd"> 
    <sec:http auto-config="true" use-expressions="true"> 

     <sec:intercept-url pattern="/templates/cadastroProfessor.xhtml" 
      access="ROLE_ADMIN" /> 
     <sec:intercept-url pattern="/templates/cadastroAula.xhtml" 
      access="ROLE_ADMIN" /> 
     <sec:intercept-url pattern="/templates/cadastroMateria.xhtml" 
      access="ROLE_ADMIN" /> 
     <sec:intercept-url pattern="/templates/exibirProfessor.xhtml" 
      access="ROLE_ADMIN" /> 
     <sec:intercept-url pattern="/templates/exibirMateria.xhtml" 
      access="ROLE_ADMIN,ROLE_PROFESSOR" /> 
     <!-- <sec:intercept-url pattern="/pessoa/**" access="ROLE_USER" /> --> 
     <sec:form-login login-page="/login.jsf" 
      login-processing-url="/j_spring_security_check" 
      authentication-failure-url="/login.jsf?erro=true" /> 
     <sec:csrf disabled="true" /> 
    </sec:http> 


    <sec:authentication-manager alias="authenticationManager"> 
     <sec:authentication-provider 
      user-service-ref="segurancaService"> 

     </sec:authentication-provider> 
    </sec:authentication-manager> 
</beans:beans> 

applicationContext.xmlを

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:p="http://www.springframework.org/schema/p" 
    xmlns:tx="http://www.springframework.org/schema/tx" 
    xmlns:jpa="http://www.springframework.org/schema/data/jpa" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd 
     http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd 
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> 

    <context:component-scan base-package="br.com.redefatec"/> 

    <jpa:repositories base-package="br.com.redefatec.repository"/> 

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

    <bean id="entityManagerFactory" 
     class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" 
     p:packagesToScan="br.com.redefatec.model" 
     p:dataSource-ref="dataSource" 
     > 
     <property name="jpaVendorAdapter"> 
      <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> 
       <property name="generateDdl" value="false" /> 
       <property name="showSql" value="true" /> 
       <property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect"/> 
      </bean> 
     </property> 
    </bean> 

    <bean id="transactionManager" 
     class="org.springframework.orm.jpa.JpaTransactionManager"> 
     <property name="entityManagerFactory" ref="entityManagerFactory" /> 

    </bean> 

    <tx:annotation-driven /> 

</beans> 

答えて

1

問題があるあなたがuse-expressionstrueには、春のセキュリティは、あなたはまだだけでロール名を持っている一方で、式としてaccess属性の値を解釈を開始したときに、その表現ではありません。

access="<role-name>"access="hasRole('<role-name>')"に変更してみてください。

例えば、マルチロールアクセスの場合

<sec:intercept-url pattern="/templates/cadastroProfessor.xhtml" 
     access="hasRole('ROLE_ADMIN')" /> 

<sec:intercept-url pattern="/templates/cadastroProfessor.xhtml" 
     access="ROLE_ADMIN" /> 

置き換え、hasAnyRoleがあります:

<sec:intercept-url pattern="/templates/exibirMateria.xhtml" 
     access="ROLE_ADMIN,ROLE_PROFESSOR" /> 

あなたは

を記述する必要が代わりに
関連する問題