Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-1663

Attempting to use a Spring configured HTTPConduit causing compatability problems with Spring 2.5.4 testing framework

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0.5
    • 2.0.8, 2.1.2
    • Transports
    • None

    Description

      Hi there,

      I'm attempting to run some integration tests with a spring configured HTTP conduit:
      <http:conduit name="*.http-conduit">
      <http:tlsClientParameters secureSocketProtocol="SSL">
      <sec:keyManagers keyPassword="0123456789">
      <sec:keyStore type="PKCS12" password="0123456789"
      file="src/test/resources/keystores/client.p12"/>
      </sec:keyManagers>
      <sec:trustManagers>
      <sec:keyStore type="JKS" password="0123456789"
      file="src/test/resources/keystores/truststore.jks" />
      </sec:trustManagers>
      <sec:cipherSuitesFilter>
      <!-- these filters ensure that a ciphersuite with
      export-suitable or null encryption is used,
      but exclude anonymous Diffie-Hellman key change as
      this is vulnerable to man-in-the-middle attacks -->
      <sec:include>.EXPORT.</sec:include>
      <sec:include>.EXPORT1024.</sec:include>
      <sec:include>.WITH_DES.</sec:include>
      <sec:include>.WITH_NULL.</sec:include>
      <sec:exclude>.DH_anon.</sec:exclude>
      </sec:cipherSuitesFilter>
      </http:tlsClientParameters>
      </http:conduit>

      My test class is using JUnit 4 annotations and I'm also extending from AbstractJUnit4SpringContextTests which as you may know automatically loads the spring context for you with autowiring turned on. The problem I'm having is that HTTPConduit declares some of its methods with the @Resource annotation which Spring then attempts to resolved dependencies for and fails. The issue is that the HTTPConduit class does not need these dependencies injected in order to function correctly so I guess I'm wondering why they are annotated as such. Is this necessary?

      If so is there anything I can do to work around this problem?

      Here's a sample stack trace to illustrated the problem that occurs:
      javax.xml.ws.soap.SOAPFaultException: Error creating bean with name '*.http-conduit': Injection of resource methods failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [org.apache.cxf.configuration.security.AuthorizationPolicy] is defined: Unsatisfied dependency of type [class org.apache.cxf.configuration.security.AuthorizationPolicy]: expected at least 1 matching bean
      at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:211)
      at $Proxy54.getAccountDetails(Unknown Source)
      at com.sportex.regpay.payment.mtapi.transfers.TransferFundsIntegrationTest.performTransferCreditSuccessfulWithGBP(TransferFundsIntegrationTest.java:97)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.springframework.test.context.junit4.SpringTestMethod.invoke(SpringTestMethod.java:163)
      at org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(SpringMethodRoadie.java:233)
      at org.springframework.test.context.junit4.SpringMethodRoadie$RunBeforesThenTestThenAfters.run(SpringMethodRoadie.java:333)
      at org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitions(SpringMethodRoadie.java:217)
      at org.springframework.test.context.junit4.SpringMethodRoadie.runTest(SpringMethodRoadie.java:197)
      at org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringMethodRoadie.java:143)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:142)
      at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
      at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
      at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
      at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
      at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '*.http-conduit': Injection of resource methods failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [org.apache.cxf.configuration.security.AuthorizationPolicy] is defined: Unsatisfied dependency of type [class org.apache.cxf.configuration.security.AuthorizationPolicy]: expected at least 1 matching bean
      at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:306)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:996)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.configureBean(AbstractAutowireCapableBeanFactory.java:283)
      at org.springframework.beans.factory.wiring.BeanConfigurerSupport.configureBean(BeanConfigurerSupport.java:155)
      at org.apache.cxf.configuration.spring.ConfigurerImpl.configureBean(ConfigurerImpl.java:114)
      at org.apache.cxf.configuration.spring.ConfigurerImpl.configureWithWildCard(ConfigurerImpl.java:134)
      at org.apache.cxf.configuration.spring.ConfigurerImpl.configureBean(ConfigurerImpl.java:101)
      at org.apache.cxf.configuration.spring.ConfigurerImpl.configureBean(ConfigurerImpl.java:84)
      at org.apache.cxf.transport.http.AbstractHTTPTransportFactory.configure(AbstractHTTPTransportFactory.java:223)
      at org.apache.cxf.transport.http.AbstractHTTPTransportFactory.getConduit(AbstractHTTPTransportFactory.java:163)
      at org.apache.cxf.transport.http.AbstractHTTPTransportFactory.getConduit(AbstractHTTPTransportFactory.java:145)
      at org.apache.cxf.endpoint.AbstractConduitSelector.getSelectedConduit(AbstractConduitSelector.java:73)
      at org.apache.cxf.endpoint.UpfrontConduitSelector.prepare(UpfrontConduitSelector.java:61)
      at org.apache.cxf.endpoint.ClientImpl.prepareConduitSelector(ClientImpl.java:452)
      at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:273)
      at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:222)
      at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
      at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:170)
      ... 24 more
      Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [org.apache.cxf.configuration.security.AuthorizationPolicy] is defined: Unsatisfied dependency of type [class org.apache.cxf.configuration.security.AuthorizationPolicy]: expected at least 1 matching bean
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:613)
      at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:423)
      at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:502)
      at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:192)
      at org.springframework.beans.factory.annotation.InjectionMetadata.injectMethods(InjectionMetadata.java:117)
      at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:303)
      ... 41 more

      Many thanks,
      James K

      Attachments

        Activity

          People

            dkulp Daniel Kulp
            james.kavanagh James Kavanagh
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: