ServiceRuntimeException due to NPE with ComponentContext.getService()
---------------------------------------------------------------------
Key: TUSCANY-2243
URL: https://issues.apache.org/jira/browse/TUSCANY-2243
Project: Tuscany
Issue Type: Bug
Components: Java SCA Core Runtime
Reporter: Yee-Kang Chang
ComponentContext.getService() did not return the expected service when invoked.
It works with a @Reference field is defined for the service in the Impl class
but it failed without the annotation. The reference is defined in the SCDL.
Section 1.4.1.1 of the specification says, "When a component implementation
needs access to a service where the reference to the service is not known at
compile time, the reference can be located using the component's
ComponentContext." So, this should work without @Reference defined.
org.osoa.sca.ServiceRuntimeException: java.lang.NullPointerException
at
org.apache.tuscany.sca.core.context.ComponentContextImpl.getServiceReference(ComponentContextImpl.java:228)
at
org.apache.tuscany.sca.core.context.ComponentContextImpl.getServiceReference(ComponentContextImpl.java:110)
at
org.apache.tuscany.sca.core.context.ComponentContextImpl.getService(ComponentContextImpl.java:102)
at
org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext.impl.AComponentImpl.testServiceLookup(AComponentImpl.java:96)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at
org.apache.tuscany.sca.implementation.java.invocation.JavaImplementationInvoker.invoke(JavaImplementationInvoker.java:109)
at
org.apache.tuscany.sca.binding.sca.impl.SCABindingInvoker.invoke(SCABindingInvoker.java:61)
at
org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:286)
at
org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:154)
at $Proxy7.testServiceLookup(Unknown Source)
at
org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext.ComponentContextTestCase.testServiceLookup(ComponentContextTestCase.java:170)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at
org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
at
org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
at
org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at
org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
at
org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
at
org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:75)
at
org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:36)
at
org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
at
org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at
org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
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)
Caused by: java.lang.NullPointerException
at
org.apache.tuscany.sca.core.context.ComponentContextImpl.getInterfaceContract(ComponentContextImpl.java:346)
at
org.apache.tuscany.sca.core.context.ComponentContextImpl.getServiceReference(ComponentContextImpl.java:220)
... 33 more
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]