Hi again!
So, I have become desperate :-) and started poking around in the Tuscany
source code.
The NullPointerException that I experienced earlier is caused by a
component type property having a null XSD element. I modified the code,
as below, to avoid the NullPointerException.
[code]
...
            // check that the types specified in the component type and
component property match
            if (componentProperty.getXSDElement() != null
                && !componentProperty.getXSDElement().equals(
                    componentTypeProperty.getXSDElement()))
            {
                // MY MODIFICATION HERE.
                String theCompTypePropXSDElem = "[not available]";
                if (componentTypeProperty
                        .getXSDElement() != null)
                {
                    theCompTypePropXSDElem =
componentTypeProperty.getXSDElement().toString();
                }
                Monitor.error(monitor, this, Messages.ASSEMBLY_VALIDATION,
                    "PropertXSDElementsDontMatch", component.getName(),
                    componentProperty.getName(), componentProperty
                        .getXSDElement().toString(),
theCompTypePropXSDElem);
            }
...
[/code]

With this modification in place, I now receive the following messages in
the log:

Dec 17, 2009 10:28:54 PM
org.apache.tuscany.sca.builder.impl.ComponentBuilderImpl [Composite:
{http://docs.oasis-open.org/ns/opencsa/sca/200
903}, Component: ServiceComponent1] (PropertXSDElementsDontMatch)
SEVERE: [ASM_5036] The property component ServiceComponent1 property
myComplexProp has XSD element {http://foo.com}fooElement while its comp
onent type property has the XSD element [not available]
java.lang.IllegalStateException:
org.oasisopen.sca.ServiceRuntimeException: [Composite:
{http://docs.oasis-open.org/ns/opencsa/sca/200903},
Component: ServiceComponent1] - [ASM_5036] The property component
ServiceComponent1 property myComplexProp has XSD element {http://foo.com}f
ooElement while its component type property has the XSD element [not
available]
    at org.apache.tuscany.sca.node.impl.NodeImpl.start(NodeImpl.java:176)
    at
com.ivan.SmallPropertyTestMain.doStuffTuscany2(SmallPropertyTestMain.java:58)
    at com.ivan.SmallPropertyTestMain.main(SmallPropertyTestMain.java:29)
Caused by: org.oasisopen.sca.ServiceRuntimeException: [Composite:
{http://docs.oasis-open.org/ns/opencsa/sca/200903}, Component: ServiceComp
onent1] - [ASM_5036] The property component ServiceComponent1 property
myComplexProp has XSD element {http://foo.com}fooElement while its co
mponent type property has the XSD element [not available]
    at
org.apache.tuscany.sca.node.impl.NodeFactoryImpl.analyzeProblems(NodeFactoryImpl.java:174)
    at
org.apache.tuscany.sca.node.impl.NodeFactoryImpl.configureNode(NodeFactoryImpl.java:275)
    at org.apache.tuscany.sca.node.impl.NodeImpl.start(NodeImpl.java:135)
    ... 2 more
Exception in thread "main" java.lang.NullPointerException
    at com.ivan.SmallPropertyTestMain.main(SmallPropertyTestMain.java:31)

The question is: Why is the component type property null?   
Isn't the property type supposed to be inferred from the field annotated
by the @Property annotation or have I misunderstood?
Best wishes,
 Ivan

Reply via email to