Добавление Spring Security taglib создает ошибки, когда tomcat инициирует бобы


Я работаю над школьным проектом с использованием Spring MVC (Spring 3.0.0).

Теперь все работает так, как должно, пока я не добавлю Spring Security taglib в pom.xml с использованием

<dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>org.springframework.security.taglibs</artifactId>
        <version>${spring.version}</version>
</dependency>

(возможно, стоит отметить, что пока я не добавлю следующее Maven repo, он даже не сможет найти taglib).

<repository>
        <id>com.springsource.repository.bundles.external</id>
        <name>EBR External Release Repository</name>
        <url>http://repository.springsource.com/maven/bundles/external</url>
</repository>

Ошибка, которую я получаю, выглядит следующим образом:

feb 08 2011 19:46:51 ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0': Cannot create inner bean '(inner bean)' 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)#11': Cannot create inner bean '(inner bean)' of type [org.springframework.security.access.SecurityConfig] while setting constructor argument with key [Root bean: class [org.springframework.security.web.access.intercept.RequestKey]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#12': No matching factory method found: factory method 'createSingleAttributeList'
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:281) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:125) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1305) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1067) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:557) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842) [org.springframework.context-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:416) [org.springframework.context-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:261) [org.springframework.web-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:192) [org.springframework.web-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) [org.springframework.web-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135) [catalina.jar:6.0.29]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630) [catalina.jar:6.0.29]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) [catalina.jar:6.0.29]
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) [catalina.jar:6.0.29]
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546) [catalina.jar:6.0.29]
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637) [catalina.jar:6.0.29]
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:563) [catalina.jar:6.0.29]
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:498) [catalina.jar:6.0.29]
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277) [catalina.jar:6.0.29]
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321) [catalina.jar:6.0.29]
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) [catalina.jar:6.0.29]
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) [catalina.jar:6.0.29]
at org.apache.catalina.core.StandardHost.start(StandardHost.java:785) [catalina.jar:6.0.29]
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) [catalina.jar:6.0.29]
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445) [catalina.jar:6.0.29]
at org.apache.catalina.core.StandardService.start(StandardService.java:519) [catalina.jar:6.0.29]
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) [catalina.jar:6.0.29]
at org.apache.catalina.startup.Catalina.start(Catalina.java:581) [catalina.jar:6.0.29]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [na:1.6.0_23]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [na:1.6.0_23]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [na:1.6.0_23]
at java.lang.reflect.Method.invoke(Method.java:597) [na:1.6.0_23]
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) [bootstrap.jar:6.0.29]
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) [bootstrap.jar:6.0.29]
 Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#11': Cannot create inner bean '(inner bean)' of type [org.springframework.security.access.SecurityConfig] while setting constructor argument with key [Root bean: class [org.springframework.security.web.access.intercept.RequestKey]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#12': No matching factory method found: factory method 'createSingleAttributeList'
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:281) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:125) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedMap(BeanDefinitionValueResolver.java:383) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:161) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:586) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:140) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:984) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:886) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:270) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
... 39 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#12': No matching factory method found: factory method 'createSingleAttributeList'
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:502) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:964) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:868) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:270) [org.springframework.beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]
... 49 common frames omitted

У кого-нибудь есть любая идея, что я делаю неправильно? Я рву на себе волосы из-за этого.

1 4

1 ответ:

Ваш artifactId выглядит неправильно, попробуйте это: -

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-taglibs</artifactId>
        <version>${spring.version}</version>
    </dependency>

Это все зависимости, связанные с безопасностью Spring: -

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-core</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>${spring.version}</version>
    </dependency>

Просто к вашему сведению, вам не нужно настраивать этот репозиторий, потому что Spring Security существует в репозитории Maven по умолчанию.