On Jan 14, 2007, at 9:45 PM, lee zhenghui wrote:

hi,
I am writing a sample to test the feature described in section 2.2.5 of SCA_ClientAndImplementationModeforJava_v96.doc. I am describing the details of my test sample here:
         1. Create two component -- Customer and CustomerInfo.
2. Make sure the implementation class of CustomerInfo will implements more than two inferfaces. 3. Define ComponentType via @Service etc. make sure it works fine. 4. remove @Service descriptions in source code, and replace it with a ComponentType side file.
  Result:
          I got a exception:
                 java.lang.NullPointerException
at org.apache.tuscany.core.implementation.java.JavaComponentBuilder.build (JavaComponentBuilder.java:120) at org.apache.tuscany.core.implementation.java.JavaComponentBuilder.build (JavaComponentBuilder.java:1) at org.apache.tuscany.core.builder.BuilderRegistryImpl.build (BuilderRegistryImpl.java:107) at org.apache.tuscany.core.implementation.composite.AbstractCompositeBuil der.build(AbstractCompositeBuilder.java :35) at org.apache.tuscany.core.implementation.composite.CompositeBuilder.buil d(CompositeBuilder.java:44) at org.apache.tuscany.core.builder.BuilderRegistryImpl.build (BuilderRegistryImpl.java:107) at org.apache.tuscany.core.deployer.DeployerImpl.build (DeployerImpl.java:142) at org.apache.tuscany.core.deployer.DeployerImpl.deploy (DeployerImpl.java:97) at org.apache.tuscany.core.launcher.LauncherImpl.bootApplication (LauncherImpl.java:215)
    at org.apache.tuscany.test.SCATestCase.setUp(SCATestCase.java:88)
at tuscany.sample.sync.customer.CustomerImplTest.setUp (CustomerImplTest.java:16)
    at junit.framework.TestCase.runBare (TestCase.java:125)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:208)
    at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run ( JUnit3TestReference.java:128) 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)

I am attaching my sample PI zip file here, Does anyone know whether this is a runtime issue, or I missing something in my test sample?

Hi,

This is a problem with both the code and the SCA Java specification. The spec issue is that we have not defined all of the equivalent component type extensions for Java annotations. In this particular case it is support for the @Constructor annotation. If you are interested, we could work on a proposal to the spec group for adding this into the component type side file.

In terms of the code, it looks as if the side file introspection process does not create a ConstructorDefinition, which basically tells the builder which constructor to use during instantiation. If we were to support selection of a constructor in a side file, we would have to provide a mechanism that would first allow a user to specify the constructor to use in XML (by parameter type). If no constructor was specified, we would need to determine this heuristically. The Java annotation introspection mechanism does this, which you can see in org.apache.tuscany.core.implementation.processor.HeuristicPojoProcessor.

Supporting constructor selection in the side file as described above is quite a bit of work. If you are interested, I can help point you to places in the code to get started. However, this may be more than what you need to get past the issue you are facing. If you just want to get past the NPE, a simple fix would be to create a ConstructorDefinition and have it point to the default no-args constructor of the implementation. I would do this in JavaComponentTypeLoader.loadFromSideFile() after the component type as been populated with side file info and before it is returned from this method.

Jim







---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to