2014-09-11 56 views
3

我想通過參考下面的鏈接繼續對Spring的web服務實現認證/:java.lang.NoClassDefFoundError:組織/ springframework的/安全認證/ AuthenticationManager會

http://docs.spring.io/spring-ws/site/reference/html/security.html

以下是配置我已經加入:

<bean 
     class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping"> 
     <property name="interceptors"> 
      <list> 
       <ref local="wsServerSecurityInterceptor" /> 
       <ref local="payloadValidatingIterceptor" /> 
      </list> 
     </property> 
    </bean> 
    <bean id="wsServerSecurityInterceptor" 
     class="org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor"> 
     <property name="policyConfiguration" 
      value="classpath:security/xwss/security-server-policy.xml" /> 
     <property name="callbackHandlers"> 
      <list> 
       <!-- <ref bean="keyStoreHandlerServer" /> --> 
       <ref bean="springSecurityHandler" /> 
       <ref bean="callbackHandlerServer" /> 
      </list> 
     </property> 
    </bean> 
    <bean id="springSecurityHandler" 
     class="org.springframework.ws.soap.security.xwss.callback.SpringPlainTextPasswordValidationCallbackHandler"> 
    <property name="authenticationManager" ref="authenticationManager"/> 
    </bean> 
    <bean id="authenticationManager" class="org.springframework.security.providers.ProviderManager"> 
     <property name="providers"> 
     <list> 
    <ref local="authenticationProvider" /> 
    </list>   
    </property> 
    </bean> 
    <bean id="authenticationProvider" 
    class="org.springframework.security.providers.dao.DaoAuthenticationProvider"> 
       <property name="userDetailsService" ref="userDetailsService"/> 
      </bean> 
    <bean id="userDetailsService" class="com.impl.endpoints.calc.client.JpaUserDetailsService" /> 

雖然部署在服務器上的war文件,我得到以下錯誤:

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.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping#0' defined in ServletContext resource [/WEB-INF/xws-spring-ws-servlet.xml]: Cannot resolve reference to bean 'wsServerSecurityInterceptor' while setting bean property 'interceptors' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'wsServerSecurityInterceptor' defined in ServletContext resource [/WEB-INF/xws-spring-ws-servlet.xml]: Cannot resolve reference to bean 'springSecurityHandler' while setting bean property 'callbackHandlers' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityHandler' defined in ServletContext resource [/WEB-INF/xws-spring-ws-servlet.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/security/authentication/AuthenticationManager 
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329) 
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107) 
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:353) 
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:154) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1387) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1128) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) 

org/springframework/security/authentication/AuthenticationManager在配置或代碼中的任何地方都沒有提及。我想知道在哪裏需要給定的類,以及我需要做什麼配置更改來解決此錯誤。

編輯:

POM包含以下春季安全罐子:

 <dependency> 
     <groupId> 
       org.springframework.security 
       </groupId> 
     <artifactId>spring-security-web</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-core</artifactId> 
     <version>2.0.4</version> 
    </dependency> 

    <dependency> 
     <groupId> 
       org.springframework.security 
       </groupId> 
     <artifactId>spring-security-config</artifactId> 
    </dependency> 

    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-taglibs</artifactId> 
     <version>3.1.7.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-ldap</artifactId> 
     <version>3.1.7.RELEASE</version> 
    </dependency> 

    <dependency> 
     <groupId>org.springframework.ws</groupId> 
     <artifactId>spring-ws-security</artifactId> 
     <version>2.2.0.RELEASE</version> 
     <exclusions> 
      <exclusion> 
       <groupId>com.sun.xml.wsit</groupId> 
       <artifactId>xws-security</artifactId> 
      </exclusion> 
      <exclusion> 
       <groupId>com.sun.xml.wsit</groupId> 
       <artifactId>wsit-rt</artifactId> 
      </exclusion> 
     </exclusions> 
    </dependency> 

回答

6

您在配置中混合使用Spring Security 2和Spring Security 3。對所有Spring Security jar使用相同的(和最新的)版本號。對於spring-security-core罐子版,您的版本爲2.0.4,其他版本的版本爲3.1.7.RELEASE。對所有罐子使用當前發佈版本,並確保當您構建項目時WEB-INF/lib中沒有不同的版本。

包名也改變了API docs 2和使用之間3.如果你需要知道一個類是在什麼包。

+0

這個答案幫助我注意到'DaoAuthenticationProvider'現在處於不同的包中,'org.springframework.security.authentication.dao'。 TKS – 2015-04-10 11:48:57

0

下載org.springframework.security.core.jar,並將其添加ロclasspath中。

+0

我已經有了春天的安全核心罐子在我的聚甲醛。我已經添加了當前存在於應用程序中的安全罐的列表。 – user3619997 2014-09-11 06:23:58

+0

@ user3619997如果jar在'WEB-INF/lib'目錄下,你可以看看你的war文件嗎? – Jens 2014-09-11 06:29:12

+0

是的,spring-security-core-2.0.4.jar存在於WAR文件的WEB-INF/lib目錄中 – user3619997 2014-09-11 06:36:14

相關問題