Announcement Announcement Module
Collapse
No announcement yet.
Application context shutting down immediately after initialization Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Application context shutting down immediately after initialization

    I'm trying to add 2-legged oauth 1.0 to a web service. The service was functional when I started. After modifying web.xml, creating applicationContext-security.xml, and adding the necessary jars, it won't come up: Spring closes the root context immediately after it's finished initializing it.

    I'm using framework version 3.0.6, security version 3.1.0, and oauth version 1.0.0.M5.

    I added the following to web.xml:

    Code:
    <filter>
            <filter-name>filterChainProxy</filter-name>
            <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>
    
    <filter-mapping>
            <filter-name>filterChainProxy</filter-name>
            <url-pattern>/*</url-pattern>
    </filter-mapping>
    applicationContext-security.xml contains the following:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans:beans xmlns="http://www.springframework.org/schema/security"
                 xmlns:beans="http://www.springframework.org/schema/beans"
                 xmlns:oauth="http://www.springframework.org/schema/security/oauth"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://www.springframework.org/schema/beans
                                     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                                     http://www.springframework.org/schema/security
                                     http://www.springframework.org/schema/security/spring-security-3.1.xsd
                                     http://www.springframework.org/schema/security/oauth
                                     http://www.springframework.org/schema/security/spring-security-oauth-1.0.xsd">
    
        <authentication-manager alias="authenticationManager"/>
    
        <http entry-point-ref="oAuthEntryPoint">
            <intercept-url pattern="/charges/**" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
            <intercept-url pattern="/compliance/**" access="IS_AUTHENTICATED_FULLY"/>
        </http>
    
        <beans:bean id="oAuthEntryPoint"
                    class="org.springframework.security.oauth.provider.OAuthProcessingFilterEntryPoint"/>
    
        <oauth:provider token-services-ref="tokenServices" consumer-details-service-ref="consumerDetails"/>
    
        <oauth:token-services id="tokenServices"/>
    
        <oauth:consumer-details-service id="consumerDetails">
            <oauth:consumer name="mymii" key="mymii" typeOfSecret="rsa-cert"
                            secret="/WEB-INF/keys/mymii.der" requiredToObtainAuthenticatedToken="false"/>
        </oauth:consumer-details-service>
    
    </beans:beans>
    and you can see the trace output Spring is producing by going to http://thombrando.com/catalina.out.


    Spring logs 3 suspicious messages while initializing the root WebApplicationContext:

    Code:
    2011-12-13 19:01:14,454 TRACE [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Ignoring constructor [public org.springframework.security.authentication.ProviderManager(java.util.List,org.springframework.security.authentication.AuthenticationManager)] of bean 'org.springframework.security.authenticationManager': org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.security.authenticationManager': Unsatisfied dependency expressed through constructor argument with index 1 of type [org.springframework.security.authentication.AuthenticationManager]: Ambiguous constructor argument types - did you specify the correct bean references as constructor arguments?
    ...
    2011-12-13 19:01:14,569 TRACE [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Ignoring constructor [public org.springframework.security.web.session.SessionManagementFilter(org.springframework.security.web.context.SecurityContextRepository,org.springframework.security.web.authentication.session.SessionAuthenticationStrategy)] of bean '(inner bean)#6': org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '(inner bean)#6': Unsatisfied dependency expressed through constructor argument with index 1 of type [org.springframework.security.web.authentication.session.SessionAuthenticationStrategy]: Ambiguous constructor argument types - did you specify the correct bean references as constructor arguments?
    ...
    2011-12-13 19:01:14,870 TRACE [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Ignoring constructor [public org.springframework.security.web.FilterChainProxy(org.springframework.security.web.SecurityFilterChain)] of bean 'org.springframework.security.filterChainProxy': org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.security.filterChainProxy': Unsatisfied dependency expressed through constructor argument with index 0 of type [org.springframework.security.web.SecurityFilterChain]: Could not convert constructor argument value of type [java.util.ArrayList] to required type [org.springframework.security.web.SecurityFilterChain]: Failed to convert value of type 'java.util.ArrayList' to required type 'org.springframework.security.web.SecurityFilterChain'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.util.ArrayList] to required type [org.springframework.security.web.SecurityFilterChain]: no matching editors or conversion strategy found
    Then it tries to initialize the filterChainProxy, and that's where it fails:

    Code:
    2011-12-13 19:01:14,913 INFO [org.springframework.web.context.ContextLoader] - Root WebApplicationContext: initialization completed in 1608 ms
    2011-12-13 19:01:14,918 DEBUG [org.springframework.web.filter.DelegatingFilterProxy] - Initializing filter 'filterChainProxy'
    2011-12-13 19:01:14,922 TRACE [org.springframework.beans.factory.support.DefaultListableBeanFactory] - No bean named 'filterChainProxy' found in org.springframework.beans.factory.support.DefaultListableBeanFactory@1762fc7: defining beans [dataSource,org.springframework.security.authentication.DefaultAuthenticationEventPublisher#0,org.springframework.security.authenticationManager,org.springframework.security.filterChains,org.springframework.security.filterChainProxy,org.springframework.security.web.PortMapperImpl#0,org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0,org.springframework.security.authentication.ProviderManager#0,org.springframework.security.web.context.HttpSessionSecurityContextRepository#0,org.springframework.security.web.authentication.session.SessionFixationProtectionStrategy#0,org.springframework.security.web.savedrequest.HttpSessionRequestCache#0,org.springframework.security.access.vote.AffirmativeBased#0,org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0,org.springframework.security.web.access.DefaultWebInvocationPrivilegeEvaluator#0,org.springframework.security.authentication.AnonymousAuthenticationProvider#0,org.springframework.security.userDetailsServiceFactory,org.springframework.security.web.DefaultSecurityFilterChain#0,oAuthEntryPoint,oauthVerifierServices,oauthSuccessfulAuthenticationHandler,oauthRequestTokenFilter,oauthAuthenticateTokenFilter,oauthAccessTokenFilter,oauthProtectedResourceFilter,tokenServices,consumerDetails]; root of factory hierarchy
    2011-12-13 19:01:14,927 INFO [org.springframework.web.context.support.XmlWebApplicationContext] - Closing Root WebApplicationContext: startup date [Tue Dec 13 19:01:13 EST 2011]; root of context hierarchy
    Any help would be greatly appreciated. I've tried this with different versions of the framework, security, and oauth, with the same results.

    Thanks.

    Thom

  • #2
    I tried your config file and it loaded cleanly for me. Do you have some rogue, older jar files on your classpath by mistake or something?

    Comment


    • #3
      The app's WEB-INF/lib directory contains the following jars:

      Code:
      -rw-rw-r-- 1 tcservd tcservd  232771 Dec 13 18:53 commons-codec-1.6.jar
      -rw-rw-r-- 1 tcservd tcservd  160519 Dec 13 18:53 commons-dbcp-1.4.jar
      -rw-rw-r-- 1 tcservd tcservd  163151 Dec 13 18:53 commons-io-2.1.jar
      -rw-rw-r-- 1 tcservd tcservd   60841 Dec 13 18:53 commons-logging-1.1.1.jar
      -rw-rw-r-- 1 tcservd tcservd  100472 Dec 13 18:53 commons-pool-1.5.6.jar
      -rw-rw-r-- 1 tcservd tcservd 1012446 Dec 13 18:53 jackson-all-1.8.5.jar
      -rw-rw-r-- 1 tcservd tcservd  896587 Dec 13 18:53 jaxb-impl.jar
      -rw-rw-r-- 1 tcservd tcservd  481534 Dec 13 18:53 log4j-1.2.16.jar
      -rw-rw-r-- 1 tcservd tcservd  321428 Dec 13 18:53 org.springframework.aop-3.0.6.RELEASE.jar
      -rw-rw-r-- 1 tcservd tcservd   53082 Dec 13 18:53 org.springframework.asm-3.0.6.RELEASE.jar
      -rw-rw-r-- 1 tcservd tcservd   35557 Dec 13 18:53 org.springframework.aspects-3.0.6.RELEASE.jar
      -rw-rw-r-- 1 tcservd tcservd  556590 Dec 13 18:53 org.springframework.beans-3.0.6.RELEASE.jar
      -rw-rw-r-- 1 tcservd tcservd  670258 Dec 13 18:53 org.springframework.context-3.0.6.RELEASE.jar
      -rw-rw-r-- 1 tcservd tcservd  101450 Dec 13 18:53 org.springframework.context.support-3.0.6.RELEASE.jar
      -rw-rw-r-- 1 tcservd tcservd  382184 Dec 13 18:53 org.springframework.core-3.0.6.RELEASE.jar
      -rw-rw-r-- 1 tcservd tcservd  169752 Dec 13 18:53 org.springframework.expression-3.0.6.RELEASE.jar
      -rw-rw-r-- 1 tcservd tcservd    1810 Dec 13 18:53 org.springframework.instrument-3.0.6.RELEASE.jar
      -rw-rw-r-- 1 tcservd tcservd    5727 Dec 13 18:53 org.springframework.instrument.tomcat-3.0.6.RELEASE.jar
      -rw-rw-r-- 1 tcservd tcservd  386033 Dec 13 18:53 org.springframework.jdbc-3.0.6.RELEASE.jar
      -rw-rw-r-- 1 tcservd tcservd  185408 Dec 13 18:53 org.springframework.jms-3.0.6.RELEASE.jar
      -rw-rw-r-- 1 tcservd tcservd  334743 Dec 13 18:53 org.springframework.orm-3.0.6.RELEASE.jar
      -rw-rw-r-- 1 tcservd tcservd   61379 Dec 13 18:53 org.springframework.oxm-3.0.6.RELEASE.jar
      -rw-rw-r-- 1 tcservd tcservd  205276 Dec 13 18:53 org.springframework.test-3.0.6.RELEASE.jar
      -rw-rw-r-- 1 tcservd tcservd  231913 Dec 13 18:53 org.springframework.transaction-3.0.6.RELEASE.jar
      -rw-rw-r-- 1 tcservd tcservd  398149 Dec 13 18:53 org.springframework.web-3.0.6.RELEASE.jar
      -rw-rw-r-- 1 tcservd tcservd  175647 Dec 13 18:53 org.springframework.web.portlet-3.0.6.RELEASE.jar
      -rw-rw-r-- 1 tcservd tcservd  419488 Dec 13 18:53 org.springframework.web.servlet-3.0.6.RELEASE.jar
      -rw-rw-r-- 1 tcservd tcservd   31404 Dec 13 18:53 org.springframework.web.struts-3.0.6.RELEASE.jar
      -rw-rw-r-- 1 tcservd tcservd  202754 Dec 13 18:53 spring-security-config-3.1.0.RELEASE.jar
      -rw-rw-r-- 1 tcservd tcservd  348567 Dec 13 18:53 spring-security-core-3.1.0.RELEASE.jar
      -rw-rw-r-- 1 tcservd tcservd  157793 Dec 13 18:53 spring-security-oauth-1.0.0.M5.jar
      -rw-rw-r-- 1 tcservd tcservd  255577 Dec 13 18:53 spring-security-web-3.1.0.RELEASE.jar
      Plus, tomcat's lib directory contains the following jar:

      Code:
      -rwx------ 1 tcservd tcservd 1988051 Oct 28  2010 ojdbc6.jar

      Comment


      • #4
        Can you try it with the latest Spring Security OAuth code? It still works for me.

        Comment


        • #5
          Later than 1.0.0.M5? That's the latest version available for download.

          Comment


          • #6
            Snapshots are built every night (http://shrub.appspot.com/maven.sprin...ecurity-oauth/). Instructions for how to get them using Maven are on the wiki (https://github.com/SpringSource/spri...wiki/downloads), and the same co-ordinates can be used for ivy, gradle etc I believe. Or you can clone from github and build it yourself.
            Last edited by Dave Syer; Dec 16th, 2011, 01:48 AM. Reason: Add link

            Comment


            • #7
              I replaced spring-security-oauth-1.0.0.M5.jar with spring-security-oauth-1.0.0.BUILD-20111216.120012-419.jar and got the same result. Spring's trace output is at http://thombrando.com/catalina.out-20111216.

              I should've mentioned earlier that I'm running in a tc Server that's running tomcat-6.0.20.C. I just found the following libraries in the shared tomcat-6.020.C/lib directory:

              Code:
              -rw-rw-r-- 1 tcservd tcservd   10796 Mar 30  2010 annotations-api.jar
              -rw-rw-r-- 1 tcservd tcservd  114926 Mar 30  2010 aspectjrt.jar
              -rw-rw-r-- 1 tcservd tcservd   49045 Mar 30  2010 catalina-ant.jar
              -rw-rw-r-- 1 tcservd tcservd  123858 Mar 30  2010 catalina-ha.jar
              -rw-rw-r-- 1 tcservd tcservd 1147169 Mar 30  2010 catalina.jar
              -rw-rw-r-- 1 tcservd tcservd  230267 Mar 30  2010 catalina-tribes.jar
              -rw-rw-r-- 1 tcservd tcservd   15518 Mar 30  2010 com.springsource.javax.transaction-1.1.0.jar
              -rw-rw-r-- 1 tcservd tcservd   99099 Mar 30  2010 com.springsource.json-1.0.2.CI-R29-B5.jar
              -rw-rw-r-- 1 tcservd tcservd   78212 Mar 30  2010 com.springsource.org.objectweb.howl-1.0.2.jar
              -rw-rw-r-- 1 tcservd tcservd   38342 Mar 30  2010 com.springsource.transaction.core-1.0.0.CI-B1.jar
              -rw-rw-r-- 1 tcservd tcservd   10062 Mar 30  2010 com.springsource.transaction.log-1.0.0.CI-B1.jar
              -rw-rw-r-- 1 tcservd tcservd   17009 Mar 30  2010 com.springsource.util.common-1.5.0.CI-R100-B29.jar
              -rw-rw-r-- 1 tcservd tcservd   27803 Mar 30  2010 el-api.jar
              -rw-rw-r-- 1 tcservd tcservd  103165 Mar 30  2010 jasper-el.jar
              -rw-rw-r-- 1 tcservd tcservd  532792 Mar 30  2010 jasper.jar
              -rw-rw-r-- 1 tcservd tcservd 1395255 Mar 30  2010 jasper-jdt.jar
              -rw-rw-r-- 1 tcservd tcservd   76594 Mar 30  2010 jsp-api.jar
              -rw-rw-r-- 1 tcservd tcservd   88187 Mar 30  2010 servlet-api.jar
              -rw-rw-r-- 1 tcservd tcservd  102046 Mar 30  2010 tcServer.jar
              -rw-rw-r-- 1 tcservd tcservd  191750 Mar 30  2010 tcserver-serviceability.jar
              -rw-rw-r-- 1 tcservd tcservd  750523 Mar 30  2010 tomcat-coyote.jar
              -rw-rw-r-- 1 tcservd tcservd  197434 Mar 30  2010 tomcat-dbcp.jar
              -rw-rw-r-- 1 tcservd tcservd   66129 Mar 30  2010 tomcat-i18n-es.jar
              -rw-rw-r-- 1 tcservd tcservd   43727 Mar 30  2010 tomcat-i18n-fr.jar
              -rw-rw-r-- 1 tcservd tcservd   49009 Mar 30  2010 tomcat-i18n-ja.jar
              -rw-rw-r-- 1 tcservd tcservd   87705 Mar 30  2010 tomcat-jdbc.jar
              Last edited by ThomBrando; Dec 16th, 2011, 11:40 AM.

              Comment


              • #8
                There's nothing wrong with your Spring configuration. But your web.xml must have the wrong bean name for the filter - <http> creates an alias called "springSecurityFilterChain", and yours is looking for "filterChainProxy".
                Last edited by Dave Syer; Dec 19th, 2011, 12:17 PM. Reason: grammar

                Comment


                • #9
                  Yes, thanks. I changed from springSecurityFilterChain to filterChainProxy while grasping at straws. I'd seen it used in section 8.2, FilterChainProxy, of the Spring Security 3.1.0 Reference Documentation without fully understanding what was written below the example on page 51:

                  When we looked at how to set up web security using namespace configuration, we used a DelegatingFilterProxy with the name “springSecurityFilterChain”. You should now be able to see that this is the name of the FilterChainProxy which is created by the namespace.
                  The reason (well, at least one of the reasons) I didn't have any luck using springSecurityFilterChain previously was that I'd forgotten to change the beans schema location in web.xml from 3.1 to 3.0 when I downgraded the version of the framework I was using (again, while grasping at straws).

                  After making both changes, Spring is able to complete its initialization successfully, and I've verified that oauth is indeed working correctly between consumers and my provider.

                  Thanks again for all your help.

                  Thom

                  Comment

                  Working...
                  X