Hi!
Another question regarding properties of components, this time about
properties that are not simple XSD types and that are injected with XML
data.
With a look at the property tests in the itest directory in the source
distribution, I tried this:
In the composite file (inside a component):
...
        <property name="person" element="ivan:person">
            <person xmlns="http://www.ivan.com/person";>
                <firstName>DeeDee</firstName>
                <lastName>Ramone</lastName>
                <age>49</age>
            </person>
        </property>
    </component>
...

In the component implementation class; the field to be injected:
    @Property(name="person", required=false)
    protected Person mPerson;

Then I have a class Person which contains two string fields firstName,
lastName and one integer field age with corresponding getters and
setters. No annotations.

In the same directory as the composite, I have the following XML schema:
<?xml version="1.0" encoding="UTF-8"?>
<schema
    xmlns="http://www.w3.org/2001/XMLSchema";
    xmlns:ivan="http://www.ivan.com/person";
    targetNamespace="http://www.ivan.com/person";
    attributeFormDefault="unqualified">
   
    <element name="person" type="ivan:Person"/>
    <complexType name="Person">
        <sequence>
            <element name="firstName" type="string" nillable="false"/>
            <element name="lastName" type="string" nillable="false"/>
            <element name="age" type="int"/>
        </sequence>
    </complexType>
</schema>

Finally, when I run the program, I there is the following exception:
Exception in thread "main" java.lang.IllegalStateException:
org.apache.tuscany.sca.assembly.builder.CompositeBuilderException:
Exception while building model
{http://docs.oasis-open.org/ns/opencsa/sca/200903}
    at org.apache.tuscany.sca.node.impl.NodeImpl.start(NodeImpl.java:176)
    at
com.ivan.client.SCAPropertyPrinterClient.main(SCAPropertyPrinterClient.java:27)
Caused by:
org.apache.tuscany.sca.assembly.builder.CompositeBuilderException:
Exception while building model
{http://docs.oasis-open.org/ns/opencsa/sca/200903}
    at
org.apache.tuscany.sca.builder.impl.ModelBuilderImpl.build(ModelBuilderImpl.java:140)
    at
org.apache.tuscany.sca.assembly.builder.DefaultBuilderExtensionPoint$LazyCompositeBuilder.build(DefaultBuilderExtensionPoint.java:224)
    at
org.apache.tuscany.sca.deployment.impl.DeployerImpl.build(DeployerImpl.java:449)
    at
org.apache.tuscany.sca.node.impl.NodeFactoryImpl.configureNode(NodeFactoryImpl.java:274)
    at org.apache.tuscany.sca.node.impl.NodeImpl.start(NodeImpl.java:135)
    ... 1 more
Caused by: java.lang.NullPointerException
    at
org.apache.tuscany.sca.builder.impl.ComponentBuilderImpl.reconcileComponentPropertyWithComponentType(ComponentBuilderImpl.java:649)
    at
org.apache.tuscany.sca.builder.impl.ComponentBuilderImpl.configureProperties(ComponentBuilderImpl.java:329)
    at
org.apache.tuscany.sca.builder.impl.ComponentBuilderImpl.configureComponentFromComponentType(ComponentBuilderImpl.java:142)
    at
org.apache.tuscany.sca.builder.impl.CompositeComponentTypeBuilderImpl.createComponentType(CompositeComponentTypeBuilderImpl.java:126)
    at
org.apache.tuscany.sca.builder.impl.ModelBuilderImpl.build(ModelBuilderImpl.java:111)
    ... 5 more

I have also tried the tests in the itest/properties, which I seriously
doubt that they ever have been able to pass given that there is no XML
schema defining the type/element used in the composite.
If anyone has any hints, I would be very grateful. Feel like I have
tried "everything", but I am sure there is something I overlooked.
Best regards!
 Ivan

Reply via email to