Results 1 to 7 of 7

Thread: Spring Security on Websphere 7 throws Servlet Exception: Failed to initialize Filter

  1. #1

    Unhappy Spring Security on Websphere 7 throws Servlet Exception: Failed to initialize Filter

    I have an application bundled with Spring Security and it works perfectly when deployed on a Tomcat server.

    However, when the same WAR is deployed to Websphere; application fails to start giving the following error.

    Code:
    javax.servlet.ServletException: [springSecurityFilterChain]: Could not be initialized.
    The status of the application in Websphere shows deployed and started.

    Using Spring Security 3.0.7 and Websphere 7.0.0.17

    Here's my web.xml

    Code:
    <!-- Spring Security configuration Start-->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/app-servlet.xml,
            /WEB-INF/security-app-context.xml
        </param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <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>
    <!-- Spring Security configuration End-->
    I am using PreAuth Filter for Siteminder. Here's my security-app-context.xml:

    Code:
     <http  use-expressions="true">
            <intercept-url pattern="/admin/**" access="hasRole('ROLE_ADMIN')" />
            <intercept-url pattern="/403.jsp" access="permitAll" />
            <!-- Allow non-secure access to static resources  -->
            <intercept-url pattern="/css/**" filters="none" />
            <intercept-url pattern="/images/**" filters="none" />
    
            <custom-filter ref="siteminderFilter" position="PRE_AUTH_FILTER"/>
    
    <!--        <form-login  /> -->
            <logout logout-success-url="/index.jsp"/>
        </http>
    
        <beans:bean id="siteminderFilter" class="org.springframework.security.web.authentication.preauth.RequestHeaderAuthenticationFilter">
            <beans:property name="principalRequestHeader" value="SM_USER"/>
            <beans:property name="authenticationManager" ref="authenticationManager" />
            <beans:property name="exceptionIfHeaderMissing" value="false"/>
        </beans:bean>
    
        <beans:bean id="AdminUserDetailsService" class="com.fw.security.auth.MyUserDetailsService">
        </beans:bean>
    
        <beans:bean id="preauthAuthProvider" class="org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider">
            <beans:property name="preAuthenticatedUserDetailsService">
                <beans:bean id="userDetailsServiceWrapper" class="org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper">
                    <beans:property name="userDetailsService" ref="AdminUserDetailsService"/>
                </beans:bean>
            </beans:property>
        </beans:bean>
    
        <authentication-manager alias="authenticationManager">
          <authentication-provider ref="preauthAuthProvider" />
        </authentication-manager>
    Last edited by nirmaljpatel; Nov 24th, 2011 at 02:12 AM. Reason: correct version number

  2. #2
    Join Date
    Oct 2008
    Location
    Poland, Wrocław
    Posts
    424

    Default

    Hi

    First, try setting "com.ibm.ws.webcontainer.invokefilterscompatibilit y = true" in "Application Servers -> server1 -> WWW Container -> Custom properties".

    Then we'll see

    regards
    Grzegorz Grzybek

  3. #3

    Default

    I did run into this on one of the forum threads... where this solved the issue for Websphere 6.

    Anyhow I configured on my server - websphere 7... but still no joy...

    Any further suggestions/pointers?

    Quote Originally Posted by Grzegorz Grzybek View Post
    Hi

    First, try setting "com.ibm.ws.webcontainer.invokefilterscompatibilit y = true" in "Application Servers -> server1 -> WWW Container -> Custom properties".

    Then we'll see

    regards
    Grzegorz Grzybek

  4. #4
    Join Date
    Oct 2008
    Location
    Poland, Wrocław
    Posts
    424

    Default

    OK, then it's not invokefilterscompatibility

    I had similar issue, but the problem was I've used servlet-api 2.5 on WebSphere 6. Maybe you're using servlet-api 3 on WebSphere 7? Did WebSphere logged something into SystemOut/Err.log?

  5. #5
    Join Date
    Jan 2008
    Posts
    1,826

    Default

    Quote Originally Posted by nirmaljpatel View Post
    I
    Code:
    javax.servlet.ServletException: [springSecurityFilterChain]: Could not be initialized.
    If you see an error like this it means you should turn logging all the way up and see what errors are produced at startup.

    PS: To avoid vulnerabilities and other unfixed bugs, you may want to update to the latest Spring Security release (3.0.7.RELEASE). When doing so I would also check to see you are the latest Spring version (3.0.6.RELEASE).
    Rob Winch - @rob_winch
    Spring Security Lead
    Pivotal

  6. #6

    Default

    Quote Originally Posted by rwinch View Post
    If you see an error like this it means you should turn logging all the way up and see what errors are produced at startup.

    PS: To avoid vulnerabilities and other unfixed bugs, you may want to update to the latest Spring Security release (3.0.7.RELEASE). When doing so I would also check to see you are the latest Spring version (3.0.6.RELEASE).
    I guess I mixed up in the OP, I am using Spring 3.0.3 and Spring Security 3.0.7.

  7. #7

    Default

    A closer look at the System.err logs revealed that there was a BeanCreationException resulting from a mis-configured Datasource.

    Code:
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R javax.servlet.ServletException: Filter [springSecurityFilterChain]: could not be initialized
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R 	at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.init(FilterInstanceWrapper.java:154)
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R 	at com.ibm.ws.webcontainer.filter.WebAppFilterManager._loadFilter(WebAppFilterManager.java:548)
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R 	at com.ibm.ws.webcontainer.filter.WebAppFilterManager.loadFilter(WebAppFilterManager.java:462)
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R 	at com.ibm.ws.webcontainer.filter.WebAppFilterManager.getFilterInstanceWrapper(WebAppFilterManager.java:319)
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R 	at com.ibm.ws.webcontainer.filter.WebAppFilterManager.getFilterChain(WebAppFilterManager.java:379)
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R 	at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:860)
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R 	at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:997)
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R 	at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.invokeFilters(DefaultExtensionProcessor.java:1043)
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R 	at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:740)
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R 	at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3933)
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R 	at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R 	at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:931)
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R 	at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R 	at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186)
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R 	at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R 	at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R 	at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R 	at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R 	at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R 	at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:816)
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R 	at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R 	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1604)
    [11/23/11 15:24:09:611 EST] 000000db SystemErr     R Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'adminManagementController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.myc.myapp.service.PinManagementService com.myc.myapp.controller.AdminManagementController.pinManagementService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pinManagementServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.myc.myapp.dao.PinManagementDAO com.myc.myapp.service.PinManagementServiceImpl.pinManagementDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pinManagementDAOImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void com.myc.myapp.dao.PinManagementDAOImpl.init(javax.sql.DataSource); nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [javax.sql.DataSource] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
    Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Context: Cell01/clusters/mSharedCluster, name: jdbc/com.myc.myapp.PIN_DS: First component in name com.myc.myapp.PIN_DS not found. [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]

    Solving this configuration issue fixed the problem.
    Last edited by nirmaljpatel; Nov 24th, 2011 at 05:02 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •