Urso Wieske wrote:
Hi Simon,

I adapted my code as you suggested. It seems like the error has dissappeared, but I got new ones. Well I removed the setter and getter of messageInterpreterCallback from MessageInterpreterImpl. Now my MessageInterpreterImpl class contains only the instance variable messageInterpreterCallback . I have made it a protected variable.

According to the SCA 1.1 specs, this variable should be private
in order to avoid having it treated as a reference.  Can you try
changing this and see if it makes any difference?

I get a HTTP Internal Server ( error 500).
I am still missing something.SCA runtime is supposed "automatically" inject my callback instance in the messageInterpreterCallback member variable of MessageInterpreterImpl. The MessageInterpreterImpl needs to have a reference to some callback instance.
I can;t seem to solve this problem.

From the stack trace it seems that the thread message context doesn't
contain the callback endpoint.  I'm not sure what could cause this.
However I noticed a problem in your composite that would be worth
fixing, and it's just possible that this might be related to the
problem that you're seeing.

The problem is that you have specified a callback URI for the
MessageInterpreter service in MessageInterpreterComponent, as follows:
  <service name="MessageInterpreter">
    <interface.java interface="org.acme.logix.MessageInterpreter"
        callbackInterface="org.acme.logix.MessageInterpreterCallback"/>
    <binding.ws 
uri="http://localhost:8081/MessageInterpreterComponent/MessageInterpreter"/>
    <callback>
      <binding.ws 
uri="http://localhost:8084/Client/MessageInterpreterCallback"/>
    </callback>
  </service>

There shouldn't be any callback URI in the service definition, because
this information is provided at runtime by the client invocation.  So
you should change the above to:
  <service name="MessageInterpreter">
    <interface.java interface="org.acme.logix.MessageInterpreter"
        callbackInterface="org.acme.logix.MessageInterpreterCallback"/>
    <binding.ws 
uri="http://localhost:8081/MessageInterpreterComponent/MessageInterpreter"/>
    <callback>
      <binding.ws/>
    </callback>
  </service>

If neither of these suggested changes fixes the problem, please
post the complete application as a zip file.

  Simon

This is the error....
---------------------------------------
SEVERE: Exception invoking injector - null
org.oasisopen.sca.ServiceRuntimeException: Exception invoking injector - null at org.apache.tuscany.sca.implementation.java.invocation.JavaImplementationInvoker.invoke(JavaImplementationInvoker.java:208) at org.apache.tuscany.sca.core.databinding.wire.DataTransformationInterceptor.invoke(DataTransformationInterceptor.java:86) at org.apache.tuscany.sca.core.invocation.RuntimeInvoker.invoke(RuntimeInvoker.java:91) at org.apache.tuscany.sca.core.invocation.RuntimeInvoker.invoke(RuntimeInvoker.java:74) at org.apache.tuscany.sca.core.assembly.impl.RuntimeEndpointImpl.invoke(RuntimeEndpointImpl.java:286) at org.apache.tuscany.sca.binding.ws.jaxws.JAXWSBindingProvider.invoke(JAXWSBindingProvider.java:207) at org.apache.tuscany.sca.binding.ws.jaxws.JAXWSBindingProvider.invoke(JAXWSBindingProvider.java:61) at com.sun.xml.internal.ws.api.server.InstanceResolver$1.invokeProvider(InstanceResolver.java:245) at com.sun.xml.internal.ws.server.InvokerTube$2.invokeProvider(InvokerTube.java:145) at com.sun.xml.internal.ws.server.provider.SyncProviderInvokerTube.processRequest(SyncProviderInvokerTube.java:67)
at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Fiber.java:587)
at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:546)
at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:531)
at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:428)
at com.sun.xml.internal.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:232) at com.sun.xml.internal.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:460) at com.sun.xml.internal.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:233) at com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handleExchange(WSHttpHandler.java:95) at com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handle(WSHttpHandler.java:80)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:65)
at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:65)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:68)
at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:555)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:65)
at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:527)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.tuscany.sca.core.factory.ObjectCreationException: Exception invoking injector - null at org.apache.tuscany.sca.implementation.java.invocation.JavaImplementationInvoker.injectCallbacks(JavaImplementationInvoker.java:235) at org.apache.tuscany.sca.implementation.java.invocation.JavaImplementationInvoker.invoke(JavaImplementationInvoker.java:106)
... 27 more
Caused by: java.lang.NullPointerException
at org.apache.tuscany.sca.core.context.impl.CallbackServiceReferenceImpl.init(CallbackServiceReferenceImpl.java:64) at org.apache.tuscany.sca.core.context.impl.CallbackServiceReferenceImpl.<init>(CallbackServiceReferenceImpl.java:47) at org.apache.tuscany.sca.core.invocation.impl.JDKProxyFactory.createCallbackProxy(JDKProxyFactory.java:137) at org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory.createCallbackProxy(ExtensibleProxyFactory.java:76) at org.apache.tuscany.sca.core.invocation.CallbackWireObjectFactory.getInstance(CallbackWireObjectFactory.java:45) at org.apache.tuscany.sca.implementation.java.injection.MethodInjector.inject(MethodInjector.java:55) at org.apache.tuscany.sca.implementation.java.invocation.JavaImplementationInvoker.injectCallbacks(JavaImplementationInvoker.java:230)
... 28 more
10-jan-2011 1:39:26 com.sun.xml.internal.ws.server.provider.SyncProviderInvokerTube processRequest
SEVERE: The server sent HTTP status code 500: Internal Server Error
com.sun.xml.internal.ws.client.ClientTransportException: The server sent HTTP status code 500: Internal Server Error at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.checkStatusCodeOneway(HttpTransportPipe.java:207) at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:164) at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:83) at com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:105)
at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Fiber.java:587)
at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:546)
at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:531)
at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:428)
at com.sun.xml.internal.ws.client.Stub.process(Stub.java:211)
at com.sun.xml.internal.ws.client.dispatch.DispatchImpl.invokeOneWay(DispatchImpl.java:204) at org.apache.tuscany.sca.binding.ws.jaxws.JAXWSBindingInvoker.invokeTarget(JAXWSBindingInvoker.java:224) at org.apache.tuscany.sca.binding.ws.jaxws.JAXWSBindingInvoker.invoke(JAXWSBindingInvoker.java:149) at org.apache.tuscany.sca.core.databinding.wire.DataTransformationInterceptor.invoke(DataTransformationInterceptor.java:86) at org.apache.tuscany.sca.core.invocation.impl.JDKInvocationHandler.invoke(JDKInvocationHandler.java:298) at org.apache.tuscany.sca.core.invocation.impl.JDKInvocationHandler.invoke(JDKInvocationHandler.java:254) at org.apache.tuscany.sca.core.invocation.impl.JDKInvocationHandler.invoke(JDKInvocationHandler.java:114) at org.apache.tuscany.sca.core.invocation.impl.AsyncJDKInvocationHandler.doInvokeSync(AsyncJDKInvocationHandler.java:238) at org.apache.tuscany.sca.core.invocation.impl.AsyncJDKInvocationHandler.invoke(AsyncJDKInvocationHandler.java:160)
at $Proxy50.interpret(Unknown Source)
at org.acme.logix.LogisticCenterImpl.processMessage(LogisticCenterImpl.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tuscany.sca.implementation.java.invocation.JavaImplementationInvoker.invoke(JavaImplementationInvoker.java:158) at org.apache.tuscany.sca.core.databinding.wire.DataTransformationInterceptor.invoke(DataTransformationInterceptor.java:86) at org.apache.tuscany.sca.core.invocation.RuntimeInvoker.invoke(RuntimeInvoker.java:91) at org.apache.tuscany.sca.core.invocation.RuntimeInvoker.invoke(RuntimeInvoker.java:74) at org.apache.tuscany.sca.core.assembly.impl.RuntimeEndpointImpl.invoke(RuntimeEndpointImpl.java:286) at org.apache.tuscany.sca.binding.ws.jaxws.JAXWSBindingProvider.invoke(JAXWSBindingProvider.java:207) at org.apache.tuscany.sca.binding.ws.jaxws.JAXWSBindingProvider.invoke(JAXWSBindingProvider.java:61) at com.sun.xml.internal.ws.api.server.InstanceResolver$1.invokeProvider(InstanceResolver.java:245) at com.sun.xml.internal.ws.server.InvokerTube$2.invokeProvider(InvokerTube.java:145) at com.sun.xml.internal.ws.server.provider.SyncProviderInvokerTube.processRequest(SyncProviderInvokerTube.java:67)
at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Fiber.java:587)
at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:546)
at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:531)
at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:428)
at com.sun.xml.internal.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:232) at com.sun.xml.internal.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:460) at com.sun.xml.internal.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:233) at com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handleExchange(WSHttpHandler.java:95) at com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handle(WSHttpHandler.java:80)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:65)
at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:65)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:68)
at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:555)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:65)
at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:527)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
-----------------------------------------
Hope you can help me. (?)

Kind Regards
Urso

2011/1/9 Simon Nash <[email protected] <mailto:[email protected]>>

    Urso Wieske wrote:

        Hi
        I am evaluating Tuscany 2.0 Beta1 and am trying to learn more
        about Callbacks (Bi-Directional interface) of SCA 1.1. I
        downloaded the Tuscany Sample files and started to explore the
        callback implementations with webservice binding, i.e. the
        Search and SearchCallback interfaces.
        It took me a while before I realized that the Tuscany SCA
        Samples were based on SCA v1.0.   Tuscany 2.0 Beta1 is based on
        the SCA v1.1 specs.
        After studying the sample sources, I have written my own callback.

        Unfortunately, I kept on getting a runtime exception after I
        installed and deployed my contribution. By the way, I am using
        Eclipse and the maven tuscany plugin.

        I can't find the problem and hope if someone can point me in the
        right direction.

        This is the error (printed on my console) I am getting when I
        try to run my program:
        [ERROR] Failed to execute goal
        org.apache.tuscany.maven.plugins:maven-tuscany-plugin:2.0-Beta1:run
        (default-cli) on project handler-agent: Execution default-cli of
        goal
        org.apache.tuscany.maven.plugins:maven-tuscany-plugin:2.0-Beta1:run
        failed: org.oasisopen.sca.ServiceRuntimeException: [Composite:
        {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component:
        MessageInterpreterComponent] - [ASM60033] No targets for
        reference: Composite =
        {http://docs.oasis-open.org/ns/opencsa/sca/200912} Reference =
        messageInterpreterCallback -> [Help 1]

        I suspect that I am doing something wrong in the composite file.
        I can't imagine I did something wrong in the java sources. (See
        below for the sources.)

    Because the MessageInterpreterImpl class doesn't contain any
    @Reference or
    @Property annotations, SCA creates implicit references for all public
    setter methods in this class whose type is a remotable SCA
    interface, and
    also for all public or protected fields in this class whose type is a
    remotable SCA interface.

    There is a public setter method setMessageInterpreterCallback() and a
    protected field messageInterpreterCallback, so SCA defines a reference
    named messageInterpreterCallback.  This reference doesn't have a target
    configured in the composite, hence the error message.

    To fix the problem, you need to remove the setter method (or make it
    protected) and change the field from protected to private.

     Simon


        Kind Regards,

        Urso


        -------------------- THE SERVICE Interface With Callback
        Interface association ----------
        /**
         *  */
        package org.acme.logix;

        import org.acme.logix.message.Message;
        import org.oasisopen.sca.annotation.Callback;
        import org.oasisopen.sca.annotation.OneWay;
        import org.oasisopen.sca.annotation.Remotable;

        /**
         *  *
         */
        @Remotable
        @Callback(MessageInterpreterCallback.class)
        public interface MessageInterpreter {

        @OneWay
        void interpret(Message msg);
        }


        /**
         *  */
        package org.acme.logix;

        import org.oasisopen.sca.annotation.OneWay;
        import org.oasisopen.sca.annotation.Remotable;

        /**
         *  *
         */
        @Remotable
        public interface MessageInterpreterCallback {
        void onInterpret(Interpretation ipr);
        }


        ---------- THE CLIENT implementing the callback interface
        ------------

        /**
         *  */
        package org.acme.logix;

        import org.acme.logix.message.Message;
        import org.oasisopen.sca.annotation.Reference;

        /**
         *  */
        public class LogisticCenterImpl implements LogisticCenter,
        MessageInterpreterCallback {
        private AuditService auditService;
        @Reference
        protected MessageInterpreter messageInterpreter;

        /* (non-Javadoc)
        * @see
        
org.acme.logix.LogisticCenter#processMessage(org.acme.logix.message.Message)
        */
        public void processMessage(Message message) {
        System.out.println("Processing message with payload " +
        message.getPayload() );
        auditService.logSentMessage(message);
        messageInterpreter.interpret(message);
        }

        /**
        * @return the auditService
        */
        public AuditService getAuditService() {
        return auditService;
        }

        /**
        * @param auditService the auditService to set
        */
        @Reference
        public void setAuditService(AuditService auditService) {
        this.auditService = auditService;
        }

        /**
        * @param messageInterpreter the messageInterpreter to set
        */
        public void setMessageInterpreter(MessageInterpreter
        messageInterpreter) {
        this.messageInterpreter = messageInterpreter;
        }

        /**
        * @return the messageInterpreter
        */
        public MessageInterpreter getMessageInterpreter() {
        return messageInterpreter;
        }


               /**
               *  THE CALLBACK method of MessageInterpreterCallback
        interface
               */
        public void onInterpret(Interpretation ipr) {
        System.out.println("Message has been interpreted.");
        }

        }


        ---------THE SERVICE WHICH IS CALLED BY THE CLIENT THROUGH
        WEBSERVICE BINDING ---------

        /**
         *  */
        package org.acme.logix;

        import org.acme.logix.message.Message;
        import org.oasisopen.sca.RequestContext;
        import org.oasisopen.sca.ServiceReference;
        import org.oasisopen.sca.annotation.Callback;
        import org.oasisopen.sca.annotation.Context;
        import org.oasisopen.sca.annotation.Reference;
        import org.oasisopen.sca.annotation.Service;

        /**
         *  *
         */
        public class MessageInterpreterImpl implements MessageInterpreter{

        @Callback
        protected MessageInterpreterCallback messageInterpreterCallback;
        /* (non-Javadoc)
        * @see
        
org.acme.logix.MessageInterpreter#interpret(org.acme.logix.message.Message)
        */
        public void interpret(Message msg) {
        System.out.println("The message is being interpreted..");
        Interpretation ipr = new Interpretation();
        messageInterpreterCallback.onInterpret(ipr);
        }



        /**
        * @return the messageInterpreterCallback
        */
        public MessageInterpreterCallback getMessageInterpreterCallback() {
        return messageInterpreterCallback;
        }



        /**
        * @param messageInterpreterCallback the
        messageInterpreterCallback to set
        */
        public void setMessageInterpreterCallback(
        MessageInterpreterCallback messageInterpreterCallback) {
        this.messageInterpreterCallback = messageInterpreterCallback;
        }
        }





        ---- THE COMPOSITE -----------



        <composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912";
                  targetNamespace="http://logistix";
                  xmlns:logistix="http://logistix";
                  name="AfnemerLogisticCenter">

           <component name="AfnemerHandlingAgentComponent">
        <implementation.java class="org.acme.logix.HandlingAgentImpl"/>
                 <reference name="logisticCenter" >
                <binding.ws <http://binding.ws> <http://binding.ws>
uri="http://127.0.0.1:8087/AfnemerHandlingAgentComponent"/> </reference> <reference name="auditService"
        target="AuditServiceComponent"/>                 </component>



           <component name="AfnemerLogisticCenterComponent">
               <implementation.java
        class="org.acme.logix.LogisticCenterImpl"/>
               <reference name="messageInterpreter">
<interface.java interface="org.acme.logix.MessageInterpreter" callbackInterface="org.acme.logix.MessageInterpreterCallback"/>

        <binding.ws <http://binding.ws> <http://binding.ws>
        
uri="http://localhost:8081/MessageInterpreterComponent/MessageInterpreter"/>
        <callback >
        <binding.ws <http://binding.ws> <http://binding.ws>
        uri="http://localhost:8084/Client/MessageInterpreterCallback
        <http://localhost:8081/Client/MessageInterpreterCallback>" />

        </callback>
        </reference>
<reference name="auditService"> <binding.jms
        
initialContextFactory="org.apache.activemq.jndi.ActiveMQInitialContextFactory"
        jndiURL="tcp://localhost:61616">
          <destination jndiName="AuditServiceQueue" />
          </binding.jms>         </reference>
                </component>
               <component name="MessageInterpreterComponent">
            <implementation.java
        class="org.acme.logix.MessageInterpreterImpl"/>
                <service name="MessageInterpreter">
        <interface.java interface="org.acme.logix.MessageInterpreter"
callbackInterface="org.acme.logix.MessageInterpreterCallback"/>
        <binding.ws <http://binding.ws> <http://binding.ws>
         
uri="http://localhost:8081/MessageInterpreterComponent/MessageInterpreter"/>
        <callback>
        <binding.ws <http://binding.ws> <http://binding.ws>
        uri="http://localhost:8084/Client/MessageInterpreterCallback
        <http://localhost:8081/Client/MessageInterpreterCallback>"/>

        </callback>
        </service>
           </component>


           <component name="AuditServiceComponent">
               <implementation.java
        class="org.acme.logix.AuditServiceImpl"/>
                       <service name="AuditService">
                   <binding.jms
        
initialContextFactory="org.apache.activemq.jndi.ActiveMQInitialContextFactory"
        jndiURL="tcp://localhost:61616">
          <destination jndiName="AuditServiceQueue" />
        </binding.jms>         </service>
           </component>
           </composite>




Reply via email to