Marek Banach

Marek Banach programista, x

Temat: Spring securty - xml

Witam,

Poraz pierwszy stykam się z Spring Security. Korzystam z Mavena tomcat 6. Podczas polecenia tomcat:deploy pojawił się błąd:

SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 13 in XML document from ServletContext resource [/WEB-INF/spring/spring-security.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.

Konfiguracja spring-security.xml

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

<beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-bea...
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-...
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util...">

<http pattern="/resources" security="none" />

<http auto-config="true" use-expressions="true">
<intercept-url pattern="/login" access="permitAll"/>
<intercept-url pattern="/logout" access="permitAll"/>
<intercept-url pattern="/denied" access="hasRole('ROLE_USER')"/>
<intercept-url pattern="/" access="hasRole('ROLE_USER')"/>
<intercept-url pattern="/user" access="hasRole('ROLE_USER')"/>
<intercept-url pattern="/admin" access="hasRole('ROLE_ADMIN')"/>

<form-login login-page="/login"
authentication-failure-url="/login/failure"
default-target-url="/"/>

<access-denied-handler error-page="/denied"/>

<logout invalidate-session="true"
logout-success-url="/logout/success"
logout-url="/logout"/>
</http>

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

Proszę o pomoc. Nie wiem jak to "ładnie" rozwiązać.

konto usunięte

Temat: Spring securty - xml

Hej,

"beans" w Twoim przypadku nie jest domyślnym namespacem (o czym świadczy deklaracja namespace'a xmlns:beans), więc musisz się odnosić do atrybutów beans tak:

<beans:beans ..../>, a nie <beans ... />Michał B. edytował(a) ten post dnia 15.04.12 o godzinie 15:58
Marek Banach

Marek Banach programista, x

Temat: Spring securty - xml

Dzięki za odpowiedź. Nie wiem jak to się stało ale odświeżyłem wszystko, nic nie zmieniłem i wyskoczył taki błąd:

SEVERE: 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#1' while setting bean property 'sourceList' with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#1': Cannot resolve reference to bean 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0' while setting constructor argument with key [2]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0': Cannot resolve reference to bean 'org.springframework.security.authentication.ProviderManager#0' while setting bean property 'authenticationManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authentication.ProviderManager#0': Cannot resolve reference to bean 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authenticationManager': Cannot resolve reference to bean 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0': Cannot resolve reference to bean 'customUserDetailsService' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customUserDetailsService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private pl.photointegrator.dao.interfaces.UserDao pl.photointegrator.service.CustomUserDetailsService.dao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateUserDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.hibernate.SessionFactory pl.photointegrator.dao.implementation.hibernate.HibernateUserDao.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/spring/data-access-context.xml]: Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError: class org.hibernate.cfg.ExtendedMappings has interface org.hibernate.cfg.Mappings as super class
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:353)

...

konto usunięte

Temat: Spring securty - xml

Szukałbym tutaj:
[/WEB-INF/spring/data-access-context.xml]: Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError: class org.hibernate.cfg.ExtendedMappings has interface org.hibernate.cfg.Mappings as super class

Korzystasz z jakichś niekompatybilnych implementacji.
Marek Banach

Marek Banach programista, x

Temat: Spring securty - xml

hibernate-annotations jest nadmiarowe. Od wersji 3.6.0 hibernate'a zostało zintegrowane do hibernate-core. Po usunięciu hibernate-annotations błąd zniknął.

Dzięki za udział w dyskusji.

Następna dyskusja:

Spring JavaConfig




Wyślij zaproszenie do