0

I am getting this error, when i am deploying my application on WebSphere. It doesn't give me any issues in my local machine.

com.ibm.ws.webcontainer.webapp.WebApp logServletError SRVE0293E: [Servlet Error]-[dispatcher]: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' is defined 
[6/27/16 15:27:50:390 EDT] 000000cd webapp        E com.ibm.ws.webcontainer.webapp.WebApp logServletError SRVE0293E: [Servlet Error]-[dispatcher]: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' is defined

This is 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_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>ActimizeWebService</display-name>
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:spring-security*.xml</param-value>
  </context-param>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/*</url-pattern>
  </servlet-mapping>
  <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>
</web-app>

This is my spring-security.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:security="http://www.springframework.org/schema/security"
    xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/security  http://www.springframework.org/schema/security/spring-security-4.0.xsd
        http://www.springframework.org/schema/security/oauth2   http://www.springframework.org/schema/security/spring-security-oauth2-2.0.xsd">

    <bean id="hellorestprojectSecurityProperties"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location" value="file:///${propertyFile}" />
    </bean>

    <security:http create-session="never" use-expressions="true"
        entry-point-ref="oauthAuthenticationEntryPoint" 
        authentication-manager-ref="oauthAuthenticationManager"
        xmlns="http://www.springframework.org/schema/security">
        <security:anonymous enabled="false" />
        <security:csrf disabled="true" />
        <security:intercept-url pattern="/**" access="permitAll" />
        <security:custom-filter ref="resourceServerFilter"
            before="PRE_AUTH_FILTER" />
        <security:access-denied-handler ref="oauthAccessDeniedHandler" />
    </security:http>

    <bean id="oauthAccessDeniedHandler"
        class="org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler" />

    <bean id="oauthAuthenticationManager"
        class="org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationManager">
        <property name="tokenServices" ref="tokenServices" />
    </bean>

    <oauth:resource-server id="resourceServerFilter"
        resource-id="hellorestproject-resources" token-services-ref="tokenServices" />

    <bean id="tokenServices"
        class="com.mypackage.hellorestproject.security.CustomRemoteTokenServices">
        <property name="tokenStore" ref="tokenStore" />
        <property name="checkTokenEndpointUrl" value="${checkTokenEndpointUrl}" />
        <property name="accessTokenConverter" ref="accessTokenConverter" />
    </bean>

    <bean id="accessTokenConverter"
        class="com.mypackage.hellorestproject.security.CustomAccessTokenConverter" />

    <bean id="tokenStore"
        class="org.springframework.security.oauth2.provider.token.store.InMemoryTokenStore" />

    <bean id="oauthAuthenticationEntryPoint"
        class="org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint ">
        <property name="realmName" value="test" />
    </bean>
</beans>

Please help me figuring out the issue. Thanks !!

Nick M
  • 91
  • 1
  • 3
  • Don't you need to add the springSecurityFilterChain filter to you web.xml as describe in http://docs.spring.io/spring-security/site/docs/3.1.x/reference/security-filter-chain.html and other stack overflow questions like http://stackoverflow.com/questions/12123516/getting-exception-no-bean-named-springsecurityfilterchain-is-defined – creechy Jun 27 '16 at 23:53
  • Figured the issue, my springSecurity xml path was incorrect and hence the springSecurity XML was not getting picked up – Nick M Jul 17 '16 at 21:57

0 Answers0