RequestContext.getCallbackReference() returns null for implementation.composite
-------------------------------------------------------------------------------

                 Key: TUSCANY-3254
                 URL: https://issues.apache.org/jira/browse/TUSCANY-3254
             Project: Tuscany
          Issue Type: Bug
          Components: Java SCA Assembly Model
    Affects Versions: Java-SCA-1.5.1
            Reporter: Simon Nash
            Assignee: Simon Nash
             Fix For: Java-SCA-1.5.1


The RequestContext.getCallbackReference() method returns null if the service 
being invoked belongs to a component whose implementation type is 
implementation.composite.

To repoduce this problem, modify TargetImpl.java in 
samples/implementation-composite so that someMethod() contains the following, 
where "ct" is the injected component context.

    public void someMethod(String arg) {
        System.out.println("Target: " + arg);
        SourceCallback sourceCallback = (SourceCallback) 
ct.getRequestContext().getCallbackReference().getService();
        sourceCallback.receiveResult(arg + " -> Target.someMethod");
    }

This produces the following output:

Running composite.CompositeTestCase
02-Sep-2009 21:30:13 org.apache.tuscany.sca.node.impl.NodeImpl <init>
INFO: Creating node: null
02-Sep-2009 21:30:14 org.apache.tuscany.sca.node.impl.NodeImpl configureNode
INFO: Loading contribution: file:/F:/tuscany90/sca-java-1.5.1/samples/implementa
tion-composite/target/classes/
02-Sep-2009 21:30:15 org.apache.tuscany.sca.node.impl.NodeImpl start
INFO: Starting node: null
Main thread Thread[main,5,main]
Source: Client.main -> Source.clientMethod
Source: Client.main => Source.clientMethod2
Sleeping ...
Target: Client.main => Source.clientMethod2
02-Sep-2009 21:30:15 org.apache.tuscany.sca.core.invocation.NonBlockingIntercept
or$1 run
Target: Client.main -> Source.clientMethod
SEVERE: Exception from @OneWay invocation
Work thread Thread[Thread-2,5,main]
java.lang.NullPointerException
Result: Client.main -> Source.clientMethod -> Target.someMethod
        at composite.TargetImpl.someMethod(TargetImpl.java:52)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tuscany.sca.implementation.java.invocation.JavaImplementat
ionInvoker.invoke(JavaImplementationInvoker.java:156)
        at org.apache.tuscany.sca.core.invocation.NonBlockingInterceptor$1.run(N
onBlockingInterceptor.java:83)
        at org.apache.tuscany.sca.core.work.Work.run(Work.java:63)
        at org.apache.tuscany.sca.core.work.ThreadPoolWorkManager$DecoratingWork
.run(ThreadPoolWorkManager.java:215)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:885)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:907)
        at java.lang.Thread.run(Thread.java:619)
02-Sep-2009 21:30:16 org.apache.tuscany.sca.node.impl.NodeImpl stop
INFO: Stopping node: null
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.684 sec <<< FA
ILURE!
test(composite.CompositeTestCase)  Time elapsed: 2.636 sec  <<< ERROR!
java.lang.IllegalStateException: Expected callbacks not received
        at composite.CompositeTestCase.test(CompositeTestCase.java:47)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at junit.framework.TestCase.runTest(TestCase.java:168)
        at junit.framework.TestCase.runBare(TestCase.java:134)
        at junit.framework.TestResult$1.protect(TestResult.java:110)
        at junit.framework.TestResult.runProtected(TestResult.java:128)
        at junit.framework.TestResult.run(TestResult.java:113)
        at junit.framework.TestCase.run(TestCase.java:124)
        at junit.framework.TestSuite.runTest(TestSuite.java:232)
        at junit.framework.TestSuite.run(TestSuite.java:227)
        at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.
java:79)
        at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.
java:62)
        at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTes
tSet(AbstractDirectoryTestSuite.java:138)
        at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(Ab
stractDirectoryTestSuite.java:125)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(Su
refireBooter.java:308)
        at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.j
ava:879)


Results :

Tests in error:
  test(composite.CompositeTestCase)

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to