cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Bricout <michael.bric...@iona.com>
Subject Configuration question
Date Thu, 05 Oct 2006 17:31:23 GMT
Hello,

I am porting the ws-resource framework implementation (Tandoori project) to
cxf2.0, and I have a problem related to configuration. It seems to be
coming down to an issue with the spring framework, but perhaps someone
familiar with configuration in cxf will be able to spot what I am doing
wrong here.

Basically, I need to instantiate a schema-defined object using setter-based
injection of property values.


My configurable type looks like this:

    <xs:complexType name="ResourceConfigurationBean">
        <xs:annotation>
            <xs:appinfo>
                <cfg:configurable/>
            </xs:appinfo>
        </xs:annotation>
        <xs:sequence>
            <xs:element ref="tns:myString" minOccurs="0"/>
            <xs:element ref="tns:resource" minOccurs="0"/>
            <!-- [...] -->
        </xs:sequence>
    </xs:complexType>

    <xs:element name="myString" type="tns:MyStringType"/>
    <xs:element name="resource" type="tns:resourceConfigurationType"/>

Both MyStringType and resourceConfigurationType are complex types, MyStringType
only defines an attribute.

    
I use the "-Xcfg" extension argument to the xsdtojava code generator
in my pom, and I obtain the expected mapping for my type as:

  com.iona.cxf.resource.configuration.types.ResourceConfigurationBean
  which extends AbstractConfigurableBeanBase.


I verified that the appropriate setters are implemented in the type, in
particular:

  public void setMyString(MyStringType value)
  public void setResourceID(ResourceIDConfigurationType value)


I extend ResourceConfigurationBean with my own ResourceFrameworkConfiguration,
which among others defines and implements the following methods:

    @javax.annotation.Resource public void setBus(Bus bus)
    @javax.annotation.PostConstruct initResourceFrameworkConfiguration()
    (this one initialises all the non instanciated members post-construct)


I created the following bean configuration:

  <beans xmlns:ct="http://cxf.apache.org/configuration/types"
      xmlns:rt="http://cxf.iona.com/resource/configuration/types">

    <bean id="celtix.{http://cxf.iona.com/resource/test}MyPort"
        class="com.iona.cxf.resource.ResourceFrameworkConfiguration">
      
      <property name="bus" ref="cxf"/>

      <property name="myString">
        <value>
          <rt:myString myValue="SomeValue"/>
        </value>
      </property>

      <property name="resource">
        <value>
          <rt:resource>
            <rt:class>MyResourceClass</rt:class>
            <rt:elementName xmlns:ns="MyNamespace">ns:MyResourceElementName
            </rt:elementName>
          </rt:resource>
        </value>
      </property>

    </bean>
  </beans>


I created a test inspired from the ManagedBusTest in cxf, where I use
the "spring" factory to obtain a bus:

  SpringBusFactory factory = new SpringBusFactory();
  bus = factory.createBus("myConfig.xml", true);


Problem: the values I defined in the config file are not properly
converted to the types at injection time.

I get the following exceptions from the Spring framework:


org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'celtix.{http://cxf.iona.com/resource/test}MyPort'
defined in class path resource [myConfig.xml]:
Error setting property values;

org.springframework.beans.TypeMismatchException:
Failed to convert property value of type
  [com.sun.org.apache.xerces.internal.dom.DeferredElementNSImpl]
to required type
  [com.iona.cxf.resource.configuration.types.MyStringType]
for property 'myString';
nested exception is java.lang.IllegalArgumentException:
  No matching editors or conversion strategy found

[...]

org.springframework.beans.TypeMismatchException:
Failed to convert property value of type
  [com.sun.org.apache.xerces.internal.dom.DeferredElementNSImpl]
to required type
  [com.iona.cxf.resource.configuration.types.ResourceConfigurationType]
for property 'resource';
nested exception is java.lang.IllegalArgumentException:
  No matching editors or conversion strategy found

[...]

at org.springframework.beans.PropertyTypeConverter.convertIfNecessary(PropertyTypeConverter.java:209)
at org.springframework.beans.PropertyTypeConverter.convertIfNecessary(PropertyTypeConverter.java:108)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:723)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:575)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValue(AbstractPropertyAccessor.java:49)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:68)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:57)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:816)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:592)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:392)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:240)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:132)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:237)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:153)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:254)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:337)
at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:68)
at com.iona.cxf.resource.ResourceFrameworkConfigurationTest.testConfiguration(ResourceFrameworkConfigurationTest.java:165)


Obviously my types cannot be properly decoded, however setting the "bus"
property works fine.


Any input will be appreciated.
Thanks,
Michael


Mime
View raw message