You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by sa...@telvent.com on 2009/06/09 18:15:56 UTC

Problem with "implementation.osgi" reference

Hello

I want to use an osgi service as a SCA component. But I can not access to 
their methods from other Component.  I mean I have created a wired 
instance to the Osgi Service ($Proxy25). It is not "null" but I can not 
invoke to one method because an error is happening 

--->Unable to create SCA binding invoker for local target 
SensorNetworkManagementComponent reference prueba (bindingURI=null 
operation=sayHello)

This is my composite file. I want to have to two components. The first had 
a reference to the second and it is normal "implementation.java". The 
second is the SCA component that is representing to the Osgi Service that 
I want to recover. This Osgi Service was registered in the Osgi registry 
by Activator class in "RegistroService" bundle.

 <sca:component name="SensorNetworkManagementComponent">
    <sca:implementation.java 
class="es.amivital.sensornetworkmanagement.sca.SensorNetworkManagementServiceImpl"/>
    <sca:service name="SensorNetworkManagementService">      
     <sca:binding.ws uri="
http://localhost:8085/SensorNetworkManagementComponent"/>
   </sca:service>
  <sca:reference name="prueba" target="PruebaComponent"/>
  </sca:component>


  <sca:component name="Prueba">
        <sca:implementation.osgi xmlns="
http://tuscany.apache.org/xmlns/sca/1.0"
             bundleSymbolicName="RegistroService"                         
             bundleVersion="1.0.0">
            <sca:properties service="prueba.PruebaImpl">                
            </sca:properties>
        </sca:implementation.osgi>
</sca:component>

***The Java code--> The first component.

public class SensorNetworkManagementServiceImpl  implements 
SensorNetworkManagementService { 
private Prueba prueba;
public Prueba getPrueba() {
return prueba;
}
@Reference
public void setPrueba(Prueba prueba) {
this.prueba = prueba;
}
}

**Java code       --> The second component. It is another bundle that is 
registering one simple Osgi Service. The interface was

public interface Prueba { 
public abstract String sayHello();

}





This instance (prueba) is not null when an outside client invoke to the 
first component. But if I invoke to one method of this interface, for 
example "prueba.sayHello" I obtained the previous error.

I have read something about anottations like @AllowsPassByReference 
or @Scope, but I don´t know if they are neccesary .

Re: Fwd: Problem with "implementation.osgi" reference

Posted by Santiago Miguel Aranda Rojas <sa...@gmail.com>.
Yes it is strange because using java code in order to register SCA node was
working. The source code of ContributionProcessor is

 // Create contribution model
        Contribution contribution =
contributionFactory.createContribution();
        contribution.setURI(contributionURI.toString());
        contribution.setLocation(contributionURL.toString());
        ModelResolver modelResolver = new
ExtensibleModelResolver(contribution, modelResolvers, modelFactories);
        contribution.setModelResolver(modelResolver);
        contribution.setUnresolved(true);

        // Create a contribution scanner
        ContributionScanner scanner =
scanners.getContributionScanner(contributionURL.getProtocol());
        if (scanner == null) {
            if ("file".equals(contributionURL.getProtocol()) && new
File(contributionURL.getFile()).isDirectory()) {
                scanner = new DirectoryContributionScanner();
            } else {
                scanner = new JarContributionScanner();
            }
        }

       * // Scan the contribution and list the artifacts contai**ned in it*
        List<Artifact> artifacts = contribution.getArtifacts();
        boolean contributionMetadata = false;
        List<String> artifactURIs = scanner.getArtifacts(contributionURL);
        for (String artifactURI: artifactURIs) {
            *URL artifactURL = scanner.getArtifactURL(contributionURL,
artifactURI); -->  This returns null*

            // Add the deployed artifact model to the contribution
            Artifact artifact = this.contributionFactory.createArtifact();
            artifact.setURI(artifactURI);
           * artifact.setLocation(artifactURL.toString()); --> This is the
line 131*
            artifacts.add(artifact);
            modelResolver.addModel(artifact);


artifactURL is null because of java.lang.NullPointerException is thrown in
the line 131. I guess it is looking for something about "contribution" and
it can not recover some file correctly. I am sure there is something about
contribution when I was using the java code that I don´t have when I don´t
use this code.

I remember you the java code I used
* *
**try {

 //Registrado el servicio SensorNetworkManagement en el dominio SCA
            NodeFactory factory = NodeFactory.newInstance();
            String url =
ContributionLocationHelper.getContributionLocation(getClass());
            Contribution contrib = new Contribution("c1", url);
            node = factory.createNode("OSGI-INF/sca/bundle.composite",
contrib);
            node.start();
        } catch (Throwable e) {
            e.printStackTrace();
  }




2009/6/17 Raymond Feng <en...@gmail.com>

>  Please see my comments inline.
>
>  *From:* Santiago Miguel Aranda Rojas <sa...@gmail.com>
> *Sent:* Wednesday, June 17, 2009 3:02 AM
> *To:* user@tuscany.apache.org ; miguel.luna@telvent.com
> *Subject:* Re: Fwd: Problem with "implementation.osgi" reference
>
> Ok.
> I have checked and I don´t need to write code in order to register SCA
> node.
>
> Tuscany is trying to register the node with both options
> * With "SCA-Composite: true" in the manifest.mf
>
> <rfeng>The value should be a path to the composite file within the
> bundle</rfeng>
>
> * Without SCA-Composite header but with a OSGI-INF/sca directory.
>
> The second option has a problem using Eclipse. I have seen the source code
> of NodeManager.java and "isSCABundle"
> method. bundle.findEntries("OSGI-INF/sca", "*", false) is not working
> correctly in Eclipse because tries to find these files in /OSGI-INF/sca but
> they are really in /src/main/resources/OSGI-INF/sca. When I pack the bundle
> into a jar I have the right structure. But it is not important. I have
> copied this structure into the root of my Eclipse project.
>
> <rfeng>Good catch.</rfeng>
>
>
> I have a new error with both options. Tuscany recognizes the bundle as SCA
> bundle but
>
>  17-jun-2009 11:41:01
> org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl configureNode
> INFO: Loading contribution: bundleentry://33/
> *Could not load resource
> META-INF/maven/es.amivital.calculatorservice2/CalculatorService3/pom.properties
> *
>
> <rfeng>This is really strange.</rfeng>
>
> 17-jun-2009 11:41:01 org.apache.tuscany.sca.node.osgi.impl.NodeManager
> bundleStarted
> GRAVE: java.lang.NullPointerException
> org.oasisopen.sca.ServiceRuntimeException: java.lang.NullPointerException
> at
> org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl$NodeImpl.<init>(NodeFactoryImpl.java:579)
> at
> org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl$NodeImpl.<init>(NodeFactoryImpl.java:562)
> at
> org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl.createNode(NodeFactoryImpl.java:506)
> at
> org.apache.tuscany.sca.node.osgi.impl.NodeManager.bundleStarted(NodeManager.java:96)
> at
> org.apache.tuscany.sca.node.osgi.impl.NodeManager.bundleChanged(NodeManager.java:119)
> at
> org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:1210)
> at
> org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:195)
> at
> org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:141)
> at
> org.eclipse.osgi.framework.internal.core.Framework.publishBundleEventPrivileged(Framework.java:1558)
> at
> org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent(Framework.java:1509)
> at
> org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:355)
> at
> org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:350)
> at
> org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1118)
> at
> org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:634)
> at
> org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:508)
> at
> org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:282)
> at
> org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:468)
> at
> org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:195)
> at
> org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:297)
> Caused by: java.lang.NullPointerException
> at
> org.apache.tuscany.sca.workspace.processor.impl.ContributionContentProcessor.read(ContributionContentProcessor.java:131)
>
> <rfeng>This line doesn't match the latest code in
> ContributionContentProcessor.java. Can you post the lines around?</rfeng>
>
> at
> org.apache.tuscany.sca.workspace.processor.impl.ContributionContentProcessor.read(ContributionContentProcessor.java:1)
> at
> org.apache.tuscany.sca.contribution.processor.DefaultURLArtifactProcessorExtensionPoint$LazyURLArtifactProcessor.read(DefaultURLArtifactProcessorExtensionPoint.java:337)
> at
> org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl.configureNode(NodeFactoryImpl.java:369)
> at
> org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl.access$2(NodeFactoryImpl.java:351)
> at
> org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl$NodeImpl.<init>(NodeFactoryImpl.java:574)
> ... 18 more
>
> When I was using code in order to register the node it was working Ok. I
> think I need something more. What is sca-contribution.xml. Do I need this
> file? Where should it be ? I don´t know why "Could not load resource
> META-INF/maven/es.amivital.calculatorservice2/CalculatorService3/pom.properties" if
> this file it is from maven and it is not from Tuscany
>
>
> Thank you very much for your help
>
> ------------------------------------------------------------------------------------------------------------
>
>
>
>
>
>
> 2009/6/16 Raymond Feng <en...@gmail.com>
>
>> You don't have to write the code to start the Node. The node-impl-osgi
>> bundle is watching the SCA enabled OSGi bundles and it will start the Node
>> when the bundle is started.
>>
>> Thanks,
>> Raymond
>>
>> From: Santiago Miguel Aranda Rojas
>> Sent: Tuesday, June 16, 2009 1:44 AM
>> To: user@tuscany.apache.org
>> Subject: Re: Fwd: Problem with "implementation.osgi" reference
>>
>>
>>
>> Sorry I forgot one question.
>>
>>
>> I am using this code in order to register CalculatorService as SCA
>> service.
>>
>>
>> try {
>>
>> //Registrado el servicio SensorNetworkManagement en el dominio SCA
>>          NodeFactory factory = NodeFactory.newInstance();
>>          String url =
>> ContributionLocationHelper.getContributionLocation(getClass());
>>          Contribution contrib = new Contribution("c1", url);
>>          node = factory.createNode("OSGI-INF/sca/bundle.composite",
>> contrib);
>>          node.start();
>>      } catch (Throwable e) {
>>          e.printStackTrace();
>>      }
>>
>>
>> Is it neccesary this??? Can I put composite and component type in
>> "OSGI-INF/sca" directory only?  I mean have I to write this code? Does
>> Tuscany read these files automatically?
>>
>>
>>
>>
>> Does TestService need this code too?
>>
>>
>>
>>
>> Thank you very much.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> 2009/6/16 <sa...@telvent.com>
>>
>>
>> So, I have to attach two files (componentType and composite) to my two
>> different bundles (TestService and Calculator) and model it as
>> "implementation.osgi".   I have TestService in a bundle I will add these two
>> file and I will design as "implementation.osgi" .
>>
>> But Calculator Service (this is in other bundle) has three components and
>> they are all "implementation.java" and it is working OK. How can I put a
>> reference to TestService?? Do I need change "implementation.osgi" in
>> CalculatorComponent instead "implementation.java"? and is it neccesary for
>> AddServiceComponent and SubstractService??
>>
>> I will try a example I will copy my files in the email.
>>
>> Thank you very much
>>
>> Un saludo.
>> Santiago Miguel Aranda Rojas
>> Telvent Interactiva
>> Extension: 35999
>> Telefono: 955637418
>>
>>
>>
>> "Raymond Feng" <en...@gmail.com>
>>
>> "Raymond Feng"
>> 15/06/2009 18:36
>> Para: <us...@tuscany.apache.org>, <sa...@telvent.com>
>> cc:
>> Asunto: Re: Fwd: Problem with "implementation.osgi" reference
>>
>>
>>
>>
>>
>> To access an OSGi service from the SCA component, you will have to provide
>> SCA configurations for the OSGi bundle so that it becomes an SCA component
>> using implementation.osgi and the OSGi service becomes an SCA service so
>> that the Calculator component can wire to that TestService.
>>
>> There are two SCA files you to provide to model the OSGi bundle as an SCA
>> component.
>> * bundle.componentType to describe what OSGi services or references are
>> used
>> in the bundle (We potentially have better approach to introspect the OSGi
>> bundle to build this up)
>> * bundle.composite to configure the component, for example, setting the
>> bindings.
>>
>> These files can be in a separate OSGi bundle than the one that owns the
>> services/references.
>>
>> Thanks,
>> Raymond
>>
>> From: Santiago Miguel Aranda Rojas
>> Sent: Monday, June 15, 2009 4:01 AM
>> To: user@tuscany.apache.org
>> Subject: Fwd: Problem with "implementation.osgi" reference
>>
>>
>>
>>
>>
>>
>> Hi
>>
>>
>> I can not understand this sample because there are many new concepts for
>> me.
>> For example "bundle.componentType". There is not too much information
>> about
>> that . I think I need something more simple. I have attached a picture
>> with
>> my idea.
>>
>>
>> ** When my SCA service was working I had a main component
>> "implementacion.java" with two references to another two components
>> (implementation.java). The main component could be invoked as Web Service.
>>
>>
>> ** Now, I want another reference to a Service (TestService in the picture)
>> that was registered by another different bundle. But this is a OSGi
>> bundle,
>> without SCA information, Composite file nor ComponentType file. I mean it
>> is
>> a bundle that is registering a service in the OSGi registry. I need have a
>> instance wired to this OSGi service in the class of the main Component in
>> order to invoke their methods.
>>
>>
>> TestService testService;
>>
>>
>> //I need testService is not null in order to invoke their methods.
>> testService.sayHello();
>>
>>
>>
>>
>> I hope you can understand my problem. You can ask me if you want.
>>
>>
>> Thank you very mucha
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> 2009/6/10 Raymond Feng <en...@gmail.com>
>>
>> Please see:
>>
>>
>> https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator/
>>
>> https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator-operations/
>>
>>
>> http://cwiki.apache.org/confluence/display/TUSCANYWIKI/OSGi+RFC+119+Implementation
>>
>> Thanks,
>> Raymond
>>
>>
>> From: Santiago Miguel Aranda Rojas
>> Sent: Wednesday, June 10, 2009 12:07 AM
>> To: user@tuscany.apache.org
>> Subject: Re: Problem with "implementation.osgi" reference
>>
>>
>> Yes, you are right. I was doing some different tests and I copied you a
>> wrong composite. I wanted to see if the change of @target made an error in
>> tuscany.  But Tuscany doesn4t recognize this error because I think it
>> supposes that will be a "remote Component". I can see this in the tuscany
>> trace
>>
>>
>> ADVERTENCIA: Component reference target not found, it might be a remote
>> service running elsewhere in the SCA Domain: Composite =
>> {
>> http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement}SensorNetworkManagement<http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement%7DSensorNetworkManagement>
>> Service = PruebaComponent
>>
>>
>>
>> But it is Ok, because the component I want if an Osgi Service registered
>> in
>> the Osgi registry.
>> I have fixed the error in @target and it is not working yet.
>>
>>
>> Do you know any example when an <implementation.osgi> component is used?
>>
>>
>>
>>
>> I have tried to change  "xmlns" tag, but it doesn4t work.
>>
>>
>> <sca:component name="PruebaComponent">
>>      <sca:implementation.osgi
>> xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
>>           bundleSymbolicName="RegistroService"
>>           bundleVersion="1.0.0">
>>          <sca:properties service="prueba.PruebaImpl">
>>          </sca:properties>
>>      </sca:implementation.osgi>
>>    </sca:component>
>>
>>
>> Thank you very much.
>>
>>
>>
>> 2009/6/10 Raymond Feng <en...@gmail.com>
>>
>> The @target is pointing to a wrong componentName/serviceName. It should be
>> "Prueba" instead of "PruebaComponent" as the component name is "Prueba".
>>
>>
>> From: Santiago Miguel Aranda Rojas
>> Sent: Tuesday, June 09, 2009 1:28 PM
>> To: user@tuscany.apache.org
>> Subject: Re: Problem with "implementation.osgi" reference
>>
>>
>> Tuscany 2.02M. The last version I think. April 2009
>> ----- Original Message ----- From: Raymond Feng
>> To: user@tuscany.apache.org
>> Sent: Tuesday, June 09, 2009 7:12 PM
>> Subject: Re: Problem with "implementation.osgi" reference
>>
>>
>> Are you using Tuscany/SCA 2.x or 1.x?
>>
>>
>> From: santiago.aranda@telvent.com
>> Sent: Tuesday, June 09, 2009 9:15 AM
>> To: user@tuscany.apache.org
>> Subject: Problem with "implementation.osgi" reference
>>
>>
>>
>> Hello
>>
>> I want to use an osgi service as a SCA component. But I can not access to
>> their methods from other Component.  I mean I have created a wired
>> instance
>> to the Osgi Service ($Proxy25). It is not "null" but I can not invoke to
>> one
>> method because an error is happening
>>
>> --->Unable to create SCA binding invoker for local target
>> SensorNetworkManagementComponent reference prueba (bindingURI=null
>> operation=sayHello)
>>
>> This is my composite file. I want to have to two components. The first had
>> a
>> reference to the second and it is normal "implementation.java". The second
>> is the SCA component that is representing to the Osgi Service that I want
>> to
>> recover. This Osgi Service was registered in the Osgi registry by
>> Activator
>> class in "RegistroService" bundle.
>>
>> <sca:component name="SensorNetworkManagementComponent">
>>  <sca:implementation.java
>>
>> class="es.amivital.sensornetworkmanagement.sca.SensorNetworkManagementServiceImpl"/>
>>  <sca:service name="SensorNetworkManagementService">
>>   <sca:binding.ws
>> uri="http://localhost:8085/SensorNetworkManagementComponent"/>
>>  </sca:service>
>> <sca:reference name="prueba" target="PruebaComponent"/>
>> </sca:component>
>>
>>
>> <sca:component name="Prueba">
>>      <sca:implementation.osgi
>> xmlns="http://tuscany.apache.org/xmlns/sca/1.0"
>>           bundleSymbolicName="RegistroService"
>>           bundleVersion="1.0.0">
>>          <sca:properties service="prueba.PruebaImpl">
>>          </sca:properties>
>>      </sca:implementation.osgi>
>> </sca:component>
>>
>> ***The Java code--> The first component.
>>
>> public class SensorNetworkManagementServiceImpl  implements
>> SensorNetworkManagementService {
>> private Prueba prueba;
>> public Prueba getPrueba() {
>> return prueba;
>> }
>> @Reference
>> public void setPrueba(Prueba prueba) {
>> this.prueba = prueba;
>> }
>> }
>>
>> **Java code       --> The second component. It is another bundle that is
>> registering one simple Osgi Service. The interface was
>>
>> public interface Prueba {
>> public abstract String sayHello();
>>
>> }
>>
>>
>>
>>
>>
>> This instance (prueba) is not null when an outside client invoke to the
>> first component. But if I invoke to one method of this interface, for
>> example "prueba.sayHello" I obtained the previous error.
>>
>> I have read something about anottations like @AllowsPassByReference or
>> @Scope, but I don4t know if they are neccesary .
>>
>
>

Re: Fwd: Problem with "implementation.osgi" reference

Posted by Raymond Feng <en...@gmail.com>.
Please see my comments inline.


From: Santiago Miguel Aranda Rojas 
Sent: Wednesday, June 17, 2009 3:02 AM
To: user@tuscany.apache.org ; miguel.luna@telvent.com 
Subject: Re: Fwd: Problem with "implementation.osgi" reference


Ok. 
I have checked and I don´t need to write code in order to register SCA node. 


Tuscany is trying to register the node with both options
* With "SCA-Composite: true" in the manifest.mf 

<rfeng>The value should be a path to the composite file within the bundle</rfeng>

* Without SCA-Composite header but with a OSGI-INF/sca directory.


The second option has a problem using Eclipse. I have seen the source code of NodeManager.java and "isSCABundle" method. bundle.findEntries("OSGI-INF/sca", "*", false) is not working correctly in Eclipse because tries to find these files in /OSGI-INF/sca but they are really in /src/main/resources/OSGI-INF/sca. When I pack the bundle into a jar I have the right structure. But it is not important. I have copied this structure into the root of my Eclipse project.

<rfeng>Good catch.</rfeng>




I have a new error with both options. Tuscany recognizes the bundle as SCA bundle but 


17-jun-2009 11:41:01 org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl configureNode
INFO: Loading contribution: bundleentry://33/
Could not load resource META-INF/maven/es.amivital.calculatorservice2/CalculatorService3/pom.properties

<rfeng>This is really strange.</rfeng>

17-jun-2009 11:41:01 org.apache.tuscany.sca.node.osgi.impl.NodeManager bundleStarted
GRAVE: java.lang.NullPointerException
org.oasisopen.sca.ServiceRuntimeException: java.lang.NullPointerException
at org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl$NodeImpl.<init>(NodeFactoryImpl.java:579)
at org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl$NodeImpl.<init>(NodeFactoryImpl.java:562)
at org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl.createNode(NodeFactoryImpl.java:506)
at org.apache.tuscany.sca.node.osgi.impl.NodeManager.bundleStarted(NodeManager.java:96)
at org.apache.tuscany.sca.node.osgi.impl.NodeManager.bundleChanged(NodeManager.java:119)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:1210)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:195)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:141)
at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEventPrivileged(Framework.java:1558)
at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent(Framework.java:1509)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:355)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:350)
at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1118)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:634)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:508)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:282)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:468)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:195)
at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:297)
Caused by: java.lang.NullPointerException
at org.apache.tuscany.sca.workspace.processor.impl.ContributionContentProcessor.read(ContributionContentProcessor.java:131)

<rfeng>This line doesn't match the latest code in ContributionContentProcessor.java. Can you post the lines around?</rfeng>

at org.apache.tuscany.sca.workspace.processor.impl.ContributionContentProcessor.read(ContributionContentProcessor.java:1)
at org.apache.tuscany.sca.contribution.processor.DefaultURLArtifactProcessorExtensionPoint$LazyURLArtifactProcessor.read(DefaultURLArtifactProcessorExtensionPoint.java:337)
at org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl.configureNode(NodeFactoryImpl.java:369)
at org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl.access$2(NodeFactoryImpl.java:351)
at org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl$NodeImpl.<init>(NodeFactoryImpl.java:574)
... 18 more


When I was using code in order to register the node it was working Ok. I think I need something more. What is sca-contribution.xml. Do I need this file? Where should it be ? I don´t know why "Could not load resource META-INF/maven/es.amivital.calculatorservice2/CalculatorService3/pom.properties" if this file it is from maven and it is not from Tuscany




Thank you very much for your help
------------------------------------------------------------------------------------------------------------











2009/6/16 Raymond Feng <en...@gmail.com>

  You don't have to write the code to start the Node. The node-impl-osgi bundle is watching the SCA enabled OSGi bundles and it will start the Node when the bundle is started. 


  Thanks,
  Raymond

  From: Santiago Miguel Aranda Rojas

  Sent: Tuesday, June 16, 2009 1:44 AM 

  To: user@tuscany.apache.org

  Subject: Re: Fwd: Problem with "implementation.osgi" reference 



  Sorry I forgot one question.


  I am using this code in order to register CalculatorService as SCA service.


  try {

  //Registrado el servicio SensorNetworkManagement en el dominio SCA
           NodeFactory factory = NodeFactory.newInstance();
           String url = ContributionLocationHelper.getContributionLocation(getClass());
           Contribution contrib = new Contribution("c1", url);
           node = factory.createNode("OSGI-INF/sca/bundle.composite", contrib);
           node.start();
       } catch (Throwable e) {
           e.printStackTrace();
       }


  Is it neccesary this??? Can I put composite and component type in "OSGI-INF/sca" directory only?  I mean have I to write this code? Does Tuscany read these files automatically?




  Does TestService need this code too?




  Thank you very much.









  2009/6/16 <sa...@telvent.com>


  So, I have to attach two files (componentType and composite) to my two different bundles (TestService and Calculator) and model it as "implementation.osgi".   I have TestService in a bundle I will add these two file and I will design as "implementation.osgi" .

  But Calculator Service (this is in other bundle) has three components and they are all "implementation.java" and it is working OK. How can I put a reference to TestService?? Do I need change "implementation.osgi" in CalculatorComponent instead "implementation.java"? and is it neccesary for AddServiceComponent and SubstractService??

  I will try a example I will copy my files in the email.

  Thank you very much

  Un saludo.
  Santiago Miguel Aranda Rojas
  Telvent Interactiva
  Extension: 35999
  Telefono: 955637418



  "Raymond Feng" <en...@gmail.com>

  "Raymond Feng"
  15/06/2009 18:36
  Para: <us...@tuscany.apache.org>, <sa...@telvent.com>
  cc:
  Asunto: Re: Fwd: Problem with "implementation.osgi" reference





  To access an OSGi service from the SCA component, you will have to provide
  SCA configurations for the OSGi bundle so that it becomes an SCA component
  using implementation.osgi and the OSGi service becomes an SCA service so
  that the Calculator component can wire to that TestService.

  There are two SCA files you to provide to model the OSGi bundle as an SCA
  component.
  * bundle.componentType to describe what OSGi services or references are used
  in the bundle (We potentially have better approach to introspect the OSGi
  bundle to build this up)
  * bundle.composite to configure the component, for example, setting the
  bindings.

  These files can be in a separate OSGi bundle than the one that owns the
  services/references.

  Thanks,
  Raymond

  From: Santiago Miguel Aranda Rojas
  Sent: Monday, June 15, 2009 4:01 AM
  To: user@tuscany.apache.org
  Subject: Fwd: Problem with "implementation.osgi" reference






  Hi


  I can not understand this sample because there are many new concepts for me.
  For example "bundle.componentType". There is not too much information about
  that . I think I need something more simple. I have attached a picture with
  my idea.


  ** When my SCA service was working I had a main component
  "implementacion.java" with two references to another two components
  (implementation.java). The main component could be invoked as Web Service.


  ** Now, I want another reference to a Service (TestService in the picture)
  that was registered by another different bundle. But this is a OSGi bundle,
  without SCA information, Composite file nor ComponentType file. I mean it is
  a bundle that is registering a service in the OSGi registry. I need have a
  instance wired to this OSGi service in the class of the main Component in
  order to invoke their methods.


  TestService testService;


  //I need testService is not null in order to invoke their methods.
  testService.sayHello();




  I hope you can understand my problem. You can ask me if you want.


  Thank you very mucha

















  2009/6/10 Raymond Feng <en...@gmail.com>

  Please see:

  https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator/
  https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator-operations/

  http://cwiki.apache.org/confluence/display/TUSCANYWIKI/OSGi+RFC+119+Implementation

  Thanks,
  Raymond


  From: Santiago Miguel Aranda Rojas
  Sent: Wednesday, June 10, 2009 12:07 AM
  To: user@tuscany.apache.org
  Subject: Re: Problem with "implementation.osgi" reference


  Yes, you are right. I was doing some different tests and I copied you a
  wrong composite. I wanted to see if the change of @target made an error in
  tuscany.  But Tuscany doesn4t recognize this error because I think it
  supposes that will be a "remote Component". I can see this in the tuscany
  trace


  ADVERTENCIA: Component reference target not found, it might be a remote
  service running elsewhere in the SCA Domain: Composite =
  {http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement}SensorNetworkManagement
  Service = PruebaComponent



  But it is Ok, because the component I want if an Osgi Service registered in
  the Osgi registry.
  I have fixed the error in @target and it is not working yet.


  Do you know any example when an <implementation.osgi> component is used?




  I have tried to change  "xmlns" tag, but it doesn4t work.


  <sca:component name="PruebaComponent">
       <sca:implementation.osgi
  xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
            bundleSymbolicName="RegistroService"
            bundleVersion="1.0.0">
           <sca:properties service="prueba.PruebaImpl">
           </sca:properties>
       </sca:implementation.osgi>
     </sca:component>


  Thank you very much.



  2009/6/10 Raymond Feng <en...@gmail.com>

  The @target is pointing to a wrong componentName/serviceName. It should be
  "Prueba" instead of "PruebaComponent" as the component name is "Prueba".


  From: Santiago Miguel Aranda Rojas
  Sent: Tuesday, June 09, 2009 1:28 PM
  To: user@tuscany.apache.org
  Subject: Re: Problem with "implementation.osgi" reference


  Tuscany 2.02M. The last version I think. April 2009
  ----- Original Message ----- From: Raymond Feng
  To: user@tuscany.apache.org
  Sent: Tuesday, June 09, 2009 7:12 PM
  Subject: Re: Problem with "implementation.osgi" reference


  Are you using Tuscany/SCA 2.x or 1.x?


  From: santiago.aranda@telvent.com
  Sent: Tuesday, June 09, 2009 9:15 AM
  To: user@tuscany.apache.org
  Subject: Problem with "implementation.osgi" reference



  Hello

  I want to use an osgi service as a SCA component. But I can not access to
  their methods from other Component.  I mean I have created a wired instance
  to the Osgi Service ($Proxy25). It is not "null" but I can not invoke to one
  method because an error is happening

  --->Unable to create SCA binding invoker for local target
  SensorNetworkManagementComponent reference prueba (bindingURI=null
  operation=sayHello)

  This is my composite file. I want to have to two components. The first had a
  reference to the second and it is normal "implementation.java". The second
  is the SCA component that is representing to the Osgi Service that I want to
  recover. This Osgi Service was registered in the Osgi registry by Activator
  class in "RegistroService" bundle.

  <sca:component name="SensorNetworkManagementComponent">
   <sca:implementation.java
  class="es.amivital.sensornetworkmanagement.sca.SensorNetworkManagementServiceImpl"/>
   <sca:service name="SensorNetworkManagementService">
    <sca:binding.ws
  uri="http://localhost:8085/SensorNetworkManagementComponent"/>
   </sca:service>
  <sca:reference name="prueba" target="PruebaComponent"/>
  </sca:component>


  <sca:component name="Prueba">
       <sca:implementation.osgi
  xmlns="http://tuscany.apache.org/xmlns/sca/1.0"
            bundleSymbolicName="RegistroService"
            bundleVersion="1.0.0">
           <sca:properties service="prueba.PruebaImpl">
           </sca:properties>
       </sca:implementation.osgi>
  </sca:component>

  ***The Java code--> The first component.

  public class SensorNetworkManagementServiceImpl  implements
  SensorNetworkManagementService {
  private Prueba prueba;
  public Prueba getPrueba() {
  return prueba;
  }
  @Reference
  public void setPrueba(Prueba prueba) {
  this.prueba = prueba;
  }
  }

  **Java code       --> The second component. It is another bundle that is
  registering one simple Osgi Service. The interface was

  public interface Prueba {
  public abstract String sayHello();

  }





  This instance (prueba) is not null when an outside client invoke to the
  first component. But if I invoke to one method of this interface, for
  example "prueba.sayHello" I obtained the previous error.

  I have read something about anottations like @AllowsPassByReference or
  @Scope, but I don4t know if they are neccesary . 


Re: Fwd: Problem with "implementation.osgi" reference

Posted by Santiago Miguel Aranda Rojas <sa...@gmail.com>.
Ok.
I have checked and I don´t need to write code in order to register SCA
node.

Tuscany is trying to register the node with both options
* With "SCA-Composite: true" in the manifest.mf
* Without SCA-Composite header but with a OSGI-INF/sca directory.

The second option has a problem using Eclipse. I have seen the source code
of NodeManager.java and "isSCABundle"
method. bundle.findEntries("OSGI-INF/sca", "*", false) is not working
correctly in Eclipse because tries to find these files in /OSGI-INF/sca but
they are really in /src/main/resources/OSGI-INF/sca. When I pack the bundle
into a jar I have the right structure. But it is not important. I have
copied this structure into the root of my Eclipse project.


I have a new error with both options. Tuscany recognizes the bundle as SCA
bundle but

17-jun-2009 11:41:01 org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl
configureNode
INFO: Loading contribution: bundleentry://33/
*Could not load resource
META-INF/maven/es.amivital.calculatorservice2/CalculatorService3/pom.properties
*
17-jun-2009 11:41:01 org.apache.tuscany.sca.node.osgi.impl.NodeManager
bundleStarted
GRAVE: java.lang.NullPointerException
org.oasisopen.sca.ServiceRuntimeException: java.lang.NullPointerException
at
org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl$NodeImpl.<init>(NodeFactoryImpl.java:579)
at
org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl$NodeImpl.<init>(NodeFactoryImpl.java:562)
at
org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl.createNode(NodeFactoryImpl.java:506)
at
org.apache.tuscany.sca.node.osgi.impl.NodeManager.bundleStarted(NodeManager.java:96)
at
org.apache.tuscany.sca.node.osgi.impl.NodeManager.bundleChanged(NodeManager.java:119)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:1210)
at
org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:195)
at
org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:141)
at
org.eclipse.osgi.framework.internal.core.Framework.publishBundleEventPrivileged(Framework.java:1558)
at
org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent(Framework.java:1509)
at
org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:355)
at
org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:350)
at
org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1118)
at
org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:634)
at
org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:508)
at
org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:282)
at
org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:468)
at
org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:195)
at
org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:297)
Caused by: java.lang.NullPointerException
at
org.apache.tuscany.sca.workspace.processor.impl.ContributionContentProcessor.read(ContributionContentProcessor.java:131)
at
org.apache.tuscany.sca.workspace.processor.impl.ContributionContentProcessor.read(ContributionContentProcessor.java:1)
at
org.apache.tuscany.sca.contribution.processor.DefaultURLArtifactProcessorExtensionPoint$LazyURLArtifactProcessor.read(DefaultURLArtifactProcessorExtensionPoint.java:337)
at
org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl.configureNode(NodeFactoryImpl.java:369)
at
org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl.access$2(NodeFactoryImpl.java:351)
at
org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl$NodeImpl.<init>(NodeFactoryImpl.java:574)
... 18 more

When I was using code in order to register the node it was working Ok. I
think I need something more. What is sca-contribution.xml. Do I need this
file? Where should it be ? I don´t know why "Could not load resource
META-INF/maven/es.amivital.calculatorservice2/CalculatorService3/pom.properties"
if
this file it is from maven and it is not from Tuscany


Thank you very much for your help
------------------------------------------------------------------------------------------------------------






2009/6/16 Raymond Feng <en...@gmail.com>

> You don't have to write the code to start the Node. The node-impl-osgi
> bundle is watching the SCA enabled OSGi bundles and it will start the Node
> when the bundle is started.
>
> Thanks,
> Raymond
>
> From: Santiago Miguel Aranda Rojas
> Sent: Tuesday, June 16, 2009 1:44 AM
> To: user@tuscany.apache.org
> Subject: Re: Fwd: Problem with "implementation.osgi" reference
>
>
>
> Sorry I forgot one question.
>
>
> I am using this code in order to register CalculatorService as SCA service.
>
>
> try {
>
> //Registrado el servicio SensorNetworkManagement en el dominio SCA
>          NodeFactory factory = NodeFactory.newInstance();
>          String url =
> ContributionLocationHelper.getContributionLocation(getClass());
>          Contribution contrib = new Contribution("c1", url);
>          node = factory.createNode("OSGI-INF/sca/bundle.composite",
> contrib);
>          node.start();
>      } catch (Throwable e) {
>          e.printStackTrace();
>      }
>
>
> Is it neccesary this??? Can I put composite and component type in
> "OSGI-INF/sca" directory only?  I mean have I to write this code? Does
> Tuscany read these files automatically?
>
>
>
>
> Does TestService need this code too?
>
>
>
>
> Thank you very much.
>
>
>
>
>
>
>
>
>
> 2009/6/16 <sa...@telvent.com>
>
>
> So, I have to attach two files (componentType and composite) to my two
> different bundles (TestService and Calculator) and model it as
> "implementation.osgi".   I have TestService in a bundle I will add these two
> file and I will design as "implementation.osgi" .
>
> But Calculator Service (this is in other bundle) has three components and
> they are all "implementation.java" and it is working OK. How can I put a
> reference to TestService?? Do I need change "implementation.osgi" in
> CalculatorComponent instead "implementation.java"? and is it neccesary for
> AddServiceComponent and SubstractService??
>
> I will try a example I will copy my files in the email.
>
> Thank you very much
>
> Un saludo.
> Santiago Miguel Aranda Rojas
> Telvent Interactiva
> Extension: 35999
> Telefono: 955637418
>
>
>
> "Raymond Feng" <en...@gmail.com>
>
> "Raymond Feng"
> 15/06/2009 18:36
> Para: <us...@tuscany.apache.org>, <sa...@telvent.com>
> cc:
> Asunto: Re: Fwd: Problem with "implementation.osgi" reference
>
>
>
>
>
> To access an OSGi service from the SCA component, you will have to provide
> SCA configurations for the OSGi bundle so that it becomes an SCA component
> using implementation.osgi and the OSGi service becomes an SCA service so
> that the Calculator component can wire to that TestService.
>
> There are two SCA files you to provide to model the OSGi bundle as an SCA
> component.
> * bundle.componentType to describe what OSGi services or references are
> used
> in the bundle (We potentially have better approach to introspect the OSGi
> bundle to build this up)
> * bundle.composite to configure the component, for example, setting the
> bindings.
>
> These files can be in a separate OSGi bundle than the one that owns the
> services/references.
>
> Thanks,
> Raymond
>
> From: Santiago Miguel Aranda Rojas
> Sent: Monday, June 15, 2009 4:01 AM
> To: user@tuscany.apache.org
> Subject: Fwd: Problem with "implementation.osgi" reference
>
>
>
>
>
>
> Hi
>
>
> I can not understand this sample because there are many new concepts for
> me.
> For example "bundle.componentType". There is not too much information about
> that . I think I need something more simple. I have attached a picture with
> my idea.
>
>
> ** When my SCA service was working I had a main component
> "implementacion.java" with two references to another two components
> (implementation.java). The main component could be invoked as Web Service.
>
>
> ** Now, I want another reference to a Service (TestService in the picture)
> that was registered by another different bundle. But this is a OSGi bundle,
> without SCA information, Composite file nor ComponentType file. I mean it
> is
> a bundle that is registering a service in the OSGi registry. I need have a
> instance wired to this OSGi service in the class of the main Component in
> order to invoke their methods.
>
>
> TestService testService;
>
>
> //I need testService is not null in order to invoke their methods.
> testService.sayHello();
>
>
>
>
> I hope you can understand my problem. You can ask me if you want.
>
>
> Thank you very mucha
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> 2009/6/10 Raymond Feng <en...@gmail.com>
>
> Please see:
>
> https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator/
>
> https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator-operations/
>
>
> http://cwiki.apache.org/confluence/display/TUSCANYWIKI/OSGi+RFC+119+Implementation
>
> Thanks,
> Raymond
>
>
> From: Santiago Miguel Aranda Rojas
> Sent: Wednesday, June 10, 2009 12:07 AM
> To: user@tuscany.apache.org
> Subject: Re: Problem with "implementation.osgi" reference
>
>
> Yes, you are right. I was doing some different tests and I copied you a
> wrong composite. I wanted to see if the change of @target made an error in
> tuscany.  But Tuscany doesn4t recognize this error because I think it
> supposes that will be a "remote Component". I can see this in the tuscany
> trace
>
>
> ADVERTENCIA: Component reference target not found, it might be a remote
> service running elsewhere in the SCA Domain: Composite =
> {
> http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement}SensorNetworkManagement<http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement%7DSensorNetworkManagement>
> Service = PruebaComponent
>
>
>
> But it is Ok, because the component I want if an Osgi Service registered in
> the Osgi registry.
> I have fixed the error in @target and it is not working yet.
>
>
> Do you know any example when an <implementation.osgi> component is used?
>
>
>
>
> I have tried to change  "xmlns" tag, but it doesn4t work.
>
>
> <sca:component name="PruebaComponent">
>      <sca:implementation.osgi
> xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
>           bundleSymbolicName="RegistroService"
>           bundleVersion="1.0.0">
>          <sca:properties service="prueba.PruebaImpl">
>          </sca:properties>
>      </sca:implementation.osgi>
>    </sca:component>
>
>
> Thank you very much.
>
>
>
> 2009/6/10 Raymond Feng <en...@gmail.com>
>
> The @target is pointing to a wrong componentName/serviceName. It should be
> "Prueba" instead of "PruebaComponent" as the component name is "Prueba".
>
>
> From: Santiago Miguel Aranda Rojas
> Sent: Tuesday, June 09, 2009 1:28 PM
> To: user@tuscany.apache.org
> Subject: Re: Problem with "implementation.osgi" reference
>
>
> Tuscany 2.02M. The last version I think. April 2009
> ----- Original Message ----- From: Raymond Feng
> To: user@tuscany.apache.org
> Sent: Tuesday, June 09, 2009 7:12 PM
> Subject: Re: Problem with "implementation.osgi" reference
>
>
> Are you using Tuscany/SCA 2.x or 1.x?
>
>
> From: santiago.aranda@telvent.com
> Sent: Tuesday, June 09, 2009 9:15 AM
> To: user@tuscany.apache.org
> Subject: Problem with "implementation.osgi" reference
>
>
>
> Hello
>
> I want to use an osgi service as a SCA component. But I can not access to
> their methods from other Component.  I mean I have created a wired instance
> to the Osgi Service ($Proxy25). It is not "null" but I can not invoke to
> one
> method because an error is happening
>
> --->Unable to create SCA binding invoker for local target
> SensorNetworkManagementComponent reference prueba (bindingURI=null
> operation=sayHello)
>
> This is my composite file. I want to have to two components. The first had
> a
> reference to the second and it is normal "implementation.java". The second
> is the SCA component that is representing to the Osgi Service that I want
> to
> recover. This Osgi Service was registered in the Osgi registry by Activator
> class in "RegistroService" bundle.
>
> <sca:component name="SensorNetworkManagementComponent">
>  <sca:implementation.java
>
> class="es.amivital.sensornetworkmanagement.sca.SensorNetworkManagementServiceImpl"/>
>  <sca:service name="SensorNetworkManagementService">
>   <sca:binding.ws
> uri="http://localhost:8085/SensorNetworkManagementComponent"/>
>  </sca:service>
> <sca:reference name="prueba" target="PruebaComponent"/>
> </sca:component>
>
>
> <sca:component name="Prueba">
>      <sca:implementation.osgi
> xmlns="http://tuscany.apache.org/xmlns/sca/1.0"
>           bundleSymbolicName="RegistroService"
>           bundleVersion="1.0.0">
>          <sca:properties service="prueba.PruebaImpl">
>          </sca:properties>
>      </sca:implementation.osgi>
> </sca:component>
>
> ***The Java code--> The first component.
>
> public class SensorNetworkManagementServiceImpl  implements
> SensorNetworkManagementService {
> private Prueba prueba;
> public Prueba getPrueba() {
> return prueba;
> }
> @Reference
> public void setPrueba(Prueba prueba) {
> this.prueba = prueba;
> }
> }
>
> **Java code       --> The second component. It is another bundle that is
> registering one simple Osgi Service. The interface was
>
> public interface Prueba {
> public abstract String sayHello();
>
> }
>
>
>
>
>
> This instance (prueba) is not null when an outside client invoke to the
> first component. But if I invoke to one method of this interface, for
> example "prueba.sayHello" I obtained the previous error.
>
> I have read something about anottations like @AllowsPassByReference or
> @Scope, but I don4t know if they are neccesary .
>

Re: Fwd: Problem with "implementation.osgi" reference

Posted by Raymond Feng <en...@gmail.com>.
You don't have to write the code to start the Node. The node-impl-osgi 
bundle is watching the SCA enabled OSGi bundles and it will start the Node 
when the bundle is started.

Thanks,
Raymond

From: Santiago Miguel Aranda Rojas
Sent: Tuesday, June 16, 2009 1:44 AM
To: user@tuscany.apache.org
Subject: Re: Fwd: Problem with "implementation.osgi" reference


Sorry I forgot one question.


I am using this code in order to register CalculatorService as SCA service.


try {

//Registrado el servicio SensorNetworkManagement en el dominio SCA
           NodeFactory factory = NodeFactory.newInstance();
           String url = 
ContributionLocationHelper.getContributionLocation(getClass());
           Contribution contrib = new Contribution("c1", url);
           node = factory.createNode("OSGI-INF/sca/bundle.composite", 
contrib);
           node.start();
       } catch (Throwable e) {
           e.printStackTrace();
       }


Is it neccesary this??? Can I put composite and component type in 
"OSGI-INF/sca" directory only?  I mean have I to write this code? Does 
Tuscany read these files automatically?




Does TestService need this code too?




Thank you very much.









2009/6/16 <sa...@telvent.com>


So, I have to attach two files (componentType and composite) to my two 
different bundles (TestService and Calculator) and model it as 
"implementation.osgi".   I have TestService in a bundle I will add these two 
file and I will design as "implementation.osgi" .

But Calculator Service (this is in other bundle) has three components and 
they are all "implementation.java" and it is working OK. How can I put a 
reference to TestService?? Do I need change "implementation.osgi" in 
CalculatorComponent instead "implementation.java"? and is it neccesary for 
AddServiceComponent and SubstractService??

I will try a example I will copy my files in the email.

Thank you very much

Un saludo.
Santiago Miguel Aranda Rojas
Telvent Interactiva
Extension: 35999
Telefono: 955637418



"Raymond Feng" <en...@gmail.com>

"Raymond Feng"
15/06/2009 18:36
Para: <us...@tuscany.apache.org>, <sa...@telvent.com>
cc:
Asunto: Re: Fwd: Problem with "implementation.osgi" reference





To access an OSGi service from the SCA component, you will have to provide
SCA configurations for the OSGi bundle so that it becomes an SCA component
using implementation.osgi and the OSGi service becomes an SCA service so
that the Calculator component can wire to that TestService.

There are two SCA files you to provide to model the OSGi bundle as an SCA
component.
* bundle.componentType to describe what OSGi services or references are used
in the bundle (We potentially have better approach to introspect the OSGi
bundle to build this up)
* bundle.composite to configure the component, for example, setting the
bindings.

These files can be in a separate OSGi bundle than the one that owns the
services/references.

Thanks,
Raymond

From: Santiago Miguel Aranda Rojas
Sent: Monday, June 15, 2009 4:01 AM
To: user@tuscany.apache.org
Subject: Fwd: Problem with "implementation.osgi" reference






Hi


I can not understand this sample because there are many new concepts for me.
For example "bundle.componentType". There is not too much information about
that . I think I need something more simple. I have attached a picture with
my idea.


** When my SCA service was working I had a main component
"implementacion.java" with two references to another two components
(implementation.java). The main component could be invoked as Web Service.


** Now, I want another reference to a Service (TestService in the picture)
that was registered by another different bundle. But this is a OSGi bundle,
without SCA information, Composite file nor ComponentType file. I mean it is
a bundle that is registering a service in the OSGi registry. I need have a
instance wired to this OSGi service in the class of the main Component in
order to invoke their methods.


TestService testService;


//I need testService is not null in order to invoke their methods.
testService.sayHello();




I hope you can understand my problem. You can ask me if you want.


Thank you very mucha

















2009/6/10 Raymond Feng <en...@gmail.com>

Please see:

https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator/
https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator-operations/

http://cwiki.apache.org/confluence/display/TUSCANYWIKI/OSGi+RFC+119+Implementation

Thanks,
Raymond


From: Santiago Miguel Aranda Rojas
Sent: Wednesday, June 10, 2009 12:07 AM
To: user@tuscany.apache.org
Subject: Re: Problem with "implementation.osgi" reference


Yes, you are right. I was doing some different tests and I copied you a
wrong composite. I wanted to see if the change of @target made an error in
tuscany.  But Tuscany doesn4t recognize this error because I think it
supposes that will be a "remote Component". I can see this in the tuscany
trace


ADVERTENCIA: Component reference target not found, it might be a remote
service running elsewhere in the SCA Domain: Composite =
{http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement}SensorNetworkManagement
Service = PruebaComponent



But it is Ok, because the component I want if an Osgi Service registered in
the Osgi registry.
I have fixed the error in @target and it is not working yet.


Do you know any example when an <implementation.osgi> component is used?




I have tried to change  "xmlns" tag, but it doesn4t work.


 <sca:component name="PruebaComponent">
       <sca:implementation.osgi
xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
            bundleSymbolicName="RegistroService"
            bundleVersion="1.0.0">
           <sca:properties service="prueba.PruebaImpl">
           </sca:properties>
       </sca:implementation.osgi>
     </sca:component>


Thank you very much.



2009/6/10 Raymond Feng <en...@gmail.com>

The @target is pointing to a wrong componentName/serviceName. It should be
"Prueba" instead of "PruebaComponent" as the component name is "Prueba".


From: Santiago Miguel Aranda Rojas
Sent: Tuesday, June 09, 2009 1:28 PM
To: user@tuscany.apache.org
Subject: Re: Problem with "implementation.osgi" reference


Tuscany 2.02M. The last version I think. April 2009
----- Original Message ----- 
From: Raymond Feng
To: user@tuscany.apache.org
Sent: Tuesday, June 09, 2009 7:12 PM
Subject: Re: Problem with "implementation.osgi" reference


Are you using Tuscany/SCA 2.x or 1.x?


From: santiago.aranda@telvent.com
Sent: Tuesday, June 09, 2009 9:15 AM
To: user@tuscany.apache.org
Subject: Problem with "implementation.osgi" reference



Hello

I want to use an osgi service as a SCA component. But I can not access to
their methods from other Component.  I mean I have created a wired instance
to the Osgi Service ($Proxy25). It is not "null" but I can not invoke to one
method because an error is happening

--->Unable to create SCA binding invoker for local target
SensorNetworkManagementComponent reference prueba (bindingURI=null
operation=sayHello)

This is my composite file. I want to have to two components. The first had a
reference to the second and it is normal "implementation.java". The second
is the SCA component that is representing to the Osgi Service that I want to
recover. This Osgi Service was registered in the Osgi registry by Activator
class in "RegistroService" bundle.

<sca:component name="SensorNetworkManagementComponent">
   <sca:implementation.java
class="es.amivital.sensornetworkmanagement.sca.SensorNetworkManagementServiceImpl"/>
   <sca:service name="SensorNetworkManagementService">
    <sca:binding.ws
uri="http://localhost:8085/SensorNetworkManagementComponent"/>
  </sca:service>
 <sca:reference name="prueba" target="PruebaComponent"/>
 </sca:component>


 <sca:component name="Prueba">
       <sca:implementation.osgi
xmlns="http://tuscany.apache.org/xmlns/sca/1.0"
            bundleSymbolicName="RegistroService"
            bundleVersion="1.0.0">
           <sca:properties service="prueba.PruebaImpl">
           </sca:properties>
       </sca:implementation.osgi>
</sca:component>

***The Java code--> The first component.

public class SensorNetworkManagementServiceImpl  implements
SensorNetworkManagementService {
private Prueba prueba;
public Prueba getPrueba() {
return prueba;
}
@Reference
public void setPrueba(Prueba prueba) {
this.prueba = prueba;
}
}

**Java code       --> The second component. It is another bundle that is
registering one simple Osgi Service. The interface was

public interface Prueba {
public abstract String sayHello();

}





This instance (prueba) is not null when an outside client invoke to the
first component. But if I invoke to one method of this interface, for
example "prueba.sayHello" I obtained the previous error.

I have read something about anottations like @AllowsPassByReference or
@Scope, but I don4t know if they are neccesary . 


Re: Fwd: Problem with "implementation.osgi" reference

Posted by Raymond Feng <en...@gmail.com>.
You shouldn't add Service-Component header unless you decide to use OSGi 
Declarative Service for your OSGi programming.

From: Santiago Miguel Aranda Rojas
Sent: Tuesday, June 16, 2009 8:36 AM
To: user@tuscany.apache.org
Subject: Re: Fwd: Problem with "implementation.osgi" reference


I have done some tests and I have found one problem when I add 
Service-Component: OSGI-INF/prueba-component.xml to the manifest.mf of 
CalculatorService. I obtain the next error


Caused by: java.lang.NullPointerException
at 
org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl.init(NodeFactoryImpl.java:256)
at 
org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl.access$0(NodeFactoryImpl.java:224)
at 
org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl$NodeImpl.<init>(NodeFactoryImpl.java:568)


I have downloaded the source code of tuscany in order to see NodeFactoryImpl 
class. I have seen this code but I dont know why it is not working.




  // Create a monitor
        MonitorFactory monitorFactory = 
utilities.getUtility(MonitorFactory.class);
        monitor = monitorFactory.createMonitor();


I guess "monitorFactory" variable it is null. I have checked if 
org.apache.tuscany.sca.monitor is active and it is.


This is my prueba-component.xml


<component name="Prueba" xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
    <implementation class="es.amivital.calculatorservice2.CalculatorService" 
/>
    <service>
        <provide 
interface="es.amivital.calculatorservice2.CalculatorServiceImpl"/>
    </service>
</component>


Thank you very much 


Re: Fwd: Problem with "implementation.osgi" reference

Posted by Santiago Miguel Aranda Rojas <sa...@gmail.com>.
>
> I have done some tests and I have found one problem when I
>> add Service-Component: OSGI-INF/prueba-component.xml to the manifest.mf of
>> CalculatorService. I obtain the next error
>>
>
Caused by: java.lang.NullPointerException
at
org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl.init(NodeFactoryImpl.java:256)
at
org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl.access$0(NodeFactoryImpl.java:224)
at
org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl$NodeImpl.<init>(NodeFactoryImpl.java:568)

I have downloaded the source code of tuscany in order to see NodeFactoryImpl
class. I have seen this code but I dont know why it is not working.


  // Create a monitor
        MonitorFactory monitorFactory =
utilities.getUtility(MonitorFactory.class);
        monitor = monitorFactory.createMonitor();

I guess "monitorFactory" variable it is null. I have checked if
org.apache.tuscany.sca.monitor is active and it is.

This is my prueba-component.xml

<component name="Prueba" xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
    <implementation class="es.amivital.calculatorservice2.CalculatorService"
/>
    <service>
        <provide
interface="es.amivital.calculatorservice2.CalculatorServiceImpl"/>
    </service>
</component>

Thank you very much

Re: Fwd: Problem with "implementation.osgi" reference

Posted by Santiago Miguel Aranda Rojas <sa...@gmail.com>.
Sorry I forgot one question.

I am using this code in order to register CalculatorService as SCA service.

* ** try {*
* ** *
* ** //Registrado el servicio SensorNetworkManagement en el dominio SCA*
* **            NodeFactory factory = NodeFactory.newInstance();*
* **            String url =
ContributionLocationHelper.getContributionLocation(getClass());*
* **            Contribution contrib = new Contribution("c1", url);*
* **            node = factory.createNode("OSGI-INF/sca/bundle.composite",
contrib);*
* **            node.start();*
* **        } catch (Throwable e) {*
* **            e.printStackTrace();*
* **        }*
*
*
Is it neccesary this??? Can I put composite and component type in
"OSGI-INF/sca" directory only?  I mean have I to write this code? Does
Tuscany read these files automatically?


Does TestService need this code too?


Thank you very much.





2009/6/16 <sa...@telvent.com>

>
> So, I have to attach two files (componentType and composite) to my two
> different bundles (TestService and Calculator) and model it as
> "implementation.osgi".   I have TestService in a bundle I will add these two
> file and I will design as "implementation.osgi" .
>
> But Calculator Service (this is in other bundle) has three components and
> they are all "implementation.java" and it is working OK. How can I put a
> reference to TestService?? Do I need change "implementation.osgi" in
> CalculatorComponent instead "implementation.java"? and is it neccesary for
> AddServiceComponent and SubstractService??
>
> I will try a example I will copy my files in the email.
>
> Thank you very much
>
> Un saludo.
> Santiago Miguel Aranda Rojas
> Telvent Interactiva
> Extension: 35999
> Telefono: 955637418
>
>
> "Raymond Feng" <en...@gmail.com>
> "Raymond Feng"
> 15/06/2009 18:36
>  Para: <us...@tuscany.apache.org>, <sa...@telvent.com> cc:
> Asunto: Re: Fwd: Problem with "implementation.osgi" reference
>
>
>
>
> To access an OSGi service from the SCA component, you will have to provide
> SCA configurations for the OSGi bundle so that it becomes an SCA component
> using implementation.osgi and the OSGi service becomes an SCA service so
> that the Calculator component can wire to that TestService.
>
> There are two SCA files you to provide to model the OSGi bundle as an SCA
> component.
> * bundle.componentType to describe what OSGi services or references are
> used
> in the bundle (We potentially have better approach to introspect the OSGi
> bundle to build this up)
> * bundle.composite to configure the component, for example, setting the
> bindings.
>
> These files can be in a separate OSGi bundle than the one that owns the
> services/references.
>
> Thanks,
> Raymond
>
> From: Santiago Miguel Aranda Rojas
> Sent: Monday, June 15, 2009 4:01 AM
> To: user@tuscany.apache.org
> Subject: Fwd: Problem with "implementation.osgi" reference
>
>
>
>
>
>
> Hi
>
>
> I can not understand this sample because there are many new concepts for
> me.
> For example "bundle.componentType". There is not too much information about
>
> that . I think I need something more simple. I have attached a picture with
>
> my idea.
>
>
> ** When my SCA service was working I had a main component
> "implementacion.java" with two references to another two components
> (implementation.java). The main component could be invoked as Web Service.
>
>
> ** Now, I want another reference to a Service (TestService in the picture)
> that was registered by another different bundle. But this is a OSGi bundle,
>
> without SCA information, Composite file nor ComponentType file. I mean it
> is
> a bundle that is registering a service in the OSGi registry. I need have a
> instance wired to this OSGi service in the class of the main Component in
> order to invoke their methods.
>
>
> TestService testService;
>
>
> //I need testService is not null in order to invoke their methods.
> testService.sayHello();
>
>
>
>
> I hope you can understand my problem. You can ask me if you want.
>
>
> Thank you very mucha
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> 2009/6/10 Raymond Feng <en...@gmail.com>
>
> Please see:
>
> https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator/
>
> https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator-operations/
>
>
> http://cwiki.apache.org/confluence/display/TUSCANYWIKI/OSGi+RFC+119+Implementation
>
> Thanks,
> Raymond
>
>
> From: Santiago Miguel Aranda Rojas
> Sent: Wednesday, June 10, 2009 12:07 AM
> To: user@tuscany.apache.org
> Subject: Re: Problem with "implementation.osgi" reference
>
>
> Yes, you are right. I was doing some different tests and I copied you a
> wrong composite. I wanted to see if the change of @target made an error in
> tuscany.  But Tuscany doesn4t recognize this error because I think it
> supposes that will be a "remote Component". I can see this in the tuscany
> trace
>
>
> ADVERTENCIA: Component reference target not found, it might be a remote
> service running elsewhere in the SCA Domain: Composite =
> {
> http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement}SensorNetworkManagement<http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement%7DSensorNetworkManagement>
> Service = PruebaComponent
>
>
>
> But it is Ok, because the component I want if an Osgi Service registered in
>
> the Osgi registry.
> I have fixed the error in @target and it is not working yet.
>
>
> Do you know any example when an <implementation.osgi> component is used?
>
>
>
>
> I have tried to change  "xmlns" tag, but it doesn4t work.
>
>
>  <sca:component name="PruebaComponent">
>        <sca:implementation.osgi
> xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
>             bundleSymbolicName="RegistroService"
>             bundleVersion="1.0.0">
>            <sca:properties service="prueba.PruebaImpl">
>            </sca:properties>
>        </sca:implementation.osgi>
>      </sca:component>
>
>
> Thank you very much.
>
>
>
> 2009/6/10 Raymond Feng <en...@gmail.com>
>
> The @target is pointing to a wrong componentName/serviceName. It should be
> "Prueba" instead of "PruebaComponent" as the component name is "Prueba".
>
>
> From: Santiago Miguel Aranda Rojas
> Sent: Tuesday, June 09, 2009 1:28 PM
> To: user@tuscany.apache.org
> Subject: Re: Problem with "implementation.osgi" reference
>
>
> Tuscany 2.02M. The last version I think. April 2009
> ----- Original Message -----
> From: Raymond Feng
> To: user@tuscany.apache.org
> Sent: Tuesday, June 09, 2009 7:12 PM
> Subject: Re: Problem with "implementation.osgi" reference
>
>
> Are you using Tuscany/SCA 2.x or 1.x?
>
>
> From: santiago.aranda@telvent.com
> Sent: Tuesday, June 09, 2009 9:15 AM
> To: user@tuscany.apache.org
> Subject: Problem with "implementation.osgi" reference
>
>
>
> Hello
>
> I want to use an osgi service as a SCA component. But I can not access to
> their methods from other Component.  I mean I have created a wired instance
>
> to the Osgi Service ($Proxy25). It is not "null" but I can not invoke to
> one
> method because an error is happening
>
> --->Unable to create SCA binding invoker for local target
> SensorNetworkManagementComponent reference prueba (bindingURI=null
> operation=sayHello)
>
> This is my composite file. I want to have to two components. The first had
> a
> reference to the second and it is normal "implementation.java". The second
> is the SCA component that is representing to the Osgi Service that I want
> to
> recover. This Osgi Service was registered in the Osgi registry by Activator
>
> class in "RegistroService" bundle.
>
> <sca:component name="SensorNetworkManagementComponent">
>    <sca:implementation.java
>
> class="es.amivital.sensornetworkmanagement.sca.SensorNetworkManagementServiceImpl"/>
>    <sca:service name="SensorNetworkManagementService">
>     <sca:binding.ws
> uri="http://localhost:8085/SensorNetworkManagementComponent"/>
>   </sca:service>
>  <sca:reference name="prueba" target="PruebaComponent"/>
>  </sca:component>
>
>
>  <sca:component name="Prueba">
>        <sca:implementation.osgi
> xmlns="http://tuscany.apache.org/xmlns/sca/1.0"
>             bundleSymbolicName="RegistroService"
>             bundleVersion="1.0.0">
>            <sca:properties service="prueba.PruebaImpl">
>            </sca:properties>
>        </sca:implementation.osgi>
> </sca:component>
>
> ***The Java code--> The first component.
>
> public class SensorNetworkManagementServiceImpl  implements
> SensorNetworkManagementService {
> private Prueba prueba;
> public Prueba getPrueba() {
> return prueba;
> }
> @Reference
> public void setPrueba(Prueba prueba) {
> this.prueba = prueba;
> }
> }
>
> **Java code       --> The second component. It is another bundle that is
> registering one simple Osgi Service. The interface was
>
> public interface Prueba {
> public abstract String sayHello();
>
> }
>
>
>
>
>
> This instance (prueba) is not null when an outside client invoke to the
> first component. But if I invoke to one method of this interface, for
> example "prueba.sayHello" I obtained the previous error.
>
> I have read something about anottations like @AllowsPassByReference or
> @Scope, but I don4t know if they are neccesary .
>
>
>

Re: Fwd: @XmlTransient

Posted by Raymond Feng <en...@gmail.com>.
Yes, you can use it.


From: Santiago Miguel Aranda Rojas 
Sent: Tuesday, June 23, 2009 11:11 AM
To: user@tuscany.apache.org 
Subject: Re: Fwd: @XmlTransient



I want to use Annotation @XmlTransient in order to filter an attribute of one class in the client response. I mean my web service is going to return a "Employee" but I dont want return its "department" attribute. Because it is neccesary in order to avoid cyclic references. Have you check if I can use these annotations using tuscany.

https://jaxb.dev.java.net/guide/Mapping_cyclic_references_to_XML.html
class Department {
  String name;
  List<Employee> employees;
}

class Employee {
  @XmlTransient
  Department department;  // parent pointer
  String name;
  
  public void afterUnmarshal(Unmarshaller u, Object parent) {
    this.department = (Department)parent;
  }
}

Re: Fwd: @XmlTransient

Posted by Santiago Miguel Aranda Rojas <sa...@gmail.com>.
I want to use Annotation @XmlTransient in order to filter an attribute of one class in the client response. I mean my web service is going to return a "Employee" but I dont want return its "department" attribute. Because it is neccesary in order to avoid cyclic references. Have you check if I can use these annotations using tuscany.

https://jaxb.dev.java.net/guide/Mapping_cyclic_references_to_XML.html
class Department {
  String name;
  List<Employee> employees;
}

class Employee {
  @XmlTransient
  Department department;  // parent pointer
  String name;
  
  public void afterUnmarshal(Unmarshaller u, Object parent) {
    this.department = (Department)parent;
  }
}

Re: Fwd: Problem with "implementation.osgi" reference

Posted by Raymond Feng <en...@gmail.com>.
How did you run it from Eclipse? Are you using Run as ... Equinox? 

Thanks,
Raymond 

From: Santiago Miguel Aranda Rojas 
Sent: Monday, June 22, 2009 3:10 AM
To: user@tuscany.apache.org 
Subject: Re: Fwd: Problem with "implementation.osgi" reference


 Hello


It seems it is working now. I have launched Tuscany bundles outside and I have installed TestService and Calculator bundle. I am using M3RC1 now. I have to do more tests but when I invoke "add" method" using a external web client, Calculator receives the request and it is able to invoke "sayHello" method from Osgi service that was published by TestService.


But I can not use Eclipse in order to launch Tuscany and doing the same example. I know what the error is. As I commented you Eclipse was having problems in order to detect SCA files located in scr/main/java/resources/sca. I had to copy these files to the project´s root. I think I have a similar error now. It is about contribution. 


***** When I use this code in order to register node in Eclipse. It works.


                   NodeFactory factory = NodeFactory.newInstance();
           String url = ContributionLocationHelper.getContributionLocation(getClass());
           Contribution contrib = new Contribution("c1", url);
           node = factory.createNode("OSGI-INF/sca/bundle.composite", contrib);
           node.start();


      This is a debug view of "read" method from "ContributionProcessor" class


         // Scan the contribution and list the artifacts contained in it
        List<Artifact> artifacts = contribution.getArtifacts();
        boolean contributionMetadata = false;
        List<String> artifactURIs = scanner.scan(contribution); --> Contribution is Contribution : c1 
                                                                               -->from: file:/C:/TuscanyWorkspace2.03M/TestService/target/classes/




        for (String artifactURI: artifactURIs) {  --> [, es, es/amivital, es/amivital/testservice,                                              es/amivital/testservice/Activator.class, es/amivital/testservice/TestService.class,  es/amivital/testservice/TestServiceImpl.class, OSGI-INF, OSGI-INF/sca, OSGI-INF/sca/bundle.componentType, OSGI-INF/sca/bundle.composite]
            URL artifactURL = scanner.getArtifactURL(contribution, artifactURI);


            // Add the deployed artifact model to the contribution
            Artifact artifact = this.contributionFactory.createArtifact();
            artifact.setURI(artifactURI);
            artifact.setLocation(artifactURL.toString());




          As you can see I put in bold letter the value of some variables. This is correct and it is working.




*****When I don´t use code in order to register node in Eclipse. It doesn´t works.


This is a debug view of "read" method from "ContributionProcessor" class


         // Scan the contribution and list the artifacts contained in it
        List<Artifact> artifacts = contribution.getArtifacts();
        boolean contributionMetadata = false;
        List<String> artifactURIs = scanner.scan(contribution); --->Contribution : TestService 
                                                                                        ---->from: bundleentry://46/




        for (String artifactURI: artifactURIs) {  --> [.classpath, .project, .settings/, .settings/org.eclipse.jdt.core.prefs, .settings/org.maven.ide.eclipse.prefs, META-INF/, META-INF/MANIFEST.MF, OSGI-INF/, OSGI-INF/.svn/, OSGI-INF/.svn/all-wcprops, OSGI-INF/.svn/entries, OSGI-INF/.svn/format, OSGI-INF/.svn/prop-base/, OSGI-INF/.svn/props/, OSGI-INF/.svn/text-base/, OSGI-INF/.svn/text-base/calculator-component.xml.svn-base, OSGI-INF/.svn/tmp/, OSGI-INF/.svn/tmp/prop-base/, OSGI-INF/.svn/tmp/props/, OSGI-INF/.svn/tmp/text-base/, OSGI-INF/sca/, OSGI-INF/sca/.svn/, OSGI-INF/sca/.svn/all-wcprops, OSGI-INF/sca/.svn/entries, OSGI-INF/sca/.svn/format, OSGI-INF/sca/.svn/prop-base/, OSGI-INF/sca/.svn/props/, OSGI-INF/sca/.svn/text-base/, OSGI-INF/sca/.svn/text-base/bundle.componentType.svn-base, OSGI-INF/sca/.svn/text-base/bundle.composite.svn-base, OSGI-INF/sca/.svn/tmp/, OSGI-INF/sca/.svn/tmp/prop-base/, OSGI-INF/sca/.svn/tmp/props/, OSGI-INF/sca/.svn/tmp/text-base/, OSGI-INF/sca/bundle.componentType, OSGI-INF/sca/bundle.composite, pom.xml, src/, src/main/, src/main/java/, src/main/java/es/, src/main/java/es/amivital/, src/main/java/es/amivital/testservice/, src/main/java/es/amivital/testservice/Activator.java, src/main/java/es/amivital/testservice/TestService.java, src/main/java/es/amivital/testservice/TestServiceImpl.java, src/main/resources/, src/main/resources/OSGI-INF/, src/main/resources/OSGI-INF/.svn/, src/main/resources/OSGI-INF/.svn/all-wcprops, src/main/resources/OSGI-INF/.svn/entries, src/main/resources/OSGI-INF/.svn/format, src/main/resources/OSGI-INF/.svn/prop-base/, src/main/resources/OSGI-INF/.svn/props/, src/main/resources/OSGI-INF/.svn/text-base/, src/main/resources/OSGI-INF/.svn/text-base/calculator-component.xml.svn-base, src/main/resources/OSGI-INF/.svn/tmp/, src/main/resources/OSGI-INF/.svn/tmp/prop-base/, src/main/resources/OSGI-INF/.svn/tmp/props/, src/main/resources/OSGI-INF/.svn/tmp/text-base/, src/main/resources/OSGI-INF/sca/, src/main/resources/OSGI-INF/sca/.svn/, src/main/resources/OSGI-INF/sca/.svn/all-wcprops, src/main/resources/OSGI-INF/sca/.svn/entries, src/main/resources/OSGI-INF/sca/.svn/format, src/main/resources/OSGI-INF/sca/.svn/prop-base/, src/main/resources/OSGI-INF/sca/.svn/props/, src/main/resources/OSGI-INF/sca/.svn/text-base/, src/main/resources/OSGI-INF/sca/.svn/text-base/bundle.componentType.svn-base, src/main/resources/OSGI-INF/sca/.svn/text-base/bundle.composite.svn-base, src/main/resources/OSGI-INF/sca/.svn/tmp/, src/main/resources/OSGI-... 
            URL artifactURL = scanner.getArtifactURL(contribution, artifactURI);


            // Add the deployed artifact model to the contribution
            Artifact artifact = this.contributionFactory.createArtifact();
            artifact.setURI(artifactURI);
            artifact.setLocation(artifactURL.toString());




          As you can see I put in bold letter the value of some variables. It is clear that contribution is not right. ArtifactsUri variable has a lot of paths without sense. This problem doesn´t exist outside Eclipse. Have you test your examples using Eclipse?? I think I have to provide info about Contribution.


I attach my test projects.




Thank you






-------------------------------------------------------











2009/6/19 Raymond Feng <en...@gmail.com>

  Hi,

  Please see my comments inline.


  BTW, can you send your testcase?  I can point you what to fix. 


  Thanks,
  Raymond

  From: Santiago Miguel Aranda Rojas

  Sent: Friday, June 19, 2009 2:37 AM 

  To: user@tuscany.apache.org
  Subject: Re: Fwd: Problem with "implementation.osgi" reference



  Hello.


  I have downloaded M3RC1 but I have the same errors. I can not run this in Eclipse but I think it is my problem. I run this distribution outside of Eclipse and all modules are running. But when I try to run my TestService bundle I have an error


  GRAVE: org.oasisopen.sca.ServiceRuntimeException: Deployment composite OSGI-INF/
  sca/bundle.composite cannot be found within contribution bundleentry://181/
  java.lang.IllegalStateException: org.oasisopen.sca.ServiceRuntimeException: Depl
  oyment composite OSGI-INF/sca/bundle.composite cannot be found within contributi
  on bundleentry://181/


  <rfeng>The isSCABundle() checking is too relaxed. We should check the existence of OSGI-INF/sca/bundle.composite or SCA-Composite header instead of any files under OSGI-INF/sca. I'm checking in a fix soon.</rfeng> 


  I think composite.file is always compulsory. It is not enough with bunde.componentType as you said. Well, I put one composite file in order to test it


  <rfeng>Please don't add the composite file if you already have the OSGi component defined in the calculator.composite</rfeng> 


  <sca:composite xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903" name="SensorNetworkManagement" targetNamespace="http://eclipse.org/TestService/src/main/resources/TestService">

   <sca:component name="TestServiceComponent">
   <sca:implementation.osgi bundleSymbolicName="TestService" bundleVersion="1.0.0"/>
   </sca:component>
  </sca:composite>


  <rfeng>You have the wrong namespace for implementation.osgi. It should be xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" and tuscany:implementation.osgi.</rfeng>

  and I have a new error. I guess tuscany doesn4t like "implementation.osgi" componenents. When I used 2.02M I had another different error. 



  ADVERTENCIA: Element {http://docs.oasis-open.org/ns/opencsa/sca/200903}implement
  ation.osgi cannot be processed. ([row,col {unknown-source}]: [4,5])
  19-jun-2009 11:05:01 org.apache.tuscany.sca.contribution.processor.ExtensibleStA
  XArtifactProcessor
  ADVERTENCIA: Element {http://docs.oasis-open.org/ns/opencsa/sca/200903}implement
  ation.osgi cannot be processed. ([row,col {unknown-source}]: [4,5])
  19-jun-2009 11:05:01 org.apache.tuscany.sca.assembly.builder.impl.ComponentConfi
  gurationBuilderImpl
  GRAVE: No implementation for component: Component = TestServiceComponent
  19-jun-2009 11:05:01 org.apache.tuscany.sca.assembly.builder.impl.CompositeBindi
  ngURIBuilderImpl
  GRAVE: No implementation for component: Component = TestServiceComponent
  19-jun-2009 11:05:01 org.apache.tuscany.sca.node.osgi.impl.NodeManager bundleSta
  rted
  GRAVE: org.oasisopen.sca.ServiceRuntimeException: No implementation for componen
  t: Component = TestServiceComponent
  java.lang.IllegalStateException: org.oasisopen.sca.ServiceRuntimeException: No i
  mplementation for component: Component = TestServiceComponent




  Besides, I think I will not be able to wire one SCA component osgi with other SCA component java so I want to try other thing. I know tuscany is using its own ClassLoader in order to load classes it needs. But my original problem was I can not share a instance of a Singleton Class between one object loaded by default osgi ClassLoader and other object loaded tuscany ClassLoader.



  <rfeng>If your SCA contribution is packaged as OSGi bundles, the classes will be loaded by OSGi. You just need to have the correct Import-Package/Export-Package.</rfeng> 


  1) I create an instance of one Class that is not modeled with Tuscany
  2) I have other Class that will be a Singleton. Only there will be one instance of this class
  3) I recover the instance of Singleton class from the instance of step 1
  4) A CalculatorImpl instance is created when someone invoke a method from WS (this is a class modeled with Tuscany)
  5) CalculatorImpl should recover the same instance of Singleton class


  But CalculatorImpl and class of step 1 were loaded by different classLoaders so they will load the Singleton Class twice. So They will have different instances of Singleton class although it was a singleton.











  2009/6/18 Santiago Miguel Aranda Rojas <sa...@gmail.com>

  Well I will try M3RC1 tomorrow. I hope fix some errors with that

  Thank you




  ----- Original Message ----- From: Raymond Feng
  To: user@tuscany.apache.org ; santiago.aranda@telvent.com
  Sent: Thursday, June 18, 2009 5:47 PM
  Subject: Re: Fwd: Problem with "implementation.osgi" reference


  Which level of the Tuscany 2.x code are you using? The various issues you ran into seem to have been fixed before. Can you try our M3 RC1?

  http://people.apache.org/~antelder/tuscany/2.0-M3-RC1/

  Thanks,
  Raymond


  From: Santiago Miguel Aranda Rojas
  Sent: Thursday, June 18, 2009 3:05 AM
  To: user@tuscany.apache.org
  Subject: Re: Fwd: Problem with "implementation.osgi" reference


  I am checking your comments. I can not remove bundle.composite file from TestService bundle because tuscany is not working without this file.


  I have this


  Caused by: java.lang.NullPointerException
  at org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl.configureNode(NodeFactoryImpl.java:440)
  at org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl.access$2(NodeFactoryImpl.java:351)
  at org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl$NodeImpl.<init>(NodeFactoryImpl.java:574)


  and the source code about this line is


  if (composite == null) {
            composite = getDefaultComposite(configuration, workspace);
        }


        // Find the composite in the given contributions
        boolean found = false;
        Artifact compositeFile = contributionFactory.createArtifact();
        compositeFile.setUnresolved(true);
        compositeFile.setURI(composite.getURI());
        for (Contribution contribution : workspace.getContributions()) {
            ModelResolver resolver = contribution.getModelResolver();
            //            for (Artifact artifact : contribution.getArtifacts()){
            //                logger.log(Level.INFO,"artifact - " + artifact.getURI());
            //            }
            Artifact resolvedArtifact = resolver.resolveModel(Artifact.class, compositeFile);
            //            if (!resolvedArtifact.isUnresolved() && resolvedArtifact.getModel() instanceof Composite) {


            if (!composite.isUnresolved()) {  ---> This is line 440


                // The composite content was passed into the node and read into a composite model,
                // don't use the composite found in the contribution, use that composite, but just resolve
                // it within the context of the contribution
                compositeProcessor.resolve(composite, resolver);


            } else {


                // Use the resolved composite we've found in the contribution
                composite = (Composite)resolvedArtifact.getModel();
            }
            found = true;
            //            break;
            //          }
        }




  I guess composite variable is not null in the first iteration. But it is null when composite = (Composite)resolvedArtifact.getModel(); is executed. So I guess is another problem related with "contribution" because there is a comment about that "// Use the resolved composite we've found in the contribution"


  Besides, while I fix these things I am going to use java code in order to register the SCA node. I have checked all your comments about bundle.composite and bundle.componentType at TestService and Calculator bundle. When I invoke to a method of CalculatorService with a WS client I have another problem.


  This code of CalculatorServiceImpl


  public class CalculatorServiceImpl implements CalculatorService {
  private AddService addService;
  private TestService testService;


       public int add(int param1, int param2) {
  System.out.println (testService.sayHello());  --> I have an error when this line is executed
  return addService.add(param1, param2);
  }




  public AddService getAddService() {
  return addService;
  }


  @Reference
  public void setAddService(AddService addService) {
  this.addService = addService;
  }


  public TestService getTestService() {
  return testService;
  }


  @Reference
  public void setTestService(TestService testService) {
  this.testService = testService;
  }
  }




  This is the error . The testService instance is not null but it is not wired to TestService.  I have registered the Osgi Service registry using this code in the Activator of TestService bundle. I think this is neccesary.


  arg0.registerService(TestService.class.getName(), new TestServiceImpl(), null);






  Caused by: org.oasisopen.sca.ServiceUnavailableException: Unable to create SCA binding invoker for local target CalculatorComponent reference testService (bindingURI=null operation=sayHello)
  at org.apache.tuscany.sca.binding.sca.provider.RuntimeSCAReferenceBindingProvider.createInvoker(RuntimeSCAReferenceBindingProvider.java:200)






  ---------------------------------------------





  2009/6/17 Raymond Feng <en...@gmail.com>

  Hi,

  Please see my comments inline.

  Thanks,
  Raymond


  ------------------------------------
  BUNDLE CALCULATOR
  ------------------------------------
  *****OSGI-INF/sca/bundle.composite. Two java components (Calculator and AddService) and one OSGi component (TestService)


  <rfeng>This is good.</rfeng>



  <sca:composite xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903" name="SensorNetworkManagement" targetNamespace="http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement">

  <sca:component name="CalculatorComponent">
   <sca:implementation.java class="es.amivital.calculatorservice2.CalculatorServiceImpl"/>
   <sca:service name="CalculatorService">
  <sca:binding.ws uri="http://localhost:8085/CalculatorComponent"/>
   </sca:service>

   <sca:reference name="addService" target="AddServiceComponent"/>
   <sca:reference name="testService" target="TestServiceComponent/TestService"/>
  </sca:component>


  <sca:component name="AddServiceComponent">
   <sca:implementation.java class="es.amivital.calculatorservice2.AddServiceImpl"/>
  </sca:component>

  <sca:component name="TestServiceComponent">
  <sca:implementation.osgi bundleSymbolicName="TestService" bundleVersion="1.0.0"/>
  </sca:component>
  </sca:composite>




  *******OSGI-INF/sca/bundle.componentType

  <rfeng>You don't need to provide this file. The componentType is only needed for the OSGi component.</rfeng>



  <componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1">
   <!-- The service elment defines an SCA view of the OSGi service -->
   <service name="CalculatorService">
      <!-- The interface will be mapped into the OSGi service class -->
      <interface.java interface="es.amivital.calculatorservice2.CalculatorService"/>
      <!-- The list of OSGi properties -->

   </service>
  </componentType>

  -----------------------------------
  BUNDLE TESTSERVICE
  -------------------------------------


  *******OSGI-INF/sca/bundle.componentType

  <rfeng>This is good.</rfeng>



  <componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1">
   <!-- The service elment defines an SCA view of the OSGi service -->
   <service name="TestService">
      <!-- The interface will be mapped into the OSGi service class -->
      <interface.java interface="es.amivital.testservice.Test"/>
      <!-- The list of OSGi properties -->

   </service>
  </componentType>


  *****OSGI-INF/sca/bundle.composite

  <rfeng>This should be removed as the TestServiceComponent has been declared in the calculator bundle composite.</rfeng>


  <sca:composite xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903" name="SensorNetworkManagement" targetNamespace="http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement">

  <sca:component name="TestServiceComponent">
  <sca:implementation.java class="es.amivital.testservice.TestImpl"/>
  </sca:component>
  </sca:composite>



  It is necessary to have a bundle.composite file in TestService?? and bundle.componentType?? Can I remove these files from TestService bundle and put the TestService4s bundle.componentType in the Calculator bundle. You said "Alternatively, you have place the file as OSGI-INF/sca/<bundleSymbolicName>/bundle.componentType in the calculator bundle." Do you mean I can copy TestService4s bundle.componentType into a CalculatorService bundle?

  <rfeng>Yes</rfeng>



  Thank you very much
  -------------------------------------------------------------------





  Tuscany checks the OSGi bundle based on one of the following patterns:
  * An "SCA-Composite" header in the MANIFEST.MF. It points to an SCA composite file within the bundle.
  * Any files under OSGI-INF/sca.

  In your case, the first bundle contains three java components. The second bundle contains one OSGi component.  There are a few options to get them work together (CalculatorService with a reference to TestService).

  Option 1:
  1) Place bundle.composite under OSGI-INF/sca in the calculator bundle. The composite contains 4 components: 3 java components and 1 OSGi component.
  The @target for CalculatorService component's testService reference will be TestService/<serviceName>.

  2) Place bundle.componentType under OSGI-INF/sca in the test service bundle.
  Alternatively, you have place the file as OSGI-INF/sca/<bundleSymbolicName>/bundle.componentType in the calculator bundle.

  In this case, we are going to start one Node.

  Option 2:
  1) Place bundle.composite under OSGI-INF/sca in the calculator bundle. The composite contains 3 java components
  2) Place bundle.composite under OSGI-INF/sca in the test service bundle. The composite contains 1 OSGi component.
  3) Place bundle.componentType under OSGI-INF/sca in the test service bundle.

  In this case, we are going to start two nodes. You can configure the CalculatorService.testService reference and the OSGi service to use the same binding (such as RMI, or WS) to communicate. Make sure the interface is remotable. binding.sca is not working yet.

  Thanks,
  Raymond


  From: santiago.aranda@telvent.com

  Sent: Tuesday, June 16, 2009 1:33 AM

  To: user@tuscany.apache.org

  Subject: Re: Fwd: Problem with "implementation.osgi" reference




  So, I have to attach two files (componentType and composite) to my two different bundles (TestService and Calculator) and model it as "implementation.osgi".   I have TestService in a bundle I will add these two file and I will design as "implementation.osgi" .

  But Calculator Service (this is in other bundle) has three components and they are all "implementation.java" and it is working OK. How can I put a reference to TestService?? Do I need change "implementation.osgi" in CalculatorComponent instead "implementation.java"? and is it neccesary for AddServiceComponent and SubstractService??

  I will try a example I will copy my files in the email.

  Thank you very much

  Un saludo.
  Santiago Miguel Aranda Rojas
  Telvent Interactiva
  Extension: 35999
  Telefono: 955637418


  "Raymond Feng" <en...@gmail.com>
  "Raymond Feng"
  15/06/2009 18:36
  Para: <us...@tuscany.apache.org>, <sa...@telvent.com>
  cc:
  Asunto: Re: Fwd: Problem with "implementation.osgi" reference




  To access an OSGi service from the SCA component, you will have to provide
  SCA configurations for the OSGi bundle so that it becomes an SCA component
  using implementation.osgi and the OSGi service becomes an SCA service so
  that the Calculator component can wire to that TestService.

  There are two SCA files you to provide to model the OSGi bundle as an SCA
  component.
  * bundle.componentType to describe what OSGi services or references are used
  in the bundle (We potentially have better approach to introspect the OSGi
  bundle to build this up)
  * bundle.composite to configure the component, for example, setting the
  bindings.

  These files can be in a separate OSGi bundle than the one that owns the
  services/references.

  Thanks,
  Raymond

  From: Santiago Miguel Aranda Rojas
  Sent: Monday, June 15, 2009 4:01 AM
  To: user@tuscany.apache.org
  Subject: Fwd: Problem with "implementation.osgi" reference






  Hi


  I can not understand this sample because there are many new concepts for me.
  For example "bundle.componentType". There is not too much information about
  that . I think I need something more simple. I have attached a picture with
  my idea.


  ** When my SCA service was working I had a main component
  "implementacion.java" with two references to another two components
  (implementation.java). The main component could be invoked as Web Service.


  ** Now, I want another reference to a Service (TestService in the picture)
  that was registered by another different bundle. But this is a OSGi bundle,
  without SCA information, Composite file nor ComponentType file. I mean it is
  a bundle that is registering a service in the OSGi registry. I need have a
  instance wired to this OSGi service in the class of the main Component in
  order to invoke their methods.


  TestService testService;


  //I need testService is not null in order to invoke their methods.
  testService.sayHello();




  I hope you can understand my problem. You can ask me if you want.


  Thank you very mucha

















  2009/6/10 Raymond Feng <en...@gmail.com>

  Please see:

  https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator/
  https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator-operations/

  http://cwiki.apache.org/confluence/display/TUSCANYWIKI/OSGi+RFC+119+Implementation

  Thanks,
  Raymond


  From: Santiago Miguel Aranda Rojas
  Sent: Wednesday, June 10, 2009 12:07 AM
  To: user@tuscany.apache.org
  Subject: Re: Problem with "implementation.osgi" reference


  Yes, you are right. I was doing some different tests and I copied you a
  wrong composite. I wanted to see if the change of @target made an error in
  tuscany.  But Tuscany doesn4t recognize this error because I think it
  supposes that will be a "remote Component". I can see this in the tuscany
  trace


  ADVERTENCIA: Component reference target not found, it might be a remote
  service running elsewhere in the SCA Domain: Composite =
  {http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement}SensorNetworkManagement
  Service = PruebaComponent



  But it is Ok, because the component I want if an Osgi Service registered in
  the Osgi registry.
  I have fixed the error in @target and it is not working yet.


  Do you know any example when an <implementation.osgi> component is used?




  I have tried to change  "xmlns" tag, but it doesn4t work.


  <sca:component name="PruebaComponent">
   <sca:implementation.osgi
  xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
        bundleSymbolicName="RegistroService"
        bundleVersion="1.0.0">
       <sca:properties service="prueba.PruebaImpl">
       </sca:properties>
   </sca:implementation.osgi>
  </sca:component>


  Thank you very much.



  2009/6/10 Raymond Feng <en...@gmail.com>

  The @target is pointing to a wrong componentName/serviceName. It should be
  "Prueba" instead of "PruebaComponent" as the component name is "Prueba".


  From: Santiago Miguel Aranda Rojas
  Sent: Tuesday, June 09, 2009 1:28 PM
  To: user@tuscany.apache.org
  Subject: Re: Problem with "implementation.osgi" reference


  Tuscany 2.02M. The last version I think. April 2009
  ----- Original Message ----- From: Raymond Feng
  To: user@tuscany.apache.org
  Sent: Tuesday, June 09, 2009 7:12 PM
  Subject: Re: Problem with "implementation.osgi" reference


  Are you using Tuscany/SCA 2.x or 1.x?


  From: santiago.aranda@telvent.com
  Sent: Tuesday, June 09, 2009 9:15 AM
  To: user@tuscany.apache.org
  Subject: Problem with "implementation.osgi" reference



  Hello

  I want to use an osgi service as a SCA component. But I can not access to
  their methods from other Component.  I mean I have created a wired instance
  to the Osgi Service ($Proxy25). It is not "null" but I can not invoke to one
  method because an error is happening

  --->Unable to create SCA binding invoker for local target
  SensorNetworkManagementComponent reference prueba (bindingURI=null
  operation=sayHello)

  This is my composite file. I want to have to two components. The first had a
  reference to the second and it is normal "implementation.java". The second
  is the SCA component that is representing to the Osgi Service that I want to
  recover. This Osgi Service was registered in the Osgi registry by Activator
  class in "RegistroService" bundle.

  <sca:component name="SensorNetworkManagementComponent">
  <sca:implementation.java
  class="es.amivital.sensornetworkmanagement.sca.SensorNetworkManagementServiceImpl"/>
  <sca:service name="SensorNetworkManagementService">
  <sca:binding.ws
  uri="http://localhost:8085/SensorNetworkManagementComponent"/>
  </sca:service>
  <sca:reference name="prueba" target="PruebaComponent"/>
  </sca:component>


  <sca:component name="Prueba">
   <sca:implementation.osgi
  xmlns="http://tuscany.apache.org/xmlns/sca/1.0"
        bundleSymbolicName="RegistroService"
        bundleVersion="1.0.0">
       <sca:properties service="prueba.PruebaImpl">
       </sca:properties>
   </sca:implementation.osgi>
  </sca:component>

  ***The Java code--> The first component.

  public class SensorNetworkManagementServiceImpl  implements
  SensorNetworkManagementService {
  private Prueba prueba;
  public Prueba getPrueba() {
  return prueba;
  }
  @Reference
  public void setPrueba(Prueba prueba) {
  this.prueba = prueba;
  }
  }

  **Java code       --> The second component. It is another bundle that is
  registering one simple Osgi Service. The interface was

  public interface Prueba {
  public abstract String sayHello();

  }





  This instance (prueba) is not null when an outside client invoke to the
  first component. But if I invoke to one method of this interface, for
  example "prueba.sayHello" I obtained the previous error.

  I have read something about anottations like @AllowsPassByReference or
  @Scope, but I don4t know if they are neccesary . 


Re: Fwd: Problem with "implementation.osgi" reference

Posted by Raymond Feng <en...@gmail.com>.
I can reproduce the problem now. It's related to how we scan an OSGi bundle. The invalid entries are added from nesting jars. I'm adding code to check if the nested jar is on the bundle classpath to decide if we recursively scan it. I'll check in a fix soon.

Thanks,
Raymond


From: Santiago Miguel Aranda Rojas 
Sent: Monday, June 22, 2009 3:10 AM
To: user@tuscany.apache.org 
Subject: Re: Fwd: Problem with "implementation.osgi" reference


 Hello


It seems it is working now. I have launched Tuscany bundles outside and I have installed TestService and Calculator bundle. I am using M3RC1 now. I have to do more tests but when I invoke "add" method" using a external web client, Calculator receives the request and it is able to invoke "sayHello" method from Osgi service that was published by TestService.


But I can not use Eclipse in order to launch Tuscany and doing the same example. I know what the error is. As I commented you Eclipse was having problems in order to detect SCA files located in scr/main/java/resources/sca. I had to copy these files to the project´s root. I think I have a similar error now. It is about contribution. 


***** When I use this code in order to register node in Eclipse. It works.


                   NodeFactory factory = NodeFactory.newInstance();
           String url = ContributionLocationHelper.getContributionLocation(getClass());
           Contribution contrib = new Contribution("c1", url);
           node = factory.createNode("OSGI-INF/sca/bundle.composite", contrib);
           node.start();


      This is a debug view of "read" method from "ContributionProcessor" class


         // Scan the contribution and list the artifacts contained in it
        List<Artifact> artifacts = contribution.getArtifacts();
        boolean contributionMetadata = false;
        List<String> artifactURIs = scanner.scan(contribution); --> Contribution is Contribution : c1 
                                                                               -->from: file:/C:/TuscanyWorkspace2.03M/TestService/target/classes/




        for (String artifactURI: artifactURIs) {  --> [, es, es/amivital, es/amivital/testservice,                                              es/amivital/testservice/Activator.class, es/amivital/testservice/TestService.class,  es/amivital/testservice/TestServiceImpl.class, OSGI-INF, OSGI-INF/sca, OSGI-INF/sca/bundle.componentType, OSGI-INF/sca/bundle.composite]
            URL artifactURL = scanner.getArtifactURL(contribution, artifactURI);


            // Add the deployed artifact model to the contribution
            Artifact artifact = this.contributionFactory.createArtifact();
            artifact.setURI(artifactURI);
            artifact.setLocation(artifactURL.toString());




          As you can see I put in bold letter the value of some variables. This is correct and it is working.




*****When I don´t use code in order to register node in Eclipse. It doesn´t works.


This is a debug view of "read" method from "ContributionProcessor" class


         // Scan the contribution and list the artifacts contained in it
        List<Artifact> artifacts = contribution.getArtifacts();
        boolean contributionMetadata = false;
        List<String> artifactURIs = scanner.scan(contribution); --->Contribution : TestService 
                                                                                        ---->from: bundleentry://46/




        for (String artifactURI: artifactURIs) {  --> [.classpath, .project, .settings/, .settings/org.eclipse.jdt.core.prefs, .settings/org.maven.ide.eclipse.prefs, META-INF/, META-INF/MANIFEST.MF, OSGI-INF/, OSGI-INF/.svn/, OSGI-INF/.svn/all-wcprops, OSGI-INF/.svn/entries, OSGI-INF/.svn/format, OSGI-INF/.svn/prop-base/, OSGI-INF/.svn/props/, OSGI-INF/.svn/text-base/, OSGI-INF/.svn/text-base/calculator-component.xml.svn-base, OSGI-INF/.svn/tmp/, OSGI-INF/.svn/tmp/prop-base/, OSGI-INF/.svn/tmp/props/, OSGI-INF/.svn/tmp/text-base/, OSGI-INF/sca/, OSGI-INF/sca/.svn/, OSGI-INF/sca/.svn/all-wcprops, OSGI-INF/sca/.svn/entries, OSGI-INF/sca/.svn/format, OSGI-INF/sca/.svn/prop-base/, OSGI-INF/sca/.svn/props/, OSGI-INF/sca/.svn/text-base/, OSGI-INF/sca/.svn/text-base/bundle.componentType.svn-base, OSGI-INF/sca/.svn/text-base/bundle.composite.svn-base, OSGI-INF/sca/.svn/tmp/, OSGI-INF/sca/.svn/tmp/prop-base/, OSGI-INF/sca/.svn/tmp/props/, OSGI-INF/sca/.svn/tmp/text-base/, OSGI-INF/sca/bundle.componentType, OSGI-INF/sca/bundle.composite, pom.xml, src/, src/main/, src/main/java/, src/main/java/es/, src/main/java/es/amivital/, src/main/java/es/amivital/testservice/, src/main/java/es/amivital/testservice/Activator.java, src/main/java/es/amivital/testservice/TestService.java, src/main/java/es/amivital/testservice/TestServiceImpl.java, src/main/resources/, src/main/resources/OSGI-INF/, src/main/resources/OSGI-INF/.svn/, src/main/resources/OSGI-INF/.svn/all-wcprops, src/main/resources/OSGI-INF/.svn/entries, src/main/resources/OSGI-INF/.svn/format, src/main/resources/OSGI-INF/.svn/prop-base/, src/main/resources/OSGI-INF/.svn/props/, src/main/resources/OSGI-INF/.svn/text-base/, src/main/resources/OSGI-INF/.svn/text-base/calculator-component.xml.svn-base, src/main/resources/OSGI-INF/.svn/tmp/, src/main/resources/OSGI-INF/.svn/tmp/prop-base/, src/main/resources/OSGI-INF/.svn/tmp/props/, src/main/resources/OSGI-INF/.svn/tmp/text-base/, src/main/resources/OSGI-INF/sca/, src/main/resources/OSGI-INF/sca/.svn/, src/main/resources/OSGI-INF/sca/.svn/all-wcprops, src/main/resources/OSGI-INF/sca/.svn/entries, src/main/resources/OSGI-INF/sca/.svn/format, src/main/resources/OSGI-INF/sca/.svn/prop-base/, src/main/resources/OSGI-INF/sca/.svn/props/, src/main/resources/OSGI-INF/sca/.svn/text-base/, src/main/resources/OSGI-INF/sca/.svn/text-base/bundle.componentType.svn-base, src/main/resources/OSGI-INF/sca/.svn/text-base/bundle.composite.svn-base, src/main/resources/OSGI-INF/sca/.svn/tmp/, src/main/resources/OSGI-... 
            URL artifactURL = scanner.getArtifactURL(contribution, artifactURI);


            // Add the deployed artifact model to the contribution
            Artifact artifact = this.contributionFactory.createArtifact();
            artifact.setURI(artifactURI);
            artifact.setLocation(artifactURL.toString());




          As you can see I put in bold letter the value of some variables. It is clear that contribution is not right. ArtifactsUri variable has a lot of paths without sense. This problem doesn´t exist outside Eclipse. Have you test your examples using Eclipse?? I think I have to provide info about Contribution.


I attach my test projects.




Thank you






-------------------------------------------------------











2009/6/19 Raymond Feng <en...@gmail.com>

  Hi,

  Please see my comments inline.


  BTW, can you send your testcase?  I can point you what to fix. 


  Thanks,
  Raymond

  From: Santiago Miguel Aranda Rojas

  Sent: Friday, June 19, 2009 2:37 AM 

  To: user@tuscany.apache.org
  Subject: Re: Fwd: Problem with "implementation.osgi" reference



  Hello.


  I have downloaded M3RC1 but I have the same errors. I can not run this in Eclipse but I think it is my problem. I run this distribution outside of Eclipse and all modules are running. But when I try to run my TestService bundle I have an error


  GRAVE: org.oasisopen.sca.ServiceRuntimeException: Deployment composite OSGI-INF/
  sca/bundle.composite cannot be found within contribution bundleentry://181/
  java.lang.IllegalStateException: org.oasisopen.sca.ServiceRuntimeException: Depl
  oyment composite OSGI-INF/sca/bundle.composite cannot be found within contributi
  on bundleentry://181/


  <rfeng>The isSCABundle() checking is too relaxed. We should check the existence of OSGI-INF/sca/bundle.composite or SCA-Composite header instead of any files under OSGI-INF/sca. I'm checking in a fix soon.</rfeng> 


  I think composite.file is always compulsory. It is not enough with bunde.componentType as you said. Well, I put one composite file in order to test it


  <rfeng>Please don't add the composite file if you already have the OSGi component defined in the calculator.composite</rfeng> 


  <sca:composite xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903" name="SensorNetworkManagement" targetNamespace="http://eclipse.org/TestService/src/main/resources/TestService">

   <sca:component name="TestServiceComponent">
   <sca:implementation.osgi bundleSymbolicName="TestService" bundleVersion="1.0.0"/>
   </sca:component>
  </sca:composite>


  <rfeng>You have the wrong namespace for implementation.osgi. It should be xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" and tuscany:implementation.osgi.</rfeng>

  and I have a new error. I guess tuscany doesn4t like "implementation.osgi" componenents. When I used 2.02M I had another different error. 



  ADVERTENCIA: Element {http://docs.oasis-open.org/ns/opencsa/sca/200903}implement
  ation.osgi cannot be processed. ([row,col {unknown-source}]: [4,5])
  19-jun-2009 11:05:01 org.apache.tuscany.sca.contribution.processor.ExtensibleStA
  XArtifactProcessor
  ADVERTENCIA: Element {http://docs.oasis-open.org/ns/opencsa/sca/200903}implement
  ation.osgi cannot be processed. ([row,col {unknown-source}]: [4,5])
  19-jun-2009 11:05:01 org.apache.tuscany.sca.assembly.builder.impl.ComponentConfi
  gurationBuilderImpl
  GRAVE: No implementation for component: Component = TestServiceComponent
  19-jun-2009 11:05:01 org.apache.tuscany.sca.assembly.builder.impl.CompositeBindi
  ngURIBuilderImpl
  GRAVE: No implementation for component: Component = TestServiceComponent
  19-jun-2009 11:05:01 org.apache.tuscany.sca.node.osgi.impl.NodeManager bundleSta
  rted
  GRAVE: org.oasisopen.sca.ServiceRuntimeException: No implementation for componen
  t: Component = TestServiceComponent
  java.lang.IllegalStateException: org.oasisopen.sca.ServiceRuntimeException: No i
  mplementation for component: Component = TestServiceComponent




  Besides, I think I will not be able to wire one SCA component osgi with other SCA component java so I want to try other thing. I know tuscany is using its own ClassLoader in order to load classes it needs. But my original problem was I can not share a instance of a Singleton Class between one object loaded by default osgi ClassLoader and other object loaded tuscany ClassLoader.



  <rfeng>If your SCA contribution is packaged as OSGi bundles, the classes will be loaded by OSGi. You just need to have the correct Import-Package/Export-Package.</rfeng> 


  1) I create an instance of one Class that is not modeled with Tuscany
  2) I have other Class that will be a Singleton. Only there will be one instance of this class
  3) I recover the instance of Singleton class from the instance of step 1
  4) A CalculatorImpl instance is created when someone invoke a method from WS (this is a class modeled with Tuscany)
  5) CalculatorImpl should recover the same instance of Singleton class


  But CalculatorImpl and class of step 1 were loaded by different classLoaders so they will load the Singleton Class twice. So They will have different instances of Singleton class although it was a singleton.











  2009/6/18 Santiago Miguel Aranda Rojas <sa...@gmail.com>

  Well I will try M3RC1 tomorrow. I hope fix some errors with that

  Thank you




  ----- Original Message ----- From: Raymond Feng
  To: user@tuscany.apache.org ; santiago.aranda@telvent.com
  Sent: Thursday, June 18, 2009 5:47 PM
  Subject: Re: Fwd: Problem with "implementation.osgi" reference


  Which level of the Tuscany 2.x code are you using? The various issues you ran into seem to have been fixed before. Can you try our M3 RC1?

  http://people.apache.org/~antelder/tuscany/2.0-M3-RC1/

  Thanks,
  Raymond


  From: Santiago Miguel Aranda Rojas
  Sent: Thursday, June 18, 2009 3:05 AM
  To: user@tuscany.apache.org
  Subject: Re: Fwd: Problem with "implementation.osgi" reference


  I am checking your comments. I can not remove bundle.composite file from TestService bundle because tuscany is not working without this file.


  I have this


  Caused by: java.lang.NullPointerException
  at org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl.configureNode(NodeFactoryImpl.java:440)
  at org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl.access$2(NodeFactoryImpl.java:351)
  at org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl$NodeImpl.<init>(NodeFactoryImpl.java:574)


  and the source code about this line is


  if (composite == null) {
            composite = getDefaultComposite(configuration, workspace);
        }


        // Find the composite in the given contributions
        boolean found = false;
        Artifact compositeFile = contributionFactory.createArtifact();
        compositeFile.setUnresolved(true);
        compositeFile.setURI(composite.getURI());
        for (Contribution contribution : workspace.getContributions()) {
            ModelResolver resolver = contribution.getModelResolver();
            //            for (Artifact artifact : contribution.getArtifacts()){
            //                logger.log(Level.INFO,"artifact - " + artifact.getURI());
            //            }
            Artifact resolvedArtifact = resolver.resolveModel(Artifact.class, compositeFile);
            //            if (!resolvedArtifact.isUnresolved() && resolvedArtifact.getModel() instanceof Composite) {


            if (!composite.isUnresolved()) {  ---> This is line 440


                // The composite content was passed into the node and read into a composite model,
                // don't use the composite found in the contribution, use that composite, but just resolve
                // it within the context of the contribution
                compositeProcessor.resolve(composite, resolver);


            } else {


                // Use the resolved composite we've found in the contribution
                composite = (Composite)resolvedArtifact.getModel();
            }
            found = true;
            //            break;
            //          }
        }




  I guess composite variable is not null in the first iteration. But it is null when composite = (Composite)resolvedArtifact.getModel(); is executed. So I guess is another problem related with "contribution" because there is a comment about that "// Use the resolved composite we've found in the contribution"


  Besides, while I fix these things I am going to use java code in order to register the SCA node. I have checked all your comments about bundle.composite and bundle.componentType at TestService and Calculator bundle. When I invoke to a method of CalculatorService with a WS client I have another problem.


  This code of CalculatorServiceImpl


  public class CalculatorServiceImpl implements CalculatorService {
  private AddService addService;
  private TestService testService;


       public int add(int param1, int param2) {
  System.out.println (testService.sayHello());  --> I have an error when this line is executed
  return addService.add(param1, param2);
  }




  public AddService getAddService() {
  return addService;
  }


  @Reference
  public void setAddService(AddService addService) {
  this.addService = addService;
  }


  public TestService getTestService() {
  return testService;
  }


  @Reference
  public void setTestService(TestService testService) {
  this.testService = testService;
  }
  }




  This is the error . The testService instance is not null but it is not wired to TestService.  I have registered the Osgi Service registry using this code in the Activator of TestService bundle. I think this is neccesary.


  arg0.registerService(TestService.class.getName(), new TestServiceImpl(), null);






  Caused by: org.oasisopen.sca.ServiceUnavailableException: Unable to create SCA binding invoker for local target CalculatorComponent reference testService (bindingURI=null operation=sayHello)
  at org.apache.tuscany.sca.binding.sca.provider.RuntimeSCAReferenceBindingProvider.createInvoker(RuntimeSCAReferenceBindingProvider.java:200)






  ---------------------------------------------





  2009/6/17 Raymond Feng <en...@gmail.com>

  Hi,

  Please see my comments inline.

  Thanks,
  Raymond


  ------------------------------------
  BUNDLE CALCULATOR
  ------------------------------------
  *****OSGI-INF/sca/bundle.composite. Two java components (Calculator and AddService) and one OSGi component (TestService)


  <rfeng>This is good.</rfeng>



  <sca:composite xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903" name="SensorNetworkManagement" targetNamespace="http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement">

  <sca:component name="CalculatorComponent">
   <sca:implementation.java class="es.amivital.calculatorservice2.CalculatorServiceImpl"/>
   <sca:service name="CalculatorService">
  <sca:binding.ws uri="http://localhost:8085/CalculatorComponent"/>
   </sca:service>

   <sca:reference name="addService" target="AddServiceComponent"/>
   <sca:reference name="testService" target="TestServiceComponent/TestService"/>
  </sca:component>


  <sca:component name="AddServiceComponent">
   <sca:implementation.java class="es.amivital.calculatorservice2.AddServiceImpl"/>
  </sca:component>

  <sca:component name="TestServiceComponent">
  <sca:implementation.osgi bundleSymbolicName="TestService" bundleVersion="1.0.0"/>
  </sca:component>
  </sca:composite>




  *******OSGI-INF/sca/bundle.componentType

  <rfeng>You don't need to provide this file. The componentType is only needed for the OSGi component.</rfeng>



  <componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1">
   <!-- The service elment defines an SCA view of the OSGi service -->
   <service name="CalculatorService">
      <!-- The interface will be mapped into the OSGi service class -->
      <interface.java interface="es.amivital.calculatorservice2.CalculatorService"/>
      <!-- The list of OSGi properties -->

   </service>
  </componentType>

  -----------------------------------
  BUNDLE TESTSERVICE
  -------------------------------------


  *******OSGI-INF/sca/bundle.componentType

  <rfeng>This is good.</rfeng>



  <componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1">
   <!-- The service elment defines an SCA view of the OSGi service -->
   <service name="TestService">
      <!-- The interface will be mapped into the OSGi service class -->
      <interface.java interface="es.amivital.testservice.Test"/>
      <!-- The list of OSGi properties -->

   </service>
  </componentType>


  *****OSGI-INF/sca/bundle.composite

  <rfeng>This should be removed as the TestServiceComponent has been declared in the calculator bundle composite.</rfeng>


  <sca:composite xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903" name="SensorNetworkManagement" targetNamespace="http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement">

  <sca:component name="TestServiceComponent">
  <sca:implementation.java class="es.amivital.testservice.TestImpl"/>
  </sca:component>
  </sca:composite>



  It is necessary to have a bundle.composite file in TestService?? and bundle.componentType?? Can I remove these files from TestService bundle and put the TestService4s bundle.componentType in the Calculator bundle. You said "Alternatively, you have place the file as OSGI-INF/sca/<bundleSymbolicName>/bundle.componentType in the calculator bundle." Do you mean I can copy TestService4s bundle.componentType into a CalculatorService bundle?

  <rfeng>Yes</rfeng>



  Thank you very much
  -------------------------------------------------------------------





  Tuscany checks the OSGi bundle based on one of the following patterns:
  * An "SCA-Composite" header in the MANIFEST.MF. It points to an SCA composite file within the bundle.
  * Any files under OSGI-INF/sca.

  In your case, the first bundle contains three java components. The second bundle contains one OSGi component.  There are a few options to get them work together (CalculatorService with a reference to TestService).

  Option 1:
  1) Place bundle.composite under OSGI-INF/sca in the calculator bundle. The composite contains 4 components: 3 java components and 1 OSGi component.
  The @target for CalculatorService component's testService reference will be TestService/<serviceName>.

  2) Place bundle.componentType under OSGI-INF/sca in the test service bundle.
  Alternatively, you have place the file as OSGI-INF/sca/<bundleSymbolicName>/bundle.componentType in the calculator bundle.

  In this case, we are going to start one Node.

  Option 2:
  1) Place bundle.composite under OSGI-INF/sca in the calculator bundle. The composite contains 3 java components
  2) Place bundle.composite under OSGI-INF/sca in the test service bundle. The composite contains 1 OSGi component.
  3) Place bundle.componentType under OSGI-INF/sca in the test service bundle.

  In this case, we are going to start two nodes. You can configure the CalculatorService.testService reference and the OSGi service to use the same binding (such as RMI, or WS) to communicate. Make sure the interface is remotable. binding.sca is not working yet.

  Thanks,
  Raymond


  From: santiago.aranda@telvent.com

  Sent: Tuesday, June 16, 2009 1:33 AM

  To: user@tuscany.apache.org

  Subject: Re: Fwd: Problem with "implementation.osgi" reference




  So, I have to attach two files (componentType and composite) to my two different bundles (TestService and Calculator) and model it as "implementation.osgi".   I have TestService in a bundle I will add these two file and I will design as "implementation.osgi" .

  But Calculator Service (this is in other bundle) has three components and they are all "implementation.java" and it is working OK. How can I put a reference to TestService?? Do I need change "implementation.osgi" in CalculatorComponent instead "implementation.java"? and is it neccesary for AddServiceComponent and SubstractService??

  I will try a example I will copy my files in the email.

  Thank you very much

  Un saludo.
  Santiago Miguel Aranda Rojas
  Telvent Interactiva
  Extension: 35999
  Telefono: 955637418


  "Raymond Feng" <en...@gmail.com>
  "Raymond Feng"
  15/06/2009 18:36
  Para: <us...@tuscany.apache.org>, <sa...@telvent.com>
  cc:
  Asunto: Re: Fwd: Problem with "implementation.osgi" reference




  To access an OSGi service from the SCA component, you will have to provide
  SCA configurations for the OSGi bundle so that it becomes an SCA component
  using implementation.osgi and the OSGi service becomes an SCA service so
  that the Calculator component can wire to that TestService.

  There are two SCA files you to provide to model the OSGi bundle as an SCA
  component.
  * bundle.componentType to describe what OSGi services or references are used
  in the bundle (We potentially have better approach to introspect the OSGi
  bundle to build this up)
  * bundle.composite to configure the component, for example, setting the
  bindings.

  These files can be in a separate OSGi bundle than the one that owns the
  services/references.

  Thanks,
  Raymond

  From: Santiago Miguel Aranda Rojas
  Sent: Monday, June 15, 2009 4:01 AM
  To: user@tuscany.apache.org
  Subject: Fwd: Problem with "implementation.osgi" reference






  Hi


  I can not understand this sample because there are many new concepts for me.
  For example "bundle.componentType". There is not too much information about
  that . I think I need something more simple. I have attached a picture with
  my idea.


  ** When my SCA service was working I had a main component
  "implementacion.java" with two references to another two components
  (implementation.java). The main component could be invoked as Web Service.


  ** Now, I want another reference to a Service (TestService in the picture)
  that was registered by another different bundle. But this is a OSGi bundle,
  without SCA information, Composite file nor ComponentType file. I mean it is
  a bundle that is registering a service in the OSGi registry. I need have a
  instance wired to this OSGi service in the class of the main Component in
  order to invoke their methods.


  TestService testService;


  //I need testService is not null in order to invoke their methods.
  testService.sayHello();




  I hope you can understand my problem. You can ask me if you want.


  Thank you very mucha

















  2009/6/10 Raymond Feng <en...@gmail.com>

  Please see:

  https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator/
  https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator-operations/

  http://cwiki.apache.org/confluence/display/TUSCANYWIKI/OSGi+RFC+119+Implementation

  Thanks,
  Raymond


  From: Santiago Miguel Aranda Rojas
  Sent: Wednesday, June 10, 2009 12:07 AM
  To: user@tuscany.apache.org
  Subject: Re: Problem with "implementation.osgi" reference


  Yes, you are right. I was doing some different tests and I copied you a
  wrong composite. I wanted to see if the change of @target made an error in
  tuscany.  But Tuscany doesn4t recognize this error because I think it
  supposes that will be a "remote Component". I can see this in the tuscany
  trace


  ADVERTENCIA: Component reference target not found, it might be a remote
  service running elsewhere in the SCA Domain: Composite =
  {http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement}SensorNetworkManagement
  Service = PruebaComponent



  But it is Ok, because the component I want if an Osgi Service registered in
  the Osgi registry.
  I have fixed the error in @target and it is not working yet.


  Do you know any example when an <implementation.osgi> component is used?




  I have tried to change  "xmlns" tag, but it doesn4t work.


  <sca:component name="PruebaComponent">
   <sca:implementation.osgi
  xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
        bundleSymbolicName="RegistroService"
        bundleVersion="1.0.0">
       <sca:properties service="prueba.PruebaImpl">
       </sca:properties>
   </sca:implementation.osgi>
  </sca:component>


  Thank you very much.



  2009/6/10 Raymond Feng <en...@gmail.com>

  The @target is pointing to a wrong componentName/serviceName. It should be
  "Prueba" instead of "PruebaComponent" as the component name is "Prueba".


  From: Santiago Miguel Aranda Rojas
  Sent: Tuesday, June 09, 2009 1:28 PM
  To: user@tuscany.apache.org
  Subject: Re: Problem with "implementation.osgi" reference


  Tuscany 2.02M. The last version I think. April 2009
  ----- Original Message ----- From: Raymond Feng
  To: user@tuscany.apache.org
  Sent: Tuesday, June 09, 2009 7:12 PM
  Subject: Re: Problem with "implementation.osgi" reference


  Are you using Tuscany/SCA 2.x or 1.x?


  From: santiago.aranda@telvent.com
  Sent: Tuesday, June 09, 2009 9:15 AM
  To: user@tuscany.apache.org
  Subject: Problem with "implementation.osgi" reference



  Hello

  I want to use an osgi service as a SCA component. But I can not access to
  their methods from other Component.  I mean I have created a wired instance
  to the Osgi Service ($Proxy25). It is not "null" but I can not invoke to one
  method because an error is happening

  --->Unable to create SCA binding invoker for local target
  SensorNetworkManagementComponent reference prueba (bindingURI=null
  operation=sayHello)

  This is my composite file. I want to have to two components. The first had a
  reference to the second and it is normal "implementation.java". The second
  is the SCA component that is representing to the Osgi Service that I want to
  recover. This Osgi Service was registered in the Osgi registry by Activator
  class in "RegistroService" bundle.

  <sca:component name="SensorNetworkManagementComponent">
  <sca:implementation.java
  class="es.amivital.sensornetworkmanagement.sca.SensorNetworkManagementServiceImpl"/>
  <sca:service name="SensorNetworkManagementService">
  <sca:binding.ws
  uri="http://localhost:8085/SensorNetworkManagementComponent"/>
  </sca:service>
  <sca:reference name="prueba" target="PruebaComponent"/>
  </sca:component>


  <sca:component name="Prueba">
   <sca:implementation.osgi
  xmlns="http://tuscany.apache.org/xmlns/sca/1.0"
        bundleSymbolicName="RegistroService"
        bundleVersion="1.0.0">
       <sca:properties service="prueba.PruebaImpl">
       </sca:properties>
   </sca:implementation.osgi>
  </sca:component>

  ***The Java code--> The first component.

  public class SensorNetworkManagementServiceImpl  implements
  SensorNetworkManagementService {
  private Prueba prueba;
  public Prueba getPrueba() {
  return prueba;
  }
  @Reference
  public void setPrueba(Prueba prueba) {
  this.prueba = prueba;
  }
  }

  **Java code       --> The second component. It is another bundle that is
  registering one simple Osgi Service. The interface was

  public interface Prueba {
  public abstract String sayHello();

  }





  This instance (prueba) is not null when an outside client invoke to the
  first component. But if I invoke to one method of this interface, for
  example "prueba.sayHello" I obtained the previous error.

  I have read something about anottations like @AllowsPassByReference or
  @Scope, but I don4t know if they are neccesary . 


Re: Fwd: Problem with "implementation.osgi" reference

Posted by Santiago Miguel Aranda Rojas <sa...@gmail.com>.
 Hello

It seems it is working now. I have launched Tuscany bundles outside and I
have installed TestService and Calculator bundle. I am using M3RC1 now. I
have to do more tests but when I invoke "add" method" using a external web
client, Calculator receives the request and it is able to invoke "sayHello"
method from Osgi service that was published by TestService.

But I can not use Eclipse in order to launch Tuscany and doing the same
example. I know what the error is. As I commented you Eclipse was having
problems in order to detect SCA files located in
scr/main/java/resources/sca. I had to copy these files to the project´s
root. I think I have a similar error now. It is about contribution.

***** When I use this code in order to register node in Eclipse. It works.

                   NodeFactory factory = NodeFactory.newInstance();
            String url =
ContributionLocationHelper.getContributionLocation(getClass());
            Contribution contrib = new Contribution("c1", url);
            node = factory.createNode("OSGI-INF/sca/bundle.composite",
contrib);
            node.start();

      This is a debug view of "read" method from "ContributionProcessor"
class

         // Scan the contribution and list the artifacts contained in it
        List<Artifact> artifacts = contribution.getArtifacts();
        boolean contributionMetadata = false;
        List<String> artifactURIs = scanner.scan(contribution);* -->
Contribution is Contribution : c1*

  *-->from: file:/C:/TuscanyWorkspace2.03M/TestService/target/classes/*
*
*
*
*
        for (String artifactURI: artifactURIs) {  --> *[, es, es/amivital,
es/amivital/testservice,
 es/amivital/testservice/Activator.class,
es/amivital/testservice/TestService.class,
 es/amivital/testservice/TestServiceImpl.class, OSGI-INF, OSGI-INF/sca,
OSGI-INF/sca/bundle.componentType, OSGI-INF/sca/bundle.composite]*
            URL artifactURL = scanner.getArtifactURL(contribution,
artifactURI);

            // Add the deployed artifact model to the contribution
            Artifact artifact = this.contributionFactory.createArtifact();
            artifact.setURI(artifactURI);
            artifact.setLocation(artifactURL.toString());


          As you can see I put in bold letter the value of some variables.
This is correct and it is working.


*****When I don´t use code in order to register node in Eclipse. It doesn´t
works.

This is a debug view of "read" method from "ContributionProcessor" class

         // Scan the contribution and list the artifacts contained in it
        List<Artifact> artifacts = contribution.getArtifacts();
        boolean contributionMetadata = false;
        List<String> artifactURIs = scanner.scan(contribution);*
--->Contribution
: TestService *
*
             ---->from: bundleentry://46/*
*
*
*
*
        for (String artifactURI: artifactURIs) {  --> *[.classpath,
.project, .settings/, .settings/org.eclipse.jdt.core.prefs,
.settings/org.maven.ide.eclipse.prefs, META-INF/, META-INF/MANIFEST.MF,
OSGI-INF/, OSGI-INF/.svn/, OSGI-INF/.svn/all-wcprops, OSGI-INF/.svn/entries,
OSGI-INF/.svn/format, OSGI-INF/.svn/prop-base/, OSGI-INF/.svn/props/,
OSGI-INF/.svn/text-base/,
OSGI-INF/.svn/text-base/calculator-component.xml.svn-base,
OSGI-INF/.svn/tmp/, OSGI-INF/.svn/tmp/prop-base/, OSGI-INF/.svn/tmp/props/,
OSGI-INF/.svn/tmp/text-base/, OSGI-INF/sca/, OSGI-INF/sca/.svn/,
OSGI-INF/sca/.svn/all-wcprops, OSGI-INF/sca/.svn/entries,
OSGI-INF/sca/.svn/format, OSGI-INF/sca/.svn/prop-base/,
OSGI-INF/sca/.svn/props/, OSGI-INF/sca/.svn/text-base/,
OSGI-INF/sca/.svn/text-base/bundle.componentType.svn-base,
OSGI-INF/sca/.svn/text-base/bundle.composite.svn-base,
OSGI-INF/sca/.svn/tmp/, OSGI-INF/sca/.svn/tmp/prop-base/,
OSGI-INF/sca/.svn/tmp/props/, OSGI-INF/sca/.svn/tmp/text-base/,
OSGI-INF/sca/bundle.componentType, OSGI-INF/sca/bundle.composite, pom.xml,
src/, src/main/, src/main/java/, src/main/java/es/,
src/main/java/es/amivital/, src/main/java/es/amivital/testservice/,
src/main/java/es/amivital/testservice/Activator.java,
src/main/java/es/amivital/testservice/TestService.java,
src/main/java/es/amivital/testservice/TestServiceImpl.java,
src/main/resources/, src/main/resources/OSGI-INF/,
src/main/resources/OSGI-INF/.svn/,
src/main/resources/OSGI-INF/.svn/all-wcprops,
src/main/resources/OSGI-INF/.svn/entries,
src/main/resources/OSGI-INF/.svn/format,
src/main/resources/OSGI-INF/.svn/prop-base/,
src/main/resources/OSGI-INF/.svn/props/,
src/main/resources/OSGI-INF/.svn/text-base/,
src/main/resources/OSGI-INF/.svn/text-base/calculator-component.xml.svn-base,
src/main/resources/OSGI-INF/.svn/tmp/,
src/main/resources/OSGI-INF/.svn/tmp/prop-base/,
src/main/resources/OSGI-INF/.svn/tmp/props/,
src/main/resources/OSGI-INF/.svn/tmp/text-base/,
src/main/resources/OSGI-INF/sca/, src/main/resources/OSGI-INF/sca/.svn/,
src/main/resources/OSGI-INF/sca/.svn/all-wcprops,
src/main/resources/OSGI-INF/sca/.svn/entries,
src/main/resources/OSGI-INF/sca/.svn/format,
src/main/resources/OSGI-INF/sca/.svn/prop-base/,
src/main/resources/OSGI-INF/sca/.svn/props/,
src/main/resources/OSGI-INF/sca/.svn/text-base/,
src/main/resources/OSGI-INF/sca/.svn/text-base/bundle.componentType.svn-base,
src/main/resources/OSGI-INF/sca/.svn/text-base/bundle.composite.svn-base,
src/main/resources/OSGI-INF/sca/.svn/tmp/, src/main/resources/OSGI-... *
            URL artifactURL = scanner.getArtifactURL(contribution,
artifactURI);

            // Add the deployed artifact model to the contribution
            Artifact artifact = this.contributionFactory.createArtifact();
            artifact.setURI(artifactURI);
            artifact.setLocation(artifactURL.toString());


          As you can see I put in bold letter the value of some variables.
It is clear that contribution is not right. ArtifactsUri variable has a lot
of paths without sense. This problem doesn´t exist outside Eclipse. Have you
test your examples using Eclipse?? I think I have to provide info about
Contribution.

I attach my test projects.


Thank you



-------------------------------------------------------






2009/6/19 Raymond Feng <en...@gmail.com>

> Hi,
>
> Please see my comments inline.
>
> BTW, can you send your testcase?  I can point you what to fix.
>
> Thanks,
> Raymond
>
> From: Santiago Miguel Aranda Rojas
> Sent: Friday, June 19, 2009 2:37 AM
> To: user@tuscany.apache.org
> Subject: Re: Fwd: Problem with "implementation.osgi" reference
>
>
> Hello.
>
>
> I have downloaded M3RC1 but I have the same errors. I can not run this in
> Eclipse but I think it is my problem. I run this distribution outside of
> Eclipse and all modules are running. But when I try to run my TestService
> bundle I have an error
>
>
> GRAVE: org.oasisopen.sca.ServiceRuntimeException: Deployment composite
> OSGI-INF/
> sca/bundle.composite cannot be found within contribution bundleentry://181/
> java.lang.IllegalStateException: org.oasisopen.sca.ServiceRuntimeException:
> Depl
> oyment composite OSGI-INF/sca/bundle.composite cannot be found within
> contributi
> on bundleentry://181/
>
> <rfeng>The isSCABundle() checking is too relaxed. We should check the
> existence of OSGI-INF/sca/bundle.composite or SCA-Composite header instead
> of any files under OSGI-INF/sca. I'm checking in a fix soon.</rfeng>
>
> I think composite.file is always compulsory. It is not enough with
> bunde.componentType as you said. Well, I put one composite file in order to
> test it
>
> <rfeng>Please don't add the composite file if you already have the OSGi
> component defined in the calculator.composite</rfeng>
>
> <sca:composite xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
> xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
> name="SensorNetworkManagement" targetNamespace="
> http://eclipse.org/TestService/src/main/resources/TestService">
>
>  <sca:component name="TestServiceComponent">
>  <sca:implementation.osgi bundleSymbolicName="TestService"
> bundleVersion="1.0.0"/>
>  </sca:component>
> </sca:composite>
>
> <rfeng>You have the wrong namespace for implementation.osgi. It should be
> xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" and
> tuscany:implementation.osgi.</rfeng>
>
> and I have a new error. I guess tuscany doesn4t like "implementation.osgi"
> componenents. When I used 2.02M I had another different error.
>
>
> ADVERTENCIA: Element {
> http://docs.oasis-open.org/ns/opencsa/sca/200903}implement<http://docs.oasis-open.org/ns/opencsa/sca/200903%7Dimplement>
> ation.osgi cannot be processed. ([row,col {unknown-source}]: [4,5])
> 19-jun-2009 11:05:01
> org.apache.tuscany.sca.contribution.processor.ExtensibleStA
> XArtifactProcessor
> ADVERTENCIA: Element {
> http://docs.oasis-open.org/ns/opencsa/sca/200903}implement<http://docs.oasis-open.org/ns/opencsa/sca/200903%7Dimplement>
> ation.osgi cannot be processed. ([row,col {unknown-source}]: [4,5])
> 19-jun-2009 11:05:01
> org.apache.tuscany.sca.assembly.builder.impl.ComponentConfi
> gurationBuilderImpl
> GRAVE: No implementation for component: Component = TestServiceComponent
> 19-jun-2009 11:05:01
> org.apache.tuscany.sca.assembly.builder.impl.CompositeBindi
> ngURIBuilderImpl
> GRAVE: No implementation for component: Component = TestServiceComponent
> 19-jun-2009 11:05:01 org.apache.tuscany.sca.node.osgi.impl.NodeManager
> bundleSta
> rted
> GRAVE: org.oasisopen.sca.ServiceRuntimeException: No implementation for
> componen
> t: Component = TestServiceComponent
> java.lang.IllegalStateException: org.oasisopen.sca.ServiceRuntimeException:
> No i
> mplementation for component: Component = TestServiceComponent
>
>
>
>
> Besides, I think I will not be able to wire one SCA component osgi with
> other SCA component java so I want to try other thing. I know tuscany is
> using its own ClassLoader in order to load classes it needs. But my original
> problem was I can not share a instance of a Singleton Class between one
> object loaded by default osgi ClassLoader and other object loaded tuscany
> ClassLoader.
>
>
> <rfeng>If your SCA contribution is packaged as OSGi bundles, the classes
> will be loaded by OSGi. You just need to have the correct
> Import-Package/Export-Package.</rfeng>
>
>
> 1) I create an instance of one Class that is not modeled with Tuscany
> 2) I have other Class that will be a Singleton. Only there will be one
> instance of this class
> 3) I recover the instance of Singleton class from the instance of step 1
> 4) A CalculatorImpl instance is created when someone invoke a method from
> WS (this is a class modeled with Tuscany)
> 5) CalculatorImpl should recover the same instance of Singleton class
>
>
> But CalculatorImpl and class of step 1 were loaded by different
> classLoaders so they will load the Singleton Class twice. So They will have
> different instances of Singleton class although it was a singleton.
>
>
>
>
>
>
>
>
>
>
>
> 2009/6/18 Santiago Miguel Aranda Rojas <sa...@gmail.com>
>
> Well I will try M3RC1 tomorrow. I hope fix some errors with that
>
> Thank you
>
>
>
>
> ----- Original Message ----- From: Raymond Feng
> To: user@tuscany.apache.org ; santiago.aranda@telvent.com
> Sent: Thursday, June 18, 2009 5:47 PM
> Subject: Re: Fwd: Problem with "implementation.osgi" reference
>
>
> Which level of the Tuscany 2.x code are you using? The various issues you
> ran into seem to have been fixed before. Can you try our M3 RC1?
>
> http://people.apache.org/~antelder/tuscany/2.0-M3-RC1/
>
> Thanks,
> Raymond
>
>
> From: Santiago Miguel Aranda Rojas
> Sent: Thursday, June 18, 2009 3:05 AM
> To: user@tuscany.apache.org
> Subject: Re: Fwd: Problem with "implementation.osgi" reference
>
>
> I am checking your comments. I can not remove bundle.composite file from
> TestService bundle because tuscany is not working without this file.
>
>
> I have this
>
>
> Caused by: java.lang.NullPointerException
> at
> org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl.configureNode(NodeFactoryImpl.java:440)
> at
> org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl.access$2(NodeFactoryImpl.java:351)
> at
> org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl$NodeImpl.<init>(NodeFactoryImpl.java:574)
>
>
> and the source code about this line is
>
>
> if (composite == null) {
>           composite = getDefaultComposite(configuration, workspace);
>       }
>
>
>       // Find the composite in the given contributions
>       boolean found = false;
>       Artifact compositeFile = contributionFactory.createArtifact();
>       compositeFile.setUnresolved(true);
>       compositeFile.setURI(composite.getURI());
>       for (Contribution contribution : workspace.getContributions()) {
>           ModelResolver resolver = contribution.getModelResolver();
>           //            for (Artifact artifact :
> contribution.getArtifacts()){
>           //                logger.log(Level.INFO,"artifact - " +
> artifact.getURI());
>           //            }
>           Artifact resolvedArtifact = resolver.resolveModel(Artifact.class,
> compositeFile);
>           //            if (!resolvedArtifact.isUnresolved() &&
> resolvedArtifact.getModel() instanceof Composite) {
>
>
>           if (!composite.isUnresolved()) {  ---> This is line 440
>
>
>               // The composite content was passed into the node and read
> into a composite model,
>               // don't use the composite found in the contribution, use
> that composite, but just resolve
>               // it within the context of the contribution
>               compositeProcessor.resolve(composite, resolver);
>
>
>           } else {
>
>
>               // Use the resolved composite we've found in the contribution
>               composite = (Composite)resolvedArtifact.getModel();
>           }
>           found = true;
>           //            break;
>           //          }
>       }
>
>
>
>
> I guess composite variable is not null in the first iteration. But it is
> null when composite = (Composite)resolvedArtifact.getModel(); is executed.
> So I guess is another problem related with "contribution" because there is a
> comment about that "// Use the resolved composite we've found in the
> contribution"
>
>
> Besides, while I fix these things I am going to use java code in order to
> register the SCA node. I have checked all your comments about
> bundle.composite and bundle.componentType at TestService and Calculator
> bundle. When I invoke to a method of CalculatorService with a WS client I
> have another problem.
>
>
> This code of CalculatorServiceImpl
>
>
> public class CalculatorServiceImpl implements CalculatorService {
> private AddService addService;
> private TestService testService;
>
>
>      public int add(int param1, int param2) {
> System.out.println (testService.sayHello());  --> I have an error when this
> line is executed
> return addService.add(param1, param2);
> }
>
>
>
>
> public AddService getAddService() {
> return addService;
> }
>
>
> @Reference
> public void setAddService(AddService addService) {
> this.addService = addService;
> }
>
>
> public TestService getTestService() {
> return testService;
> }
>
>
> @Reference
> public void setTestService(TestService testService) {
> this.testService = testService;
> }
> }
>
>
>
>
> This is the error . The testService instance is not null but it is not
> wired to TestService.  I have registered the Osgi Service registry using
> this code in the Activator of TestService bundle. I think this is neccesary.
>
>
> arg0.registerService(TestService.class.getName(), new TestServiceImpl(),
> null);
>
>
>
>
>
>
> Caused by: org.oasisopen.sca.ServiceUnavailableException: Unable to create
> SCA binding invoker for local target CalculatorComponent reference
> testService (bindingURI=null operation=sayHello)
> at
> org.apache.tuscany.sca.binding.sca.provider.RuntimeSCAReferenceBindingProvider.createInvoker(RuntimeSCAReferenceBindingProvider.java:200)
>
>
>
>
>
>
> ---------------------------------------------
>
>
>
>
>
> 2009/6/17 Raymond Feng <en...@gmail.com>
>
> Hi,
>
> Please see my comments inline.
>
> Thanks,
> Raymond
>
>
> ------------------------------------
> BUNDLE CALCULATOR
> ------------------------------------
> *****OSGI-INF/sca/bundle.composite. Two java components (Calculator and
> AddService) and one OSGi component (TestService)
>
>
> <rfeng>This is good.</rfeng>
>
>
>
> <sca:composite xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
> xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
> name="SensorNetworkManagement" targetNamespace="
> http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement
> ">
>
> <sca:component name="CalculatorComponent">
>  <sca:implementation.java
> class="es.amivital.calculatorservice2.CalculatorServiceImpl"/>
>  <sca:service name="CalculatorService">
> <sca:binding.ws uri="http://localhost:8085/CalculatorComponent"/>
>  </sca:service>
>
>  <sca:reference name="addService" target="AddServiceComponent"/>
>  <sca:reference name="testService"
> target="TestServiceComponent/TestService"/>
> </sca:component>
>
>
> <sca:component name="AddServiceComponent">
>  <sca:implementation.java
> class="es.amivital.calculatorservice2.AddServiceImpl"/>
> </sca:component>
>
> <sca:component name="TestServiceComponent">
> <sca:implementation.osgi bundleSymbolicName="TestService"
> bundleVersion="1.0.0"/>
> </sca:component>
> </sca:composite>
>
>
>
>
> *******OSGI-INF/sca/bundle.componentType
>
> <rfeng>You don't need to provide this file. The componentType is only
> needed for the OSGi component.</rfeng>
>
>
>
> <componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
>            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>            xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1">
>  <!-- The service elment defines an SCA view of the OSGi service -->
>  <service name="CalculatorService">
>     <!-- The interface will be mapped into the OSGi service class -->
>     <interface.java
> interface="es.amivital.calculatorservice2.CalculatorService"/>
>     <!-- The list of OSGi properties -->
>
>  </service>
> </componentType>
>
> -----------------------------------
> BUNDLE TESTSERVICE
> -------------------------------------
>
>
> *******OSGI-INF/sca/bundle.componentType
>
> <rfeng>This is good.</rfeng>
>
>
>
> <componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
>            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>            xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1">
>  <!-- The service elment defines an SCA view of the OSGi service -->
>  <service name="TestService">
>     <!-- The interface will be mapped into the OSGi service class -->
>     <interface.java interface="es.amivital.testservice.Test"/>
>     <!-- The list of OSGi properties -->
>
>  </service>
> </componentType>
>
>
> *****OSGI-INF/sca/bundle.composite
>
> <rfeng>This should be removed as the TestServiceComponent has been declared
> in the calculator bundle composite.</rfeng>
>
>
> <sca:composite xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
> xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
> name="SensorNetworkManagement" targetNamespace="
> http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement
> ">
>
> <sca:component name="TestServiceComponent">
> <sca:implementation.java class="es.amivital.testservice.TestImpl"/>
> </sca:component>
> </sca:composite>
>
>
>
> It is necessary to have a bundle.composite file in TestService?? and
> bundle.componentType?? Can I remove these files from TestService bundle and
> put the TestService4s bundle.componentType in the Calculator bundle. You
> said "Alternatively, you have place the file as
> OSGI-INF/sca/<bundleSymbolicName>/bundle.componentType in the calculator
> bundle." Do you mean I can copy TestService4s bundle.componentType into a
> CalculatorService bundle?
>
> <rfeng>Yes</rfeng>
>
>
>
> Thank you very much
> -------------------------------------------------------------------
>
>
>
>
>
> Tuscany checks the OSGi bundle based on one of the following patterns:
> * An "SCA-Composite" header in the MANIFEST.MF. It points to an SCA
> composite file within the bundle.
> * Any files under OSGI-INF/sca.
>
> In your case, the first bundle contains three java components. The second
> bundle contains one OSGi component.  There are a few options to get them
> work together (CalculatorService with a reference to TestService).
>
> Option 1:
> 1) Place bundle.composite under OSGI-INF/sca in the calculator bundle. The
> composite contains 4 components: 3 java components and 1 OSGi component.
> The @target for CalculatorService component's testService reference will be
> TestService/<serviceName>.
>
> 2) Place bundle.componentType under OSGI-INF/sca in the test service
> bundle.
> Alternatively, you have place the file as
> OSGI-INF/sca/<bundleSymbolicName>/bundle.componentType in the calculator
> bundle.
>
> In this case, we are going to start one Node.
>
> Option 2:
> 1) Place bundle.composite under OSGI-INF/sca in the calculator bundle. The
> composite contains 3 java components
> 2) Place bundle.composite under OSGI-INF/sca in the test service bundle.
> The composite contains 1 OSGi component.
> 3) Place bundle.componentType under OSGI-INF/sca in the test service
> bundle.
>
> In this case, we are going to start two nodes. You can configure the
> CalculatorService.testService reference and the OSGi service to use the same
> binding (such as RMI, or WS) to communicate. Make sure the interface is
> remotable. binding.sca is not working yet.
>
> Thanks,
> Raymond
>
>
> From: santiago.aranda@telvent.com
>
> Sent: Tuesday, June 16, 2009 1:33 AM
>
> To: user@tuscany.apache.org
>
> Subject: Re: Fwd: Problem with "implementation.osgi" reference
>
>
>
>
> So, I have to attach two files (componentType and composite) to my two
> different bundles (TestService and Calculator) and model it as
> "implementation.osgi".   I have TestService in a bundle I will add these two
> file and I will design as "implementation.osgi" .
>
> But Calculator Service (this is in other bundle) has three components and
> they are all "implementation.java" and it is working OK. How can I put a
> reference to TestService?? Do I need change "implementation.osgi" in
> CalculatorComponent instead "implementation.java"? and is it neccesary for
> AddServiceComponent and SubstractService??
>
> I will try a example I will copy my files in the email.
>
> Thank you very much
>
> Un saludo.
> Santiago Miguel Aranda Rojas
> Telvent Interactiva
> Extension: 35999
> Telefono: 955637418
>
>
> "Raymond Feng" <en...@gmail.com>
> "Raymond Feng"
> 15/06/2009 18:36
> Para: <us...@tuscany.apache.org>, <sa...@telvent.com>
> cc:
> Asunto: Re: Fwd: Problem with "implementation.osgi" reference
>
>
>
>
> To access an OSGi service from the SCA component, you will have to provide
> SCA configurations for the OSGi bundle so that it becomes an SCA component
> using implementation.osgi and the OSGi service becomes an SCA service so
> that the Calculator component can wire to that TestService.
>
> There are two SCA files you to provide to model the OSGi bundle as an SCA
> component.
> * bundle.componentType to describe what OSGi services or references are
> used
> in the bundle (We potentially have better approach to introspect the OSGi
> bundle to build this up)
> * bundle.composite to configure the component, for example, setting the
> bindings.
>
> These files can be in a separate OSGi bundle than the one that owns the
> services/references.
>
> Thanks,
> Raymond
>
> From: Santiago Miguel Aranda Rojas
> Sent: Monday, June 15, 2009 4:01 AM
> To: user@tuscany.apache.org
> Subject: Fwd: Problem with "implementation.osgi" reference
>
>
>
>
>
>
> Hi
>
>
> I can not understand this sample because there are many new concepts for
> me.
> For example "bundle.componentType". There is not too much information about
> that . I think I need something more simple. I have attached a picture with
> my idea.
>
>
> ** When my SCA service was working I had a main component
> "implementacion.java" with two references to another two components
> (implementation.java). The main component could be invoked as Web Service.
>
>
> ** Now, I want another reference to a Service (TestService in the picture)
> that was registered by another different bundle. But this is a OSGi bundle,
> without SCA information, Composite file nor ComponentType file. I mean it
> is
> a bundle that is registering a service in the OSGi registry. I need have a
> instance wired to this OSGi service in the class of the main Component in
> order to invoke their methods.
>
>
> TestService testService;
>
>
> //I need testService is not null in order to invoke their methods.
> testService.sayHello();
>
>
>
>
> I hope you can understand my problem. You can ask me if you want.
>
>
> Thank you very mucha
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> 2009/6/10 Raymond Feng <en...@gmail.com>
>
> Please see:
>
> https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator/
>
> https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator-operations/
>
>
> http://cwiki.apache.org/confluence/display/TUSCANYWIKI/OSGi+RFC+119+Implementation
>
> Thanks,
> Raymond
>
>
> From: Santiago Miguel Aranda Rojas
> Sent: Wednesday, June 10, 2009 12:07 AM
> To: user@tuscany.apache.org
> Subject: Re: Problem with "implementation.osgi" reference
>
>
> Yes, you are right. I was doing some different tests and I copied you a
> wrong composite. I wanted to see if the change of @target made an error in
> tuscany.  But Tuscany doesn4t recognize this error because I think it
> supposes that will be a "remote Component". I can see this in the tuscany
> trace
>
>
> ADVERTENCIA: Component reference target not found, it might be a remote
> service running elsewhere in the SCA Domain: Composite =
> {
> http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement}SensorNetworkManagement<http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement%7DSensorNetworkManagement>
> Service = PruebaComponent
>
>
>
> But it is Ok, because the component I want if an Osgi Service registered in
> the Osgi registry.
> I have fixed the error in @target and it is not working yet.
>
>
> Do you know any example when an <implementation.osgi> component is used?
>
>
>
>
> I have tried to change  "xmlns" tag, but it doesn4t work.
>
>
> <sca:component name="PruebaComponent">
>  <sca:implementation.osgi
> xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
>       bundleSymbolicName="RegistroService"
>       bundleVersion="1.0.0">
>      <sca:properties service="prueba.PruebaImpl">
>      </sca:properties>
>  </sca:implementation.osgi>
> </sca:component>
>
>
> Thank you very much.
>
>
>
> 2009/6/10 Raymond Feng <en...@gmail.com>
>
> The @target is pointing to a wrong componentName/serviceName. It should be
> "Prueba" instead of "PruebaComponent" as the component name is "Prueba".
>
>
> From: Santiago Miguel Aranda Rojas
> Sent: Tuesday, June 09, 2009 1:28 PM
> To: user@tuscany.apache.org
> Subject: Re: Problem with "implementation.osgi" reference
>
>
> Tuscany 2.02M. The last version I think. April 2009
> ----- Original Message ----- From: Raymond Feng
> To: user@tuscany.apache.org
> Sent: Tuesday, June 09, 2009 7:12 PM
> Subject: Re: Problem with "implementation.osgi" reference
>
>
> Are you using Tuscany/SCA 2.x or 1.x?
>
>
> From: santiago.aranda@telvent.com
> Sent: Tuesday, June 09, 2009 9:15 AM
> To: user@tuscany.apache.org
> Subject: Problem with "implementation.osgi" reference
>
>
>
> Hello
>
> I want to use an osgi service as a SCA component. But I can not access to
> their methods from other Component.  I mean I have created a wired instance
> to the Osgi Service ($Proxy25). It is not "null" but I can not invoke to
> one
> method because an error is happening
>
> --->Unable to create SCA binding invoker for local target
> SensorNetworkManagementComponent reference prueba (bindingURI=null
> operation=sayHello)
>
> This is my composite file. I want to have to two components. The first had
> a
> reference to the second and it is normal "implementation.java". The second
> is the SCA component that is representing to the Osgi Service that I want
> to
> recover. This Osgi Service was registered in the Osgi registry by Activator
> class in "RegistroService" bundle.
>
> <sca:component name="SensorNetworkManagementComponent">
> <sca:implementation.java
>
> class="es.amivital.sensornetworkmanagement.sca.SensorNetworkManagementServiceImpl"/>
> <sca:service name="SensorNetworkManagementService">
> <sca:binding.ws
> uri="http://localhost:8085/SensorNetworkManagementComponent"/>
> </sca:service>
> <sca:reference name="prueba" target="PruebaComponent"/>
> </sca:component>
>
>
> <sca:component name="Prueba">
>  <sca:implementation.osgi
> xmlns="http://tuscany.apache.org/xmlns/sca/1.0"
>       bundleSymbolicName="RegistroService"
>       bundleVersion="1.0.0">
>      <sca:properties service="prueba.PruebaImpl">
>      </sca:properties>
>  </sca:implementation.osgi>
> </sca:component>
>
> ***The Java code--> The first component.
>
> public class SensorNetworkManagementServiceImpl  implements
> SensorNetworkManagementService {
> private Prueba prueba;
> public Prueba getPrueba() {
> return prueba;
> }
> @Reference
> public void setPrueba(Prueba prueba) {
> this.prueba = prueba;
> }
> }
>
> **Java code       --> The second component. It is another bundle that is
> registering one simple Osgi Service. The interface was
>
> public interface Prueba {
> public abstract String sayHello();
>
> }
>
>
>
>
>
> This instance (prueba) is not null when an outside client invoke to the
> first component. But if I invoke to one method of this interface, for
> example "prueba.sayHello" I obtained the previous error.
>
> I have read something about anottations like @AllowsPassByReference or
> @Scope, but I don4t know if they are neccesary .
>

Re: Fwd: Problem with "implementation.osgi" reference

Posted by Raymond Feng <en...@gmail.com>.
Hi,

Please see my comments inline.

BTW, can you send your testcase?  I can point you what to fix.

Thanks,
Raymond

From: Santiago Miguel Aranda Rojas
Sent: Friday, June 19, 2009 2:37 AM
To: user@tuscany.apache.org
Subject: Re: Fwd: Problem with "implementation.osgi" reference


Hello.


I have downloaded M3RC1 but I have the same errors. I can not run this in 
Eclipse but I think it is my problem. I run this distribution outside of 
Eclipse and all modules are running. But when I try to run my TestService 
bundle I have an error


GRAVE: org.oasisopen.sca.ServiceRuntimeException: Deployment composite 
OSGI-INF/
sca/bundle.composite cannot be found within contribution bundleentry://181/
java.lang.IllegalStateException: org.oasisopen.sca.ServiceRuntimeException: 
Depl
oyment composite OSGI-INF/sca/bundle.composite cannot be found within 
contributi
on bundleentry://181/

<rfeng>The isSCABundle() checking is too relaxed. We should check the 
existence of OSGI-INF/sca/bundle.composite or SCA-Composite header instead 
of any files under OSGI-INF/sca. I'm checking in a fix soon.</rfeng>

I think composite.file is always compulsory. It is not enough with 
bunde.componentType as you said. Well, I put one composite file in order to 
test it

<rfeng>Please don't add the composite file if you already have the OSGi 
component defined in the calculator.composite</rfeng>

<sca:composite xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" 
xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903" 
name="SensorNetworkManagement" 
targetNamespace="http://eclipse.org/TestService/src/main/resources/TestService">

  <sca:component name="TestServiceComponent">
   <sca:implementation.osgi bundleSymbolicName="TestService" 
bundleVersion="1.0.0"/>
  </sca:component>
</sca:composite>

<rfeng>You have the wrong namespace for implementation.osgi. It should be 
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" and 
tuscany:implementation.osgi.</rfeng>

and I have a new error. I guess tuscany doesn´t like "implementation.osgi" 
componenents. When I used 2.02M I had another different error.


ADVERTENCIA: Element 
{http://docs.oasis-open.org/ns/opencsa/sca/200903}implement
ation.osgi cannot be processed. ([row,col {unknown-source}]: [4,5])
19-jun-2009 11:05:01 
org.apache.tuscany.sca.contribution.processor.ExtensibleStA
XArtifactProcessor
ADVERTENCIA: Element 
{http://docs.oasis-open.org/ns/opencsa/sca/200903}implement
ation.osgi cannot be processed. ([row,col {unknown-source}]: [4,5])
19-jun-2009 11:05:01 
org.apache.tuscany.sca.assembly.builder.impl.ComponentConfi
gurationBuilderImpl
GRAVE: No implementation for component: Component = TestServiceComponent
19-jun-2009 11:05:01 
org.apache.tuscany.sca.assembly.builder.impl.CompositeBindi
ngURIBuilderImpl
GRAVE: No implementation for component: Component = TestServiceComponent
19-jun-2009 11:05:01 org.apache.tuscany.sca.node.osgi.impl.NodeManager 
bundleSta
rted
GRAVE: org.oasisopen.sca.ServiceRuntimeException: No implementation for 
componen
t: Component = TestServiceComponent
java.lang.IllegalStateException: org.oasisopen.sca.ServiceRuntimeException: 
No i
mplementation for component: Component = TestServiceComponent




Besides, I think I will not be able to wire one SCA component osgi with 
other SCA component java so I want to try other thing. I know tuscany is 
using its own ClassLoader in order to load classes it needs. But my original 
problem was I can not share a instance of a Singleton Class between one 
object loaded by default osgi ClassLoader and other object loaded tuscany 
ClassLoader.


<rfeng>If your SCA contribution is packaged as OSGi bundles, the classes 
will be loaded by OSGi. You just need to have the correct 
Import-Package/Export-Package.</rfeng>

1) I create an instance of one Class that is not modeled with Tuscany
2) I have other Class that will be a Singleton. Only there will be one 
instance of this class
3) I recover the instance of Singleton class from the instance of step 1
4) A CalculatorImpl instance is created when someone invoke a method from WS 
(this is a class modeled with Tuscany)
5) CalculatorImpl should recover the same instance of Singleton class


But CalculatorImpl and class of step 1 were loaded by different classLoaders 
so they will load the Singleton Class twice. So They will have different 
instances of Singleton class although it was a singleton.











2009/6/18 Santiago Miguel Aranda Rojas <sa...@gmail.com>

Well I will try M3RC1 tomorrow. I hope fix some errors with that

Thank you




----- Original Message ----- 
From: Raymond Feng
To: user@tuscany.apache.org ; santiago.aranda@telvent.com
Sent: Thursday, June 18, 2009 5:47 PM
Subject: Re: Fwd: Problem with "implementation.osgi" reference


Which level of the Tuscany 2.x code are you using? The various issues you 
ran into seem to have been fixed before. Can you try our M3 RC1?

http://people.apache.org/~antelder/tuscany/2.0-M3-RC1/

Thanks,
Raymond


From: Santiago Miguel Aranda Rojas
Sent: Thursday, June 18, 2009 3:05 AM
To: user@tuscany.apache.org
Subject: Re: Fwd: Problem with "implementation.osgi" reference


I am checking your comments. I can not remove bundle.composite file from 
TestService bundle because tuscany is not working without this file.


I have this


Caused by: java.lang.NullPointerException
at 
org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl.configureNode(NodeFactoryImpl.java:440)
at 
org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl.access$2(NodeFactoryImpl.java:351)
at 
org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl$NodeImpl.<init>(NodeFactoryImpl.java:574)


and the source code about this line is


 if (composite == null) {
            composite = getDefaultComposite(configuration, workspace);
        }


        // Find the composite in the given contributions
        boolean found = false;
        Artifact compositeFile = contributionFactory.createArtifact();
        compositeFile.setUnresolved(true);
        compositeFile.setURI(composite.getURI());
        for (Contribution contribution : workspace.getContributions()) {
            ModelResolver resolver = contribution.getModelResolver();
            //            for (Artifact artifact : 
contribution.getArtifacts()){
            //                logger.log(Level.INFO,"artifact - " + 
artifact.getURI());
            //            }
            Artifact resolvedArtifact = 
resolver.resolveModel(Artifact.class, compositeFile);
            //            if (!resolvedArtifact.isUnresolved() && 
resolvedArtifact.getModel() instanceof Composite) {


            if (!composite.isUnresolved()) {  ---> This is line 440


                // The composite content was passed into the node and read 
into a composite model,
                // don't use the composite found in the contribution, use 
that composite, but just resolve
                // it within the context of the contribution
                compositeProcessor.resolve(composite, resolver);


            } else {


                // Use the resolved composite we've found in the 
contribution
                composite = (Composite)resolvedArtifact.getModel();
            }
            found = true;
            //            break;
            //          }
        }




I guess composite variable is not null in the first iteration. But it is 
null when composite = (Composite)resolvedArtifact.getModel(); is executed. 
So I guess is another problem related with "contribution" because there is a 
comment about that "// Use the resolved composite we've found in the 
contribution"


Besides, while I fix these things I am going to use java code in order to 
register the SCA node. I have checked all your comments about 
bundle.composite and bundle.componentType at TestService and Calculator 
bundle. When I invoke to a method of CalculatorService with a WS client I 
have another problem.


This code of CalculatorServiceImpl


public class CalculatorServiceImpl implements CalculatorService {
private AddService addService;
private TestService testService;


       public int add(int param1, int param2) {
System.out.println (testService.sayHello());  --> I have an error when this 
line is executed
return addService.add(param1, param2);
}




public AddService getAddService() {
return addService;
}


@Reference
public void setAddService(AddService addService) {
this.addService = addService;
}


public TestService getTestService() {
return testService;
}


@Reference
public void setTestService(TestService testService) {
this.testService = testService;
}
}




This is the error . The testService instance is not null but it is not wired 
to TestService.  I have registered the Osgi Service registry using this code 
in the Activator of TestService bundle. I think this is neccesary.


arg0.registerService(TestService.class.getName(), new TestServiceImpl(), 
null);






Caused by: org.oasisopen.sca.ServiceUnavailableException: Unable to create 
SCA binding invoker for local target CalculatorComponent reference 
testService (bindingURI=null operation=sayHello)
at 
org.apache.tuscany.sca.binding.sca.provider.RuntimeSCAReferenceBindingProvider.createInvoker(RuntimeSCAReferenceBindingProvider.java:200)






---------------------------------------------





2009/6/17 Raymond Feng <en...@gmail.com>

Hi,

Please see my comments inline.

Thanks,
Raymond


------------------------------------
BUNDLE CALCULATOR
------------------------------------
*****OSGI-INF/sca/bundle.composite. Two java components (Calculator and 
AddService) and one OSGi component (TestService)


<rfeng>This is good.</rfeng>



<sca:composite xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" 
xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903" 
name="SensorNetworkManagement" 
targetNamespace="http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement">

 <sca:component name="CalculatorComponent">
  <sca:implementation.java 
class="es.amivital.calculatorservice2.CalculatorServiceImpl"/>
   <sca:service name="CalculatorService">
 <sca:binding.ws uri="http://localhost:8085/CalculatorComponent"/>
   </sca:service>

   <sca:reference name="addService" target="AddServiceComponent"/>
   <sca:reference name="testService" 
target="TestServiceComponent/TestService"/>
 </sca:component>


 <sca:component name="AddServiceComponent">
  <sca:implementation.java 
class="es.amivital.calculatorservice2.AddServiceImpl"/>
 </sca:component>

 <sca:component name="TestServiceComponent">
 <sca:implementation.osgi bundleSymbolicName="TestService" 
bundleVersion="1.0.0"/>
 </sca:component>
</sca:composite>




*******OSGI-INF/sca/bundle.componentType

<rfeng>You don't need to provide this file. The componentType is only needed 
for the OSGi component.</rfeng>



<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1">
  <!-- The service elment defines an SCA view of the OSGi service -->
  <service name="CalculatorService">
      <!-- The interface will be mapped into the OSGi service class -->
      <interface.java 
interface="es.amivital.calculatorservice2.CalculatorService"/>
      <!-- The list of OSGi properties -->

  </service>
</componentType>

-----------------------------------
BUNDLE TESTSERVICE
-------------------------------------


*******OSGI-INF/sca/bundle.componentType

<rfeng>This is good.</rfeng>



<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1">
  <!-- The service elment defines an SCA view of the OSGi service -->
  <service name="TestService">
      <!-- The interface will be mapped into the OSGi service class -->
      <interface.java interface="es.amivital.testservice.Test"/>
      <!-- The list of OSGi properties -->

  </service>
</componentType>


*****OSGI-INF/sca/bundle.composite

<rfeng>This should be removed as the TestServiceComponent has been declared 
in the calculator bundle composite.</rfeng>


<sca:composite xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" 
xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903" 
name="SensorNetworkManagement" 
targetNamespace="http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement">

 <sca:component name="TestServiceComponent">
 <sca:implementation.java class="es.amivital.testservice.TestImpl"/>
 </sca:component>
</sca:composite>



It is necessary to have a bundle.composite file in TestService?? and 
bundle.componentType?? Can I remove these files from TestService bundle and 
put the TestService4s bundle.componentType in the Calculator bundle. You 
said "Alternatively, you have place the file as 
OSGI-INF/sca/<bundleSymbolicName>/bundle.componentType in the calculator 
bundle." Do you mean I can copy TestService4s bundle.componentType into a 
CalculatorService bundle?

<rfeng>Yes</rfeng>



Thank you very much
-------------------------------------------------------------------





Tuscany checks the OSGi bundle based on one of the following patterns:
* An "SCA-Composite" header in the MANIFEST.MF. It points to an SCA 
composite file within the bundle.
* Any files under OSGI-INF/sca.

In your case, the first bundle contains three java components. The second 
bundle contains one OSGi component.  There are a few options to get them 
work together (CalculatorService with a reference to TestService).

Option 1:
1) Place bundle.composite under OSGI-INF/sca in the calculator bundle. The 
composite contains 4 components: 3 java components and 1 OSGi component.
The @target for CalculatorService component's testService reference will be 
TestService/<serviceName>.

2) Place bundle.componentType under OSGI-INF/sca in the test service bundle.
Alternatively, you have place the file as 
OSGI-INF/sca/<bundleSymbolicName>/bundle.componentType in the calculator 
bundle.

In this case, we are going to start one Node.

Option 2:
1) Place bundle.composite under OSGI-INF/sca in the calculator bundle. The 
composite contains 3 java components
2) Place bundle.composite under OSGI-INF/sca in the test service bundle. The 
composite contains 1 OSGi component.
3) Place bundle.componentType under OSGI-INF/sca in the test service bundle.

In this case, we are going to start two nodes. You can configure the 
CalculatorService.testService reference and the OSGi service to use the same 
binding (such as RMI, or WS) to communicate. Make sure the interface is 
remotable. binding.sca is not working yet.

Thanks,
Raymond


From: santiago.aranda@telvent.com

Sent: Tuesday, June 16, 2009 1:33 AM

To: user@tuscany.apache.org

Subject: Re: Fwd: Problem with "implementation.osgi" reference




So, I have to attach two files (componentType and composite) to my two 
different bundles (TestService and Calculator) and model it as 
"implementation.osgi".   I have TestService in a bundle I will add these two 
file and I will design as "implementation.osgi" .

But Calculator Service (this is in other bundle) has three components and 
they are all "implementation.java" and it is working OK. How can I put a 
reference to TestService?? Do I need change "implementation.osgi" in 
CalculatorComponent instead "implementation.java"? and is it neccesary for 
AddServiceComponent and SubstractService??

I will try a example I will copy my files in the email.

Thank you very much

Un saludo.
Santiago Miguel Aranda Rojas
Telvent Interactiva
Extension: 35999
Telefono: 955637418


"Raymond Feng" <en...@gmail.com>
"Raymond Feng"
15/06/2009 18:36
Para: <us...@tuscany.apache.org>, <sa...@telvent.com>
cc:
Asunto: Re: Fwd: Problem with "implementation.osgi" reference




To access an OSGi service from the SCA component, you will have to provide
SCA configurations for the OSGi bundle so that it becomes an SCA component
using implementation.osgi and the OSGi service becomes an SCA service so
that the Calculator component can wire to that TestService.

There are two SCA files you to provide to model the OSGi bundle as an SCA
component.
* bundle.componentType to describe what OSGi services or references are used
in the bundle (We potentially have better approach to introspect the OSGi
bundle to build this up)
* bundle.composite to configure the component, for example, setting the
bindings.

These files can be in a separate OSGi bundle than the one that owns the
services/references.

Thanks,
Raymond

From: Santiago Miguel Aranda Rojas
Sent: Monday, June 15, 2009 4:01 AM
To: user@tuscany.apache.org
Subject: Fwd: Problem with "implementation.osgi" reference






Hi


I can not understand this sample because there are many new concepts for me.
For example "bundle.componentType". There is not too much information about
that . I think I need something more simple. I have attached a picture with
my idea.


** When my SCA service was working I had a main component
"implementacion.java" with two references to another two components
(implementation.java). The main component could be invoked as Web Service.


** Now, I want another reference to a Service (TestService in the picture)
that was registered by another different bundle. But this is a OSGi bundle,
without SCA information, Composite file nor ComponentType file. I mean it is
a bundle that is registering a service in the OSGi registry. I need have a
instance wired to this OSGi service in the class of the main Component in
order to invoke their methods.


TestService testService;


//I need testService is not null in order to invoke their methods.
testService.sayHello();




I hope you can understand my problem. You can ask me if you want.


Thank you very mucha

















2009/6/10 Raymond Feng <en...@gmail.com>

Please see:

https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator/
https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator-operations/

http://cwiki.apache.org/confluence/display/TUSCANYWIKI/OSGi+RFC+119+Implementation

Thanks,
Raymond


From: Santiago Miguel Aranda Rojas
Sent: Wednesday, June 10, 2009 12:07 AM
To: user@tuscany.apache.org
Subject: Re: Problem with "implementation.osgi" reference


Yes, you are right. I was doing some different tests and I copied you a
wrong composite. I wanted to see if the change of @target made an error in
tuscany.  But Tuscany doesn4t recognize this error because I think it
supposes that will be a "remote Component". I can see this in the tuscany
trace


ADVERTENCIA: Component reference target not found, it might be a remote
service running elsewhere in the SCA Domain: Composite =
{http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement}SensorNetworkManagement
Service = PruebaComponent



But it is Ok, because the component I want if an Osgi Service registered in
the Osgi registry.
I have fixed the error in @target and it is not working yet.


Do you know any example when an <implementation.osgi> component is used?




I have tried to change  "xmlns" tag, but it doesn4t work.


<sca:component name="PruebaComponent">
   <sca:implementation.osgi
xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
        bundleSymbolicName="RegistroService"
        bundleVersion="1.0.0">
       <sca:properties service="prueba.PruebaImpl">
       </sca:properties>
   </sca:implementation.osgi>
 </sca:component>


Thank you very much.



2009/6/10 Raymond Feng <en...@gmail.com>

The @target is pointing to a wrong componentName/serviceName. It should be
"Prueba" instead of "PruebaComponent" as the component name is "Prueba".


From: Santiago Miguel Aranda Rojas
Sent: Tuesday, June 09, 2009 1:28 PM
To: user@tuscany.apache.org
Subject: Re: Problem with "implementation.osgi" reference


Tuscany 2.02M. The last version I think. April 2009
----- Original Message ----- From: Raymond Feng
To: user@tuscany.apache.org
Sent: Tuesday, June 09, 2009 7:12 PM
Subject: Re: Problem with "implementation.osgi" reference


Are you using Tuscany/SCA 2.x or 1.x?


From: santiago.aranda@telvent.com
Sent: Tuesday, June 09, 2009 9:15 AM
To: user@tuscany.apache.org
Subject: Problem with "implementation.osgi" reference



Hello

I want to use an osgi service as a SCA component. But I can not access to
their methods from other Component.  I mean I have created a wired instance
to the Osgi Service ($Proxy25). It is not "null" but I can not invoke to one
method because an error is happening

--->Unable to create SCA binding invoker for local target
SensorNetworkManagementComponent reference prueba (bindingURI=null
operation=sayHello)

This is my composite file. I want to have to two components. The first had a
reference to the second and it is normal "implementation.java". The second
is the SCA component that is representing to the Osgi Service that I want to
recover. This Osgi Service was registered in the Osgi registry by Activator
class in "RegistroService" bundle.

<sca:component name="SensorNetworkManagementComponent">
<sca:implementation.java
class="es.amivital.sensornetworkmanagement.sca.SensorNetworkManagementServiceImpl"/>
<sca:service name="SensorNetworkManagementService">
 <sca:binding.ws
uri="http://localhost:8085/SensorNetworkManagementComponent"/>
</sca:service>
<sca:reference name="prueba" target="PruebaComponent"/>
</sca:component>


<sca:component name="Prueba">
   <sca:implementation.osgi
xmlns="http://tuscany.apache.org/xmlns/sca/1.0"
        bundleSymbolicName="RegistroService"
        bundleVersion="1.0.0">
       <sca:properties service="prueba.PruebaImpl">
       </sca:properties>
   </sca:implementation.osgi>
</sca:component>

***The Java code--> The first component.

public class SensorNetworkManagementServiceImpl  implements
SensorNetworkManagementService {
private Prueba prueba;
public Prueba getPrueba() {
return prueba;
}
@Reference
public void setPrueba(Prueba prueba) {
this.prueba = prueba;
}
}

**Java code       --> The second component. It is another bundle that is
registering one simple Osgi Service. The interface was

public interface Prueba {
public abstract String sayHello();

}





This instance (prueba) is not null when an outside client invoke to the
first component. But if I invoke to one method of this interface, for
example "prueba.sayHello" I obtained the previous error.

I have read something about anottations like @AllowsPassByReference or
@Scope, but I don4t know if they are neccesary . 


Re: Fwd: Problem with "implementation.osgi" reference

Posted by Santiago Miguel Aranda Rojas <sa...@gmail.com>.
Hello.

I have downloaded M3RC1 but I have the same errors. I can not run this in
Eclipse but I think it is my problem. I run this distribution outside of
Eclipse and all modules are running. But when I try to run my TestService
bundle I have an error

GRAVE: org.oasisopen.sca.ServiceRuntimeException: Deployment composite
OSGI-INF/
sca/bundle.composite cannot be found within contribution bundleentry://181/
java.lang.IllegalStateException: org.oasisopen.sca.ServiceRuntimeException:
Depl
oyment composite OSGI-INF/sca/bundle.composite cannot be found within
contributi
on bundleentry://181/

I think composite.file is always compulsory. It is not enough with
bunde.componentType as you said. Well, I put one composite file in order to
test it

<sca:composite xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
name="SensorNetworkManagement" targetNamespace="
http://eclipse.org/TestService/src/main/resources/TestService">

  <sca:component name="TestServiceComponent">
   <sca:implementation.osgi bundleSymbolicName="TestService"
bundleVersion="1.0.0"/>
  </sca:component>
</sca:composite>

and I have a new error. I guess tuscany doesn´t like "implementation.osgi"
componenents. When I used 2.02M I had another different error.

ADVERTENCIA: Element {http://docs.oasis-open.org/ns/opencsa/sca/200903}*
implement*
*ation.osgi cannot be processed*. ([row,col {unknown-source}]: [4,5])
19-jun-2009 11:05:01
org.apache.tuscany.sca.contribution.processor.ExtensibleStA
XArtifactProcessor
ADVERTENCIA: Element {
http://docs.oasis-open.org/ns/opencsa/sca/200903}implement
ation.osgi cannot be processed. ([row,col {unknown-source}]: [4,5])
19-jun-2009 11:05:01
org.apache.tuscany.sca.assembly.builder.impl.ComponentConfi
gurationBuilderImpl
GRAVE: No implementation for component: Component = TestServiceComponent
19-jun-2009 11:05:01
org.apache.tuscany.sca.assembly.builder.impl.CompositeBindi
ngURIBuilderImpl
GRAVE: No implementation for component: Component = TestServiceComponent
19-jun-2009 11:05:01 org.apache.tuscany.sca.node.osgi.impl.NodeManager
bundleSta
rted
GRAVE: org.oasisopen.sca.ServiceRuntimeException: No implementation for
componen
t: Component = TestServiceComponent
java.lang.IllegalStateException: org.oasisopen.sca.ServiceRuntimeException:
No i
mplementation for component: Component = TestServiceComponent


Besides, I think I will not be able to wire one SCA component osgi with
other SCA component java so I want to try other thing. I know tuscany is
using its own ClassLoader in order to load classes it needs. But my original
problem was I can not share a instance of a Singleton Class between one
object loaded by default osgi ClassLoader and other object loaded tuscany
ClassLoader.

1) I create an instance of one Class that is not modeled with Tuscany
2) I have other Class that will be a Singleton. Only there will be one
instance of this class
3) I recover the instance of Singleton class from the instance of step 1
4) A CalculatorImpl instance is created when someone invoke a method from WS
(this is a class modeled with Tuscany)
5) CalculatorImpl should recover the same instance of Singleton class

But CalculatorImpl and class of step 1 were loaded by different classLoaders
so they will load the Singleton Class twice. So They will have different
instances of Singleton class although it was a singleton.






2009/6/18 Santiago Miguel Aranda Rojas <sa...@gmail.com>

>  Well I will try M3RC1 tomorrow. I hope fix some errors with that
>
> Thank you
>
>
>
>
>
> ----- Original Message -----
> *From:* Raymond Feng <en...@gmail.com>
> *To:* user@tuscany.apache.org ; santiago.aranda@telvent.com
> *Sent:* Thursday, June 18, 2009 5:47 PM
> *Subject:* Re: Fwd: Problem with "implementation.osgi" reference
>
> Which level of the Tuscany 2.x code are you using? The various issues you
> ran into seem to have been fixed before. Can you try our M3 RC1?
>
> http://people.apache.org/~antelder/tuscany/2.0-M3-RC1/
>
>  Thanks,
> Raymond
>
>
>  *From:* Santiago Miguel Aranda Rojas <sa...@gmail.com>
> *Sent:* Thursday, June 18, 2009 3:05 AM
> *To:* user@tuscany.apache.org
> *Subject:* Re: Fwd: Problem with "implementation.osgi" reference
>
> I am checking your comments. I can not remove bundle.composite file from
> TestService bundle because tuscany is not working without this file.
>
> I have this
>
>  Caused by: java.lang.NullPointerException
> *at
> org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl.configureNode(NodeFactoryImpl.java:440)
> *
> at
> org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl.access$2(NodeFactoryImpl.java:351)
> at
> org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl$NodeImpl.<init>(NodeFactoryImpl.java:574)
>
> and the source code about this line is
>
>   if (composite == null) {
>             composite = getDefaultComposite(configuration, workspace);
>         }
>
>         // Find the composite in the given contributions
>         boolean found = false;
>         Artifact compositeFile = contributionFactory.createArtifact();
>         compositeFile.setUnresolved(true);
>         compositeFile.setURI(composite.getURI());
>         for (Contribution contribution : workspace.getContributions()) {
>             ModelResolver resolver = contribution.getModelResolver();
>             //            for (Artifact artifact :
> contribution.getArtifacts()){
>             //                logger.log(Level.INFO,"artifact - " +
> artifact.getURI());
>             //            }
>             Artifact resolvedArtifact =
> resolver.resolveModel(Artifact.class, compositeFile);
>             //            if (!resolvedArtifact.isUnresolved() &&
> resolvedArtifact.getModel() instanceof Composite) {
>
> *            if (!composite.isUnresolved()) {  ---> This is line 440*
>
>                 // The composite content was passed into the node and read
> into a composite model,
>                 // don't use the composite found in the contribution, use
> that composite, but just resolve
>                 // it within the context of the contribution
>                 compositeProcessor.resolve(composite, resolver);
>
>             } else {
>
>                 // Use the resolved composite we've found in the
> contribution
>                 composite = (Composite)resolvedArtifact.getModel();
>             }
>             found = true;
>             //            break;
>             //          }
>         }
>
>
> I guess composite variable is not null in the first iteration. But it is
> null when* composite = (Composite)resolvedArtifact.getModel();* is
> executed. So I guess is another problem related with "contribution" because
> there is a comment about that *"// Use the resolved composite we've found
> in the contribution"*
> *
> *
> Besides, while I fix these things I am going to use java code in order to
> register the SCA node. I have checked all your comments about
> bundle.composite and bundle.componentType at TestService and Calculator
> bundle. When I invoke to a method of CalculatorService with a WS client I
> have another problem.
>
> This code of CalculatorServiceImpl
>
>  public class CalculatorServiceImpl implements CalculatorService {
>  private AddService addService;
>  private TestService testService;
>
>         public int add(int param1, int param2) {
> *System.out.println (testService.sayHello());  --> I have an error when
> this line is executed*
> return addService.add(param1, param2);
> }
>
>
> public AddService getAddService() {
> return addService;
> }
>
> @Reference
> public void setAddService(AddService addService) {
> this.addService = addService;
> }
>
> public TestService getTestService() {
> return testService;
> }
>
> @Reference
> public void setTestService(TestService testService) {
> this.testService = testService;
> }
> }
>
>
> This is the error . The testService instance is not null but it is not
> wired to TestService.  I have registered the Osgi Service registry using
> this code in the Activator of TestService bundle. I think this is neccesary.
>
> ***arg0.registerService(TestService.class.getName(), new
> TestServiceImpl(), null);  *
>
>
>
> Caused by: org.oasisopen.sca.ServiceUnavailableException: Unable to create
> SCA binding invoker for local target CalculatorComponent reference
> testService (bindingURI=null operation=sayHello)
> at
> org.apache.tuscany.sca.binding.sca.provider.RuntimeSCAReferenceBindingProvider.createInvoker(RuntimeSCAReferenceBindingProvider.java:200)
>
>
>
> ---------------------------------------------
>
>
>
> 2009/6/17 Raymond Feng <en...@gmail.com>
>
>> Hi,
>>
>> Please see my comments inline.
>>
>> Thanks,
>> Raymond
>>
>> ------------------------------------
>> BUNDLE CALCULATOR
>> ------------------------------------
>> *****OSGI-INF/sca/bundle.composite. Two java components (Calculator and
>> AddService) and one OSGi component (TestService)
>>
>> <rfeng>This is good.</rfeng>
>>
>>
>> <sca:composite xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
>> xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
>> name="SensorNetworkManagement" targetNamespace="
>> http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement
>> ">
>>
>>  <sca:component name="CalculatorComponent">
>>   <sca:implementation.java
>> class="es.amivital.calculatorservice2.CalculatorServiceImpl"/>
>>    <sca:service name="CalculatorService">
>>  <sca:binding.ws uri="http://localhost:8085/CalculatorComponent"/>
>>    </sca:service>
>>
>>    <sca:reference name="addService" target="AddServiceComponent"/>
>>    <sca:reference name="testService"
>> target="TestServiceComponent/TestService"/>
>>  </sca:component>
>>
>>
>>  <sca:component name="AddServiceComponent">
>>   <sca:implementation.java
>> class="es.amivital.calculatorservice2.AddServiceImpl"/>
>>  </sca:component>
>>
>>  <sca:component name="TestServiceComponent">
>>  <sca:implementation.osgi bundleSymbolicName="TestService"
>> bundleVersion="1.0.0"/>
>>  </sca:component>
>> </sca:composite>
>>
>>
>>
>>
>> *******OSGI-INF/sca/bundle.componentType
>> <rfeng>You don't need to provide this file. The componentType is only
>> needed for the OSGi component.</rfeng>
>>
>>
>> <componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
>>              xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>>              xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1">
>>   <!-- The service elment defines an SCA view of the OSGi service -->
>>   <service name="CalculatorService">
>>       <!-- The interface will be mapped into the OSGi service class -->
>>       <interface.java
>> interface="es.amivital.calculatorservice2.CalculatorService"/>
>>       <!-- The list of OSGi properties -->
>>
>>   </service>
>> </componentType>
>>
>> -----------------------------------
>> BUNDLE TESTSERVICE
>> -------------------------------------
>>
>>
>> *******OSGI-INF/sca/bundle.componentType
>> <rfeng>This is good.</rfeng>
>>
>>
>> <componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
>>              xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>>              xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1">
>>   <!-- The service elment defines an SCA view of the OSGi service -->
>>   <service name="TestService">
>>       <!-- The interface will be mapped into the OSGi service class -->
>>       <interface.java interface="es.amivital.testservice.Test"/>
>>       <!-- The list of OSGi properties -->
>>
>>   </service>
>> </componentType>
>>
>>
>> *****OSGI-INF/sca/bundle.composite
>> <rfeng>This should be removed as the TestServiceComponent has been
>> declared in the calculator bundle composite.</rfeng>
>>
>> <sca:composite xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
>> xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
>> name="SensorNetworkManagement" targetNamespace="
>> http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement
>> ">
>>
>>  <sca:component name="TestServiceComponent">
>>  <sca:implementation.java class="es.amivital.testservice.TestImpl"/>
>>  </sca:component>
>> </sca:composite>
>>
>>
>> It is necessary to have a bundle.composite file in TestService?? and
>> bundle.componentType?? Can I remove these files from TestService bundle and
>> put the TestService4s bundle.componentType in the Calculator bundle. You
>> said "Alternatively, you have place the file as
>> OSGI-INF/sca/<bundleSymbolicName>/bundle.componentType in the calculator
>> bundle." Do you mean I can copy TestService4s bundle.componentType into a
>> CalculatorService bundle?
>>
>> <rfeng>Yes</rfeng>
>>
>>
>>
>> Thank you very much
>> -------------------------------------------------------------------
>>
>>
>>
>>
>>
>> Tuscany checks the OSGi bundle based on one of the following patterns:
>> * An "SCA-Composite" header in the MANIFEST.MF. It points to an SCA
>> composite file within the bundle.
>> * Any files under OSGI-INF/sca.
>>
>> In your case, the first bundle contains three java components. The second
>> bundle contains one OSGi component.  There are a few options to get them
>> work together (CalculatorService with a reference to TestService).
>>
>> Option 1:
>> 1) Place bundle.composite under OSGI-INF/sca in the calculator bundle. The
>> composite contains 4 components: 3 java components and 1 OSGi component.
>> The @target for CalculatorService component's testService reference will
>> be TestService/<serviceName>.
>>
>> 2) Place bundle.componentType under OSGI-INF/sca in the test service
>> bundle.
>> Alternatively, you have place the file as
>> OSGI-INF/sca/<bundleSymbolicName>/bundle.componentType in the calculator
>> bundle.
>>
>> In this case, we are going to start one Node.
>>
>> Option 2:
>> 1) Place bundle.composite under OSGI-INF/sca in the calculator bundle. The
>> composite contains 3 java components
>> 2) Place bundle.composite under OSGI-INF/sca in the test service bundle.
>> The composite contains 1 OSGi component.
>> 3) Place bundle.componentType under OSGI-INF/sca in the test service
>> bundle.
>>
>> In this case, we are going to start two nodes. You can configure the
>> CalculatorService.testService reference and the OSGi service to use the same
>> binding (such as RMI, or WS) to communicate. Make sure the interface is
>> remotable. binding.sca is not working yet.
>>
>> Thanks,
>> Raymond
>>
>>
>> From: santiago.aranda@telvent.com
>>
>> Sent: Tuesday, June 16, 2009 1:33 AM
>>
>> To: user@tuscany.apache.org
>>
>> Subject: Re: Fwd: Problem with "implementation.osgi" reference
>>
>>
>>
>>
>> So, I have to attach two files (componentType and composite) to my two
>> different bundles (TestService and Calculator) and model it as
>> "implementation.osgi".   I have TestService in a bundle I will add these two
>> file and I will design as "implementation.osgi" .
>>
>> But Calculator Service (this is in other bundle) has three components and
>> they are all "implementation.java" and it is working OK. How can I put a
>> reference to TestService?? Do I need change "implementation.osgi" in
>> CalculatorComponent instead "implementation.java"? and is it neccesary for
>> AddServiceComponent and SubstractService??
>>
>> I will try a example I will copy my files in the email.
>>
>> Thank you very much
>>
>> Un saludo.
>> Santiago Miguel Aranda Rojas
>> Telvent Interactiva
>> Extension: 35999
>> Telefono: 955637418
>>
>>
>> "Raymond Feng" <en...@gmail.com>
>> "Raymond Feng"
>> 15/06/2009 18:36
>> Para: <us...@tuscany.apache.org>, <sa...@telvent.com>
>> cc:
>> Asunto: Re: Fwd: Problem with "implementation.osgi" reference
>>
>>
>>
>>
>> To access an OSGi service from the SCA component, you will have to provide
>> SCA configurations for the OSGi bundle so that it becomes an SCA component
>> using implementation.osgi and the OSGi service becomes an SCA service so
>> that the Calculator component can wire to that TestService.
>>
>> There are two SCA files you to provide to model the OSGi bundle as an SCA
>> component.
>> * bundle.componentType to describe what OSGi services or references are
>> used
>> in the bundle (We potentially have better approach to introspect the OSGi
>> bundle to build this up)
>> * bundle.composite to configure the component, for example, setting the
>> bindings.
>>
>> These files can be in a separate OSGi bundle than the one that owns the
>> services/references.
>>
>> Thanks,
>> Raymond
>>
>> From: Santiago Miguel Aranda Rojas
>> Sent: Monday, June 15, 2009 4:01 AM
>> To: user@tuscany.apache.org
>> Subject: Fwd: Problem with "implementation.osgi" reference
>>
>>
>>
>>
>>
>>
>> Hi
>>
>>
>> I can not understand this sample because there are many new concepts for
>> me.
>> For example "bundle.componentType". There is not too much information
>> about
>> that . I think I need something more simple. I have attached a picture
>> with
>> my idea.
>>
>>
>> ** When my SCA service was working I had a main component
>> "implementacion.java" with two references to another two components
>> (implementation.java). The main component could be invoked as Web Service.
>>
>>
>> ** Now, I want another reference to a Service (TestService in the picture)
>> that was registered by another different bundle. But this is a OSGi
>> bundle,
>> without SCA information, Composite file nor ComponentType file. I mean it
>> is
>> a bundle that is registering a service in the OSGi registry. I need have a
>> instance wired to this OSGi service in the class of the main Component in
>> order to invoke their methods.
>>
>>
>> TestService testService;
>>
>>
>> //I need testService is not null in order to invoke their methods.
>> testService.sayHello();
>>
>>
>>
>>
>> I hope you can understand my problem. You can ask me if you want.
>>
>>
>> Thank you very mucha
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> 2009/6/10 Raymond Feng <en...@gmail.com>
>>
>> Please see:
>>
>>
>> https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator/
>>
>> https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator-operations/
>>
>>
>> http://cwiki.apache.org/confluence/display/TUSCANYWIKI/OSGi+RFC+119+Implementation
>>
>> Thanks,
>> Raymond
>>
>>
>> From: Santiago Miguel Aranda Rojas
>> Sent: Wednesday, June 10, 2009 12:07 AM
>> To: user@tuscany.apache.org
>> Subject: Re: Problem with "implementation.osgi" reference
>>
>>
>> Yes, you are right. I was doing some different tests and I copied you a
>> wrong composite. I wanted to see if the change of @target made an error in
>> tuscany.  But Tuscany doesn4t recognize this error because I think it
>> supposes that will be a "remote Component". I can see this in the tuscany
>> trace
>>
>>
>> ADVERTENCIA: Component reference target not found, it might be a remote
>> service running elsewhere in the SCA Domain: Composite =
>> {
>> http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement}SensorNetworkManagement<http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement%7DSensorNetworkManagement>
>> Service = PruebaComponent
>>
>>
>>
>> But it is Ok, because the component I want if an Osgi Service registered
>> in
>> the Osgi registry.
>> I have fixed the error in @target and it is not working yet.
>>
>>
>> Do you know any example when an <implementation.osgi> component is used?
>>
>>
>>
>>
>> I have tried to change  "xmlns" tag, but it doesn4t work.
>>
>>
>> <sca:component name="PruebaComponent">
>>    <sca:implementation.osgi
>> xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
>>         bundleSymbolicName="RegistroService"
>>         bundleVersion="1.0.0">
>>        <sca:properties service="prueba.PruebaImpl">
>>        </sca:properties>
>>    </sca:implementation.osgi>
>>  </sca:component>
>>
>>
>> Thank you very much.
>>
>>
>>
>> 2009/6/10 Raymond Feng <en...@gmail.com>
>>
>> The @target is pointing to a wrong componentName/serviceName. It should be
>> "Prueba" instead of "PruebaComponent" as the component name is "Prueba".
>>
>>
>> From: Santiago Miguel Aranda Rojas
>> Sent: Tuesday, June 09, 2009 1:28 PM
>> To: user@tuscany.apache.org
>> Subject: Re: Problem with "implementation.osgi" reference
>>
>>
>> Tuscany 2.02M. The last version I think. April 2009
>> ----- Original Message ----- From: Raymond Feng
>> To: user@tuscany.apache.org
>> Sent: Tuesday, June 09, 2009 7:12 PM
>> Subject: Re: Problem with "implementation.osgi" reference
>>
>>
>> Are you using Tuscany/SCA 2.x or 1.x?
>>
>>
>> From: santiago.aranda@telvent.com
>> Sent: Tuesday, June 09, 2009 9:15 AM
>> To: user@tuscany.apache.org
>> Subject: Problem with "implementation.osgi" reference
>>
>>
>>
>> Hello
>>
>> I want to use an osgi service as a SCA component. But I can not access to
>> their methods from other Component.  I mean I have created a wired
>> instance
>> to the Osgi Service ($Proxy25). It is not "null" but I can not invoke to
>> one
>> method because an error is happening
>>
>> --->Unable to create SCA binding invoker for local target
>> SensorNetworkManagementComponent reference prueba (bindingURI=null
>> operation=sayHello)
>>
>> This is my composite file. I want to have to two components. The first had
>> a
>> reference to the second and it is normal "implementation.java". The second
>> is the SCA component that is representing to the Osgi Service that I want
>> to
>> recover. This Osgi Service was registered in the Osgi registry by
>> Activator
>> class in "RegistroService" bundle.
>>
>> <sca:component name="SensorNetworkManagementComponent">
>> <sca:implementation.java
>>
>> class="es.amivital.sensornetworkmanagement.sca.SensorNetworkManagementServiceImpl"/>
>> <sca:service name="SensorNetworkManagementService">
>>  <sca:binding.ws
>> uri="http://localhost:8085/SensorNetworkManagementComponent"/>
>> </sca:service>
>> <sca:reference name="prueba" target="PruebaComponent"/>
>> </sca:component>
>>
>>
>> <sca:component name="Prueba">
>>    <sca:implementation.osgi
>> xmlns="http://tuscany.apache.org/xmlns/sca/1.0"
>>         bundleSymbolicName="RegistroService"
>>         bundleVersion="1.0.0">
>>        <sca:properties service="prueba.PruebaImpl">
>>        </sca:properties>
>>    </sca:implementation.osgi>
>> </sca:component>
>>
>> ***The Java code--> The first component.
>>
>> public class SensorNetworkManagementServiceImpl  implements
>> SensorNetworkManagementService {
>> private Prueba prueba;
>> public Prueba getPrueba() {
>> return prueba;
>> }
>> @Reference
>> public void setPrueba(Prueba prueba) {
>> this.prueba = prueba;
>> }
>> }
>>
>> **Java code       --> The second component. It is another bundle that is
>> registering one simple Osgi Service. The interface was
>>
>> public interface Prueba {
>> public abstract String sayHello();
>>
>> }
>>
>>
>>
>>
>>
>> This instance (prueba) is not null when an outside client invoke to the
>> first component. But if I invoke to one method of this interface, for
>> example "prueba.sayHello" I obtained the previous error.
>>
>> I have read something about anottations like @AllowsPassByReference or
>> @Scope, but I don4t know if they are neccesary .
>>
>
>

Re: Fwd: Problem with "implementation.osgi" reference

Posted by Raymond Feng <en...@gmail.com>.
Which level of the Tuscany 2.x code are you using? The various issues you ran into seem to have been fixed before. Can you try our M3 RC1?

http://people.apache.org/~antelder/tuscany/2.0-M3-RC1/

Thanks,
Raymond

 
From: Santiago Miguel Aranda Rojas 
Sent: Thursday, June 18, 2009 3:05 AM
To: user@tuscany.apache.org 
Subject: Re: Fwd: Problem with "implementation.osgi" reference


I am checking your comments. I can not remove bundle.composite file from TestService bundle because tuscany is not working without this file.


I have this


Caused by: java.lang.NullPointerException
at org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl.configureNode(NodeFactoryImpl.java:440)
at org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl.access$2(NodeFactoryImpl.java:351)
at org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl$NodeImpl.<init>(NodeFactoryImpl.java:574)


and the source code about this line is


 if (composite == null) {
            composite = getDefaultComposite(configuration, workspace);
        }


        // Find the composite in the given contributions
        boolean found = false;
        Artifact compositeFile = contributionFactory.createArtifact();
        compositeFile.setUnresolved(true);
        compositeFile.setURI(composite.getURI());
        for (Contribution contribution : workspace.getContributions()) {
            ModelResolver resolver = contribution.getModelResolver();
            //            for (Artifact artifact : contribution.getArtifacts()){
            //                logger.log(Level.INFO,"artifact - " + artifact.getURI());
            //            }
            Artifact resolvedArtifact = resolver.resolveModel(Artifact.class, compositeFile);
            //            if (!resolvedArtifact.isUnresolved() && resolvedArtifact.getModel() instanceof Composite) {


            if (!composite.isUnresolved()) {  ---> This is line 440


                // The composite content was passed into the node and read into a composite model,
                // don't use the composite found in the contribution, use that composite, but just resolve
                // it within the context of the contribution
                compositeProcessor.resolve(composite, resolver);


            } else {


                // Use the resolved composite we've found in the contribution
                composite = (Composite)resolvedArtifact.getModel();
            }
            found = true;
            //            break;
            //          }
        }




I guess composite variable is not null in the first iteration. But it is null when composite = (Composite)resolvedArtifact.getModel(); is executed. So I guess is another problem related with "contribution" because there is a comment about that "// Use the resolved composite we've found in the contribution"


Besides, while I fix these things I am going to use java code in order to register the SCA node. I have checked all your comments about bundle.composite and bundle.componentType at TestService and Calculator bundle. When I invoke to a method of CalculatorService with a WS client I have another problem. 


This code of CalculatorServiceImpl


public class CalculatorServiceImpl implements CalculatorService {
private AddService addService;
private TestService testService;


       public int add(int param1, int param2) {
System.out.println (testService.sayHello());  --> I have an error when this line is executed
return addService.add(param1, param2);
}




public AddService getAddService() {
return addService;
}


@Reference
public void setAddService(AddService addService) {
this.addService = addService;
}


public TestService getTestService() {
return testService;
}


@Reference
public void setTestService(TestService testService) {
this.testService = testService;
}
}




This is the error . The testService instance is not null but it is not wired to TestService.  I have registered the Osgi Service registry using this code in the Activator of TestService bundle. I think this is neccesary.


arg0.registerService(TestService.class.getName(), new TestServiceImpl(), null);  






Caused by: org.oasisopen.sca.ServiceUnavailableException: Unable to create SCA binding invoker for local target CalculatorComponent reference testService (bindingURI=null operation=sayHello)
at org.apache.tuscany.sca.binding.sca.provider.RuntimeSCAReferenceBindingProvider.createInvoker(RuntimeSCAReferenceBindingProvider.java:200)






---------------------------------------------





2009/6/17 Raymond Feng <en...@gmail.com>

  Hi,

  Please see my comments inline.

  Thanks,
  Raymond 


  ------------------------------------
  BUNDLE CALCULATOR
  ------------------------------------
  *****OSGI-INF/sca/bundle.composite. Two java components (Calculator and AddService) and one OSGi component (TestService)


  <rfeng>This is good.</rfeng> 



  <sca:composite xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903" name="SensorNetworkManagement" targetNamespace="http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement">

   <sca:component name="CalculatorComponent">
    <sca:implementation.java class="es.amivital.calculatorservice2.CalculatorServiceImpl"/>
     <sca:service name="CalculatorService">
   <sca:binding.ws uri="http://localhost:8085/CalculatorComponent"/>
     </sca:service>

     <sca:reference name="addService" target="AddServiceComponent"/>
     <sca:reference name="testService" target="TestServiceComponent/TestService"/>
   </sca:component>


   <sca:component name="AddServiceComponent">
    <sca:implementation.java class="es.amivital.calculatorservice2.AddServiceImpl"/>
   </sca:component>

   <sca:component name="TestServiceComponent">
   <sca:implementation.osgi bundleSymbolicName="TestService" bundleVersion="1.0.0"/>
   </sca:component>
  </sca:composite>




  *******OSGI-INF/sca/bundle.componentType

  <rfeng>You don't need to provide this file. The componentType is only needed for the OSGi component.</rfeng> 



  <componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1">
    <!-- The service elment defines an SCA view of the OSGi service -->
    <service name="CalculatorService">
        <!-- The interface will be mapped into the OSGi service class -->
        <interface.java interface="es.amivital.calculatorservice2.CalculatorService"/>
        <!-- The list of OSGi properties -->

    </service>
  </componentType>

  -----------------------------------
  BUNDLE TESTSERVICE
  -------------------------------------


  *******OSGI-INF/sca/bundle.componentType

  <rfeng>This is good.</rfeng> 



  <componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1">
    <!-- The service elment defines an SCA view of the OSGi service -->
    <service name="TestService">
        <!-- The interface will be mapped into the OSGi service class -->
        <interface.java interface="es.amivital.testservice.Test"/>
        <!-- The list of OSGi properties -->

    </service>
  </componentType>


  *****OSGI-INF/sca/bundle.composite

  <rfeng>This should be removed as the TestServiceComponent has been declared in the calculator bundle composite.</rfeng> 


  <sca:composite xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903" name="SensorNetworkManagement" targetNamespace="http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement">

   <sca:component name="TestServiceComponent">
   <sca:implementation.java class="es.amivital.testservice.TestImpl"/>
   </sca:component>
  </sca:composite>



  It is necessary to have a bundle.composite file in TestService?? and bundle.componentType?? Can I remove these files from TestService bundle and put the TestService4s bundle.componentType in the Calculator bundle. You said "Alternatively, you have place the file as OSGI-INF/sca/<bundleSymbolicName>/bundle.componentType in the calculator bundle." Do you mean I can copy TestService4s bundle.componentType into a CalculatorService bundle?

  <rfeng>Yes</rfeng> 



  Thank you very much
  -------------------------------------------------------------------





  Tuscany checks the OSGi bundle based on one of the following patterns:
  * An "SCA-Composite" header in the MANIFEST.MF. It points to an SCA composite file within the bundle.
  * Any files under OSGI-INF/sca.

  In your case, the first bundle contains three java components. The second bundle contains one OSGi component.  There are a few options to get them work together (CalculatorService with a reference to TestService).

  Option 1:
  1) Place bundle.composite under OSGI-INF/sca in the calculator bundle. The composite contains 4 components: 3 java components and 1 OSGi component.
  The @target for CalculatorService component's testService reference will be TestService/<serviceName>.

  2) Place bundle.componentType under OSGI-INF/sca in the test service bundle.
  Alternatively, you have place the file as OSGI-INF/sca/<bundleSymbolicName>/bundle.componentType in the calculator bundle.

  In this case, we are going to start one Node.

  Option 2:
  1) Place bundle.composite under OSGI-INF/sca in the calculator bundle. The composite contains 3 java components
  2) Place bundle.composite under OSGI-INF/sca in the test service bundle. The composite contains 1 OSGi component.
  3) Place bundle.componentType under OSGI-INF/sca in the test service bundle.

  In this case, we are going to start two nodes. You can configure the CalculatorService.testService reference and the OSGi service to use the same binding (such as RMI, or WS) to communicate. Make sure the interface is remotable. binding.sca is not working yet.

  Thanks,
  Raymond


  From: santiago.aranda@telvent.com

  Sent: Tuesday, June 16, 2009 1:33 AM

  To: user@tuscany.apache.org

  Subject: Re: Fwd: Problem with "implementation.osgi" reference




  So, I have to attach two files (componentType and composite) to my two different bundles (TestService and Calculator) and model it as "implementation.osgi".   I have TestService in a bundle I will add these two file and I will design as "implementation.osgi" .

  But Calculator Service (this is in other bundle) has three components and they are all "implementation.java" and it is working OK. How can I put a reference to TestService?? Do I need change "implementation.osgi" in CalculatorComponent instead "implementation.java"? and is it neccesary for AddServiceComponent and SubstractService??

  I will try a example I will copy my files in the email.

  Thank you very much

  Un saludo.
  Santiago Miguel Aranda Rojas
  Telvent Interactiva
  Extension: 35999
  Telefono: 955637418


  "Raymond Feng" <en...@gmail.com>
  "Raymond Feng"
  15/06/2009 18:36
  Para: <us...@tuscany.apache.org>, <sa...@telvent.com>
  cc:
  Asunto: Re: Fwd: Problem with "implementation.osgi" reference




  To access an OSGi service from the SCA component, you will have to provide
  SCA configurations for the OSGi bundle so that it becomes an SCA component
  using implementation.osgi and the OSGi service becomes an SCA service so
  that the Calculator component can wire to that TestService.

  There are two SCA files you to provide to model the OSGi bundle as an SCA
  component.
  * bundle.componentType to describe what OSGi services or references are used
  in the bundle (We potentially have better approach to introspect the OSGi
  bundle to build this up)
  * bundle.composite to configure the component, for example, setting the
  bindings.

  These files can be in a separate OSGi bundle than the one that owns the
  services/references.

  Thanks,
  Raymond

  From: Santiago Miguel Aranda Rojas
  Sent: Monday, June 15, 2009 4:01 AM
  To: user@tuscany.apache.org
  Subject: Fwd: Problem with "implementation.osgi" reference






  Hi


  I can not understand this sample because there are many new concepts for me.
  For example "bundle.componentType". There is not too much information about
  that . I think I need something more simple. I have attached a picture with
  my idea.


  ** When my SCA service was working I had a main component
  "implementacion.java" with two references to another two components
  (implementation.java). The main component could be invoked as Web Service.


  ** Now, I want another reference to a Service (TestService in the picture)
  that was registered by another different bundle. But this is a OSGi bundle,
  without SCA information, Composite file nor ComponentType file. I mean it is
  a bundle that is registering a service in the OSGi registry. I need have a
  instance wired to this OSGi service in the class of the main Component in
  order to invoke their methods.


  TestService testService;


  //I need testService is not null in order to invoke their methods.
  testService.sayHello();




  I hope you can understand my problem. You can ask me if you want.


  Thank you very mucha

















  2009/6/10 Raymond Feng <en...@gmail.com>

  Please see:

  https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator/
  https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator-operations/

  http://cwiki.apache.org/confluence/display/TUSCANYWIKI/OSGi+RFC+119+Implementation

  Thanks,
  Raymond


  From: Santiago Miguel Aranda Rojas
  Sent: Wednesday, June 10, 2009 12:07 AM
  To: user@tuscany.apache.org
  Subject: Re: Problem with "implementation.osgi" reference


  Yes, you are right. I was doing some different tests and I copied you a
  wrong composite. I wanted to see if the change of @target made an error in
  tuscany.  But Tuscany doesn4t recognize this error because I think it
  supposes that will be a "remote Component". I can see this in the tuscany
  trace


  ADVERTENCIA: Component reference target not found, it might be a remote
  service running elsewhere in the SCA Domain: Composite =
  {http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement}SensorNetworkManagement
  Service = PruebaComponent



  But it is Ok, because the component I want if an Osgi Service registered in
  the Osgi registry.
  I have fixed the error in @target and it is not working yet.


  Do you know any example when an <implementation.osgi> component is used?




  I have tried to change  "xmlns" tag, but it doesn4t work.


  <sca:component name="PruebaComponent">
     <sca:implementation.osgi
  xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
          bundleSymbolicName="RegistroService"
          bundleVersion="1.0.0">
         <sca:properties service="prueba.PruebaImpl">
         </sca:properties>
     </sca:implementation.osgi>
   </sca:component>


  Thank you very much.



  2009/6/10 Raymond Feng <en...@gmail.com>

  The @target is pointing to a wrong componentName/serviceName. It should be
  "Prueba" instead of "PruebaComponent" as the component name is "Prueba".


  From: Santiago Miguel Aranda Rojas
  Sent: Tuesday, June 09, 2009 1:28 PM
  To: user@tuscany.apache.org
  Subject: Re: Problem with "implementation.osgi" reference


  Tuscany 2.02M. The last version I think. April 2009
  ----- Original Message ----- From: Raymond Feng
  To: user@tuscany.apache.org
  Sent: Tuesday, June 09, 2009 7:12 PM
  Subject: Re: Problem with "implementation.osgi" reference


  Are you using Tuscany/SCA 2.x or 1.x?


  From: santiago.aranda@telvent.com
  Sent: Tuesday, June 09, 2009 9:15 AM
  To: user@tuscany.apache.org
  Subject: Problem with "implementation.osgi" reference



  Hello

  I want to use an osgi service as a SCA component. But I can not access to
  their methods from other Component.  I mean I have created a wired instance
  to the Osgi Service ($Proxy25). It is not "null" but I can not invoke to one
  method because an error is happening

  --->Unable to create SCA binding invoker for local target
  SensorNetworkManagementComponent reference prueba (bindingURI=null
  operation=sayHello)

  This is my composite file. I want to have to two components. The first had a
  reference to the second and it is normal "implementation.java". The second
  is the SCA component that is representing to the Osgi Service that I want to
  recover. This Osgi Service was registered in the Osgi registry by Activator
  class in "RegistroService" bundle.

  <sca:component name="SensorNetworkManagementComponent">
  <sca:implementation.java
  class="es.amivital.sensornetworkmanagement.sca.SensorNetworkManagementServiceImpl"/>
  <sca:service name="SensorNetworkManagementService">
   <sca:binding.ws
  uri="http://localhost:8085/SensorNetworkManagementComponent"/>
  </sca:service>
  <sca:reference name="prueba" target="PruebaComponent"/>
  </sca:component>


  <sca:component name="Prueba">
     <sca:implementation.osgi
  xmlns="http://tuscany.apache.org/xmlns/sca/1.0"
          bundleSymbolicName="RegistroService"
          bundleVersion="1.0.0">
         <sca:properties service="prueba.PruebaImpl">
         </sca:properties>
     </sca:implementation.osgi>
  </sca:component>

  ***The Java code--> The first component.

  public class SensorNetworkManagementServiceImpl  implements
  SensorNetworkManagementService {
  private Prueba prueba;
  public Prueba getPrueba() {
  return prueba;
  }
  @Reference
  public void setPrueba(Prueba prueba) {
  this.prueba = prueba;
  }
  }

  **Java code       --> The second component. It is another bundle that is
  registering one simple Osgi Service. The interface was

  public interface Prueba {
  public abstract String sayHello();

  }





  This instance (prueba) is not null when an outside client invoke to the
  first component. But if I invoke to one method of this interface, for
  example "prueba.sayHello" I obtained the previous error.

  I have read something about anottations like @AllowsPassByReference or
  @Scope, but I don4t know if they are neccesary . 


Re: Fwd: Problem with "implementation.osgi" reference

Posted by Santiago Miguel Aranda Rojas <sa...@gmail.com>.
I am checking your comments. I can not remove bundle.composite file from
TestService bundle because tuscany is not working without this file.

I have this

Caused by: java.lang.NullPointerException
*at
org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl.configureNode(NodeFactoryImpl.java:440)
*
at
org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl.access$2(NodeFactoryImpl.java:351)
at
org.apache.tuscany.sca.node.osgi.impl.NodeFactoryImpl$NodeImpl.<init>(NodeFactoryImpl.java:574)

and the source code about this line is

 if (composite == null) {
            composite = getDefaultComposite(configuration, workspace);
        }

        // Find the composite in the given contributions
        boolean found = false;
        Artifact compositeFile = contributionFactory.createArtifact();
        compositeFile.setUnresolved(true);
        compositeFile.setURI(composite.getURI());
        for (Contribution contribution : workspace.getContributions()) {
            ModelResolver resolver = contribution.getModelResolver();
            //            for (Artifact artifact :
contribution.getArtifacts()){
            //                logger.log(Level.INFO,"artifact - " +
artifact.getURI());
            //            }
            Artifact resolvedArtifact =
resolver.resolveModel(Artifact.class, compositeFile);
            //            if (!resolvedArtifact.isUnresolved() &&
resolvedArtifact.getModel() instanceof Composite) {

*            if (!composite.isUnresolved()) {  ---> This is line 440*

                // The composite content was passed into the node and read
into a composite model,
                // don't use the composite found in the contribution, use
that composite, but just resolve
                // it within the context of the contribution
                compositeProcessor.resolve(composite, resolver);

            } else {

                // Use the resolved composite we've found in the
contribution
                composite = (Composite)resolvedArtifact.getModel();
            }
            found = true;
            //            break;
            //          }
        }


I guess composite variable is not null in the first iteration. But it is
null when* composite = (Composite)resolvedArtifact.getModel();* is executed.
So I guess is another problem related with "contribution" because there is a
comment about that *"// Use the resolved composite we've found in the
contribution"*
*
*
Besides, while I fix these things I am going to use java code in order to
register the SCA node. I have checked all your comments about
bundle.composite and bundle.componentType at TestService and Calculator
bundle. When I invoke to a method of CalculatorService with a WS client I
have another problem.

This code of CalculatorServiceImpl

public class CalculatorServiceImpl implements CalculatorService {
 private AddService addService;
 private TestService testService;

       public int add(int param1, int param2) {
*System.out.println (testService.sayHello());  --> I have an error when this
line is executed*
return addService.add(param1, param2);
}


public AddService getAddService() {
return addService;
}

@Reference
public void setAddService(AddService addService) {
this.addService = addService;
}

public TestService getTestService() {
return testService;
}

@Reference
public void setTestService(TestService testService) {
this.testService = testService;
}
}


This is the error . The testService instance is not null but it is not wired
to TestService.  I have registered the Osgi Service registry using this code
in the Activator of TestService bundle. I think this is neccesary.

* **arg0.registerService(TestService.class.getName(), new TestServiceImpl(),
null);  *



Caused by: org.oasisopen.sca.ServiceUnavailableException: Unable to create
SCA binding invoker for local target CalculatorComponent reference
testService (bindingURI=null operation=sayHello)
at
org.apache.tuscany.sca.binding.sca.provider.RuntimeSCAReferenceBindingProvider.createInvoker(RuntimeSCAReferenceBindingProvider.java:200)



---------------------------------------------



2009/6/17 Raymond Feng <en...@gmail.com>

> Hi,
>
> Please see my comments inline.
>
> Thanks,
> Raymond
>
> ------------------------------------
> BUNDLE CALCULATOR
> ------------------------------------
> *****OSGI-INF/sca/bundle.composite. Two java components (Calculator and
> AddService) and one OSGi component (TestService)
>
> <rfeng>This is good.</rfeng>
>
>
> <sca:composite xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
> xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
> name="SensorNetworkManagement" targetNamespace="
> http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement
> ">
>
>  <sca:component name="CalculatorComponent">
>   <sca:implementation.java
> class="es.amivital.calculatorservice2.CalculatorServiceImpl"/>
>    <sca:service name="CalculatorService">
>  <sca:binding.ws uri="http://localhost:8085/CalculatorComponent"/>
>    </sca:service>
>
>    <sca:reference name="addService" target="AddServiceComponent"/>
>    <sca:reference name="testService"
> target="TestServiceComponent/TestService"/>
>  </sca:component>
>
>
>  <sca:component name="AddServiceComponent">
>   <sca:implementation.java
> class="es.amivital.calculatorservice2.AddServiceImpl"/>
>  </sca:component>
>
>  <sca:component name="TestServiceComponent">
>  <sca:implementation.osgi bundleSymbolicName="TestService"
> bundleVersion="1.0.0"/>
>  </sca:component>
> </sca:composite>
>
>
>
>
> *******OSGI-INF/sca/bundle.componentType
> <rfeng>You don't need to provide this file. The componentType is only
> needed for the OSGi component.</rfeng>
>
>
> <componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
>              xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>              xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1">
>   <!-- The service elment defines an SCA view of the OSGi service -->
>   <service name="CalculatorService">
>       <!-- The interface will be mapped into the OSGi service class -->
>       <interface.java
> interface="es.amivital.calculatorservice2.CalculatorService"/>
>       <!-- The list of OSGi properties -->
>
>   </service>
> </componentType>
>
> -----------------------------------
> BUNDLE TESTSERVICE
> -------------------------------------
>
>
> *******OSGI-INF/sca/bundle.componentType
> <rfeng>This is good.</rfeng>
>
>
> <componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
>              xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>              xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1">
>   <!-- The service elment defines an SCA view of the OSGi service -->
>   <service name="TestService">
>       <!-- The interface will be mapped into the OSGi service class -->
>       <interface.java interface="es.amivital.testservice.Test"/>
>       <!-- The list of OSGi properties -->
>
>   </service>
> </componentType>
>
>
> *****OSGI-INF/sca/bundle.composite
> <rfeng>This should be removed as the TestServiceComponent has been declared
> in the calculator bundle composite.</rfeng>
>
> <sca:composite xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
> xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
> name="SensorNetworkManagement" targetNamespace="
> http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement
> ">
>
>  <sca:component name="TestServiceComponent">
>  <sca:implementation.java class="es.amivital.testservice.TestImpl"/>
>  </sca:component>
> </sca:composite>
>
>
> It is necessary to have a bundle.composite file in TestService?? and
> bundle.componentType?? Can I remove these files from TestService bundle and
> put the TestService4s bundle.componentType in the Calculator bundle. You
> said "Alternatively, you have place the file as
> OSGI-INF/sca/<bundleSymbolicName>/bundle.componentType in the calculator
> bundle." Do you mean I can copy TestService4s bundle.componentType into a
> CalculatorService bundle?
>
> <rfeng>Yes</rfeng>
>
>
>
> Thank you very much
> -------------------------------------------------------------------
>
>
>
>
>
> Tuscany checks the OSGi bundle based on one of the following patterns:
> * An "SCA-Composite" header in the MANIFEST.MF. It points to an SCA
> composite file within the bundle.
> * Any files under OSGI-INF/sca.
>
> In your case, the first bundle contains three java components. The second
> bundle contains one OSGi component.  There are a few options to get them
> work together (CalculatorService with a reference to TestService).
>
> Option 1:
> 1) Place bundle.composite under OSGI-INF/sca in the calculator bundle. The
> composite contains 4 components: 3 java components and 1 OSGi component.
> The @target for CalculatorService component's testService reference will be
> TestService/<serviceName>.
>
> 2) Place bundle.componentType under OSGI-INF/sca in the test service
> bundle.
> Alternatively, you have place the file as
> OSGI-INF/sca/<bundleSymbolicName>/bundle.componentType in the calculator
> bundle.
>
> In this case, we are going to start one Node.
>
> Option 2:
> 1) Place bundle.composite under OSGI-INF/sca in the calculator bundle. The
> composite contains 3 java components
> 2) Place bundle.composite under OSGI-INF/sca in the test service bundle.
> The composite contains 1 OSGi component.
> 3) Place bundle.componentType under OSGI-INF/sca in the test service
> bundle.
>
> In this case, we are going to start two nodes. You can configure the
> CalculatorService.testService reference and the OSGi service to use the same
> binding (such as RMI, or WS) to communicate. Make sure the interface is
> remotable. binding.sca is not working yet.
>
> Thanks,
> Raymond
>
>
> From: santiago.aranda@telvent.com
>
> Sent: Tuesday, June 16, 2009 1:33 AM
>
> To: user@tuscany.apache.org
>
> Subject: Re: Fwd: Problem with "implementation.osgi" reference
>
>
>
>
> So, I have to attach two files (componentType and composite) to my two
> different bundles (TestService and Calculator) and model it as
> "implementation.osgi".   I have TestService in a bundle I will add these two
> file and I will design as "implementation.osgi" .
>
> But Calculator Service (this is in other bundle) has three components and
> they are all "implementation.java" and it is working OK. How can I put a
> reference to TestService?? Do I need change "implementation.osgi" in
> CalculatorComponent instead "implementation.java"? and is it neccesary for
> AddServiceComponent and SubstractService??
>
> I will try a example I will copy my files in the email.
>
> Thank you very much
>
> Un saludo.
> Santiago Miguel Aranda Rojas
> Telvent Interactiva
> Extension: 35999
> Telefono: 955637418
>
>
> "Raymond Feng" <en...@gmail.com>
> "Raymond Feng"
> 15/06/2009 18:36
> Para: <us...@tuscany.apache.org>, <sa...@telvent.com>
> cc:
> Asunto: Re: Fwd: Problem with "implementation.osgi" reference
>
>
>
>
> To access an OSGi service from the SCA component, you will have to provide
> SCA configurations for the OSGi bundle so that it becomes an SCA component
> using implementation.osgi and the OSGi service becomes an SCA service so
> that the Calculator component can wire to that TestService.
>
> There are two SCA files you to provide to model the OSGi bundle as an SCA
> component.
> * bundle.componentType to describe what OSGi services or references are
> used
> in the bundle (We potentially have better approach to introspect the OSGi
> bundle to build this up)
> * bundle.composite to configure the component, for example, setting the
> bindings.
>
> These files can be in a separate OSGi bundle than the one that owns the
> services/references.
>
> Thanks,
> Raymond
>
> From: Santiago Miguel Aranda Rojas
> Sent: Monday, June 15, 2009 4:01 AM
> To: user@tuscany.apache.org
> Subject: Fwd: Problem with "implementation.osgi" reference
>
>
>
>
>
>
> Hi
>
>
> I can not understand this sample because there are many new concepts for
> me.
> For example "bundle.componentType". There is not too much information about
> that . I think I need something more simple. I have attached a picture with
> my idea.
>
>
> ** When my SCA service was working I had a main component
> "implementacion.java" with two references to another two components
> (implementation.java). The main component could be invoked as Web Service.
>
>
> ** Now, I want another reference to a Service (TestService in the picture)
> that was registered by another different bundle. But this is a OSGi bundle,
> without SCA information, Composite file nor ComponentType file. I mean it
> is
> a bundle that is registering a service in the OSGi registry. I need have a
> instance wired to this OSGi service in the class of the main Component in
> order to invoke their methods.
>
>
> TestService testService;
>
>
> //I need testService is not null in order to invoke their methods.
> testService.sayHello();
>
>
>
>
> I hope you can understand my problem. You can ask me if you want.
>
>
> Thank you very mucha
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> 2009/6/10 Raymond Feng <en...@gmail.com>
>
> Please see:
>
> https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator/
>
> https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator-operations/
>
>
> http://cwiki.apache.org/confluence/display/TUSCANYWIKI/OSGi+RFC+119+Implementation
>
> Thanks,
> Raymond
>
>
> From: Santiago Miguel Aranda Rojas
> Sent: Wednesday, June 10, 2009 12:07 AM
> To: user@tuscany.apache.org
> Subject: Re: Problem with "implementation.osgi" reference
>
>
> Yes, you are right. I was doing some different tests and I copied you a
> wrong composite. I wanted to see if the change of @target made an error in
> tuscany.  But Tuscany doesn4t recognize this error because I think it
> supposes that will be a "remote Component". I can see this in the tuscany
> trace
>
>
> ADVERTENCIA: Component reference target not found, it might be a remote
> service running elsewhere in the SCA Domain: Composite =
> {
> http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement}SensorNetworkManagement<http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement%7DSensorNetworkManagement>
> Service = PruebaComponent
>
>
>
> But it is Ok, because the component I want if an Osgi Service registered in
> the Osgi registry.
> I have fixed the error in @target and it is not working yet.
>
>
> Do you know any example when an <implementation.osgi> component is used?
>
>
>
>
> I have tried to change  "xmlns" tag, but it doesn4t work.
>
>
> <sca:component name="PruebaComponent">
>    <sca:implementation.osgi
> xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
>         bundleSymbolicName="RegistroService"
>         bundleVersion="1.0.0">
>        <sca:properties service="prueba.PruebaImpl">
>        </sca:properties>
>    </sca:implementation.osgi>
>  </sca:component>
>
>
> Thank you very much.
>
>
>
> 2009/6/10 Raymond Feng <en...@gmail.com>
>
> The @target is pointing to a wrong componentName/serviceName. It should be
> "Prueba" instead of "PruebaComponent" as the component name is "Prueba".
>
>
> From: Santiago Miguel Aranda Rojas
> Sent: Tuesday, June 09, 2009 1:28 PM
> To: user@tuscany.apache.org
> Subject: Re: Problem with "implementation.osgi" reference
>
>
> Tuscany 2.02M. The last version I think. April 2009
> ----- Original Message ----- From: Raymond Feng
> To: user@tuscany.apache.org
> Sent: Tuesday, June 09, 2009 7:12 PM
> Subject: Re: Problem with "implementation.osgi" reference
>
>
> Are you using Tuscany/SCA 2.x or 1.x?
>
>
> From: santiago.aranda@telvent.com
> Sent: Tuesday, June 09, 2009 9:15 AM
> To: user@tuscany.apache.org
> Subject: Problem with "implementation.osgi" reference
>
>
>
> Hello
>
> I want to use an osgi service as a SCA component. But I can not access to
> their methods from other Component.  I mean I have created a wired instance
> to the Osgi Service ($Proxy25). It is not "null" but I can not invoke to
> one
> method because an error is happening
>
> --->Unable to create SCA binding invoker for local target
> SensorNetworkManagementComponent reference prueba (bindingURI=null
> operation=sayHello)
>
> This is my composite file. I want to have to two components. The first had
> a
> reference to the second and it is normal "implementation.java". The second
> is the SCA component that is representing to the Osgi Service that I want
> to
> recover. This Osgi Service was registered in the Osgi registry by Activator
> class in "RegistroService" bundle.
>
> <sca:component name="SensorNetworkManagementComponent">
> <sca:implementation.java
>
> class="es.amivital.sensornetworkmanagement.sca.SensorNetworkManagementServiceImpl"/>
> <sca:service name="SensorNetworkManagementService">
>  <sca:binding.ws
> uri="http://localhost:8085/SensorNetworkManagementComponent"/>
> </sca:service>
> <sca:reference name="prueba" target="PruebaComponent"/>
> </sca:component>
>
>
> <sca:component name="Prueba">
>    <sca:implementation.osgi
> xmlns="http://tuscany.apache.org/xmlns/sca/1.0"
>         bundleSymbolicName="RegistroService"
>         bundleVersion="1.0.0">
>        <sca:properties service="prueba.PruebaImpl">
>        </sca:properties>
>    </sca:implementation.osgi>
> </sca:component>
>
> ***The Java code--> The first component.
>
> public class SensorNetworkManagementServiceImpl  implements
> SensorNetworkManagementService {
> private Prueba prueba;
> public Prueba getPrueba() {
> return prueba;
> }
> @Reference
> public void setPrueba(Prueba prueba) {
> this.prueba = prueba;
> }
> }
>
> **Java code       --> The second component. It is another bundle that is
> registering one simple Osgi Service. The interface was
>
> public interface Prueba {
> public abstract String sayHello();
>
> }
>
>
>
>
>
> This instance (prueba) is not null when an outside client invoke to the
> first component. But if I invoke to one method of this interface, for
> example "prueba.sayHello" I obtained the previous error.
>
> I have read something about anottations like @AllowsPassByReference or
> @Scope, but I don4t know if they are neccesary .
>

Re: Fwd: Problem with "implementation.osgi" reference

Posted by Raymond Feng <en...@gmail.com>.
Hi,

Please see my comments inline.

Thanks,
Raymond

------------------------------------
BUNDLE CALCULATOR
------------------------------------
*****OSGI-INF/sca/bundle.composite. Two java components (Calculator and 
AddService) and one OSGi component (TestService)

<rfeng>This is good.</rfeng>


<sca:composite xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" 
xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903" 
name="SensorNetworkManagement" 
targetNamespace="http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement">

  <sca:component name="CalculatorComponent">
    <sca:implementation.java 
class="es.amivital.calculatorservice2.CalculatorServiceImpl"/>
     <sca:service name="CalculatorService">
  <sca:binding.ws uri="http://localhost:8085/CalculatorComponent"/>
     </sca:service>

     <sca:reference name="addService" target="AddServiceComponent"/>
     <sca:reference name="testService" 
target="TestServiceComponent/TestService"/>
  </sca:component>


  <sca:component name="AddServiceComponent">
    <sca:implementation.java 
class="es.amivital.calculatorservice2.AddServiceImpl"/>
  </sca:component>

  <sca:component name="TestServiceComponent">
   <sca:implementation.osgi bundleSymbolicName="TestService" 
bundleVersion="1.0.0"/>
  </sca:component>
</sca:composite>




*******OSGI-INF/sca/bundle.componentType
<rfeng>You don't need to provide this file. The componentType is only needed 
for the OSGi component.</rfeng>


<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1">
    <!-- The service elment defines an SCA view of the OSGi service -->
    <service name="CalculatorService">
        <!-- The interface will be mapped into the OSGi service class -->
        <interface.java 
interface="es.amivital.calculatorservice2.CalculatorService"/>
        <!-- The list of OSGi properties -->

    </service>
</componentType>

-----------------------------------
BUNDLE TESTSERVICE
-------------------------------------


*******OSGI-INF/sca/bundle.componentType
<rfeng>This is good.</rfeng>


<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1">
    <!-- The service elment defines an SCA view of the OSGi service -->
    <service name="TestService">
        <!-- The interface will be mapped into the OSGi service class -->
        <interface.java interface="es.amivital.testservice.Test"/>
        <!-- The list of OSGi properties -->

    </service>
</componentType>


*****OSGI-INF/sca/bundle.composite
<rfeng>This should be removed as the TestServiceComponent has been declared 
in the calculator bundle composite.</rfeng>

<sca:composite xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" 
xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903" 
name="SensorNetworkManagement" 
targetNamespace="http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement">

  <sca:component name="TestServiceComponent">
   <sca:implementation.java class="es.amivital.testservice.TestImpl"/>
  </sca:component>
</sca:composite>


It is necessary to have a bundle.composite file in TestService?? and 
bundle.componentType?? Can I remove these files from TestService bundle and 
put the TestService´s bundle.componentType in the Calculator bundle. You 
said "Alternatively, you have place the file as 
OSGI-INF/sca/<bundleSymbolicName>/bundle.componentType in the calculator 
bundle." Do you mean I can copy TestService´s bundle.componentType into a 
CalculatorService bundle?

<rfeng>Yes</rfeng>


Thank you very much
-------------------------------------------------------------------





Tuscany checks the OSGi bundle based on one of the following patterns:
* An "SCA-Composite" header in the MANIFEST.MF. It points to an SCA 
composite file within the bundle.
* Any files under OSGI-INF/sca.

In your case, the first bundle contains three java components. The second 
bundle contains one OSGi component.  There are a few options to get them 
work together (CalculatorService with a reference to TestService).

Option 1:
1) Place bundle.composite under OSGI-INF/sca in the calculator bundle. The 
composite contains 4 components: 3 java components and 1 OSGi component.
The @target for CalculatorService component's testService reference will be 
TestService/<serviceName>.

2) Place bundle.componentType under OSGI-INF/sca in the test service bundle.
Alternatively, you have place the file as 
OSGI-INF/sca/<bundleSymbolicName>/bundle.componentType in the calculator 
bundle.

In this case, we are going to start one Node.

Option 2:
1) Place bundle.composite under OSGI-INF/sca in the calculator bundle. The 
composite contains 3 java components
2) Place bundle.composite under OSGI-INF/sca in the test service bundle. The 
composite contains 1 OSGi component.
3) Place bundle.componentType under OSGI-INF/sca in the test service bundle.

In this case, we are going to start two nodes. You can configure the 
CalculatorService.testService reference and the OSGi service to use the same 
binding (such as RMI, or WS) to communicate. Make sure the interface is 
remotable. binding.sca is not working yet.

Thanks,
Raymond


From: santiago.aranda@telvent.com

Sent: Tuesday, June 16, 2009 1:33 AM

To: user@tuscany.apache.org

Subject: Re: Fwd: Problem with "implementation.osgi" reference




So, I have to attach two files (componentType and composite) to my two 
different bundles (TestService and Calculator) and model it as 
"implementation.osgi".   I have TestService in a bundle I will add these two 
file and I will design as "implementation.osgi" .

But Calculator Service (this is in other bundle) has three components and 
they are all "implementation.java" and it is working OK. How can I put a 
reference to TestService?? Do I need change "implementation.osgi" in 
CalculatorComponent instead "implementation.java"? and is it neccesary for 
AddServiceComponent and SubstractService??

I will try a example I will copy my files in the email.

Thank you very much

Un saludo.
Santiago Miguel Aranda Rojas
Telvent Interactiva
Extension: 35999
Telefono: 955637418


"Raymond Feng" <en...@gmail.com>
"Raymond Feng"
15/06/2009 18:36
Para: <us...@tuscany.apache.org>, <sa...@telvent.com>
cc:
Asunto: Re: Fwd: Problem with "implementation.osgi" reference




To access an OSGi service from the SCA component, you will have to provide
SCA configurations for the OSGi bundle so that it becomes an SCA component
using implementation.osgi and the OSGi service becomes an SCA service so
that the Calculator component can wire to that TestService.

There are two SCA files you to provide to model the OSGi bundle as an SCA
component.
* bundle.componentType to describe what OSGi services or references are used
in the bundle (We potentially have better approach to introspect the OSGi
bundle to build this up)
* bundle.composite to configure the component, for example, setting the
bindings.

These files can be in a separate OSGi bundle than the one that owns the
services/references.

Thanks,
Raymond

From: Santiago Miguel Aranda Rojas
Sent: Monday, June 15, 2009 4:01 AM
To: user@tuscany.apache.org
Subject: Fwd: Problem with "implementation.osgi" reference






Hi


I can not understand this sample because there are many new concepts for me.
For example "bundle.componentType". There is not too much information about
that . I think I need something more simple. I have attached a picture with
my idea.


** When my SCA service was working I had a main component
"implementacion.java" with two references to another two components
(implementation.java). The main component could be invoked as Web Service.


** Now, I want another reference to a Service (TestService in the picture)
that was registered by another different bundle. But this is a OSGi bundle,
without SCA information, Composite file nor ComponentType file. I mean it is
a bundle that is registering a service in the OSGi registry. I need have a
instance wired to this OSGi service in the class of the main Component in
order to invoke their methods.


TestService testService;


//I need testService is not null in order to invoke their methods.
testService.sayHello();




I hope you can understand my problem. You can ask me if you want.


Thank you very mucha

















2009/6/10 Raymond Feng <en...@gmail.com>

Please see:

https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator/
https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator-operations/

http://cwiki.apache.org/confluence/display/TUSCANYWIKI/OSGi+RFC+119+Implementation

Thanks,
Raymond


From: Santiago Miguel Aranda Rojas
Sent: Wednesday, June 10, 2009 12:07 AM
To: user@tuscany.apache.org
Subject: Re: Problem with "implementation.osgi" reference


Yes, you are right. I was doing some different tests and I copied you a
wrong composite. I wanted to see if the change of @target made an error in
tuscany.  But Tuscany doesn4t recognize this error because I think it
supposes that will be a "remote Component". I can see this in the tuscany
trace


ADVERTENCIA: Component reference target not found, it might be a remote
service running elsewhere in the SCA Domain: Composite =
{http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement}SensorNetworkManagement
Service = PruebaComponent



But it is Ok, because the component I want if an Osgi Service registered in
the Osgi registry.
I have fixed the error in @target and it is not working yet.


Do you know any example when an <implementation.osgi> component is used?




I have tried to change  "xmlns" tag, but it doesn4t work.


<sca:component name="PruebaComponent">
     <sca:implementation.osgi
xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
          bundleSymbolicName="RegistroService"
          bundleVersion="1.0.0">
         <sca:properties service="prueba.PruebaImpl">
         </sca:properties>
     </sca:implementation.osgi>
   </sca:component>


Thank you very much.



2009/6/10 Raymond Feng <en...@gmail.com>

The @target is pointing to a wrong componentName/serviceName. It should be
"Prueba" instead of "PruebaComponent" as the component name is "Prueba".


From: Santiago Miguel Aranda Rojas
Sent: Tuesday, June 09, 2009 1:28 PM
To: user@tuscany.apache.org
Subject: Re: Problem with "implementation.osgi" reference


Tuscany 2.02M. The last version I think. April 2009
----- Original Message ----- From: Raymond Feng
To: user@tuscany.apache.org
Sent: Tuesday, June 09, 2009 7:12 PM
Subject: Re: Problem with "implementation.osgi" reference


Are you using Tuscany/SCA 2.x or 1.x?


From: santiago.aranda@telvent.com
Sent: Tuesday, June 09, 2009 9:15 AM
To: user@tuscany.apache.org
Subject: Problem with "implementation.osgi" reference



Hello

I want to use an osgi service as a SCA component. But I can not access to
their methods from other Component.  I mean I have created a wired instance
to the Osgi Service ($Proxy25). It is not "null" but I can not invoke to one
method because an error is happening

--->Unable to create SCA binding invoker for local target
SensorNetworkManagementComponent reference prueba (bindingURI=null
operation=sayHello)

This is my composite file. I want to have to two components. The first had a
reference to the second and it is normal "implementation.java". The second
is the SCA component that is representing to the Osgi Service that I want to
recover. This Osgi Service was registered in the Osgi registry by Activator
class in "RegistroService" bundle.

<sca:component name="SensorNetworkManagementComponent">
 <sca:implementation.java
class="es.amivital.sensornetworkmanagement.sca.SensorNetworkManagementServiceImpl"/>
 <sca:service name="SensorNetworkManagementService">
  <sca:binding.ws
uri="http://localhost:8085/SensorNetworkManagementComponent"/>
 </sca:service>
<sca:reference name="prueba" target="PruebaComponent"/>
</sca:component>


<sca:component name="Prueba">
     <sca:implementation.osgi
xmlns="http://tuscany.apache.org/xmlns/sca/1.0"
          bundleSymbolicName="RegistroService"
          bundleVersion="1.0.0">
         <sca:properties service="prueba.PruebaImpl">
         </sca:properties>
     </sca:implementation.osgi>
</sca:component>

***The Java code--> The first component.

public class SensorNetworkManagementServiceImpl  implements
SensorNetworkManagementService {
private Prueba prueba;
public Prueba getPrueba() {
return prueba;
}
@Reference
public void setPrueba(Prueba prueba) {
this.prueba = prueba;
}
}

**Java code       --> The second component. It is another bundle that is
registering one simple Osgi Service. The interface was

public interface Prueba {
public abstract String sayHello();

}





This instance (prueba) is not null when an outside client invoke to the
first component. But if I invoke to one method of this interface, for
example "prueba.sayHello" I obtained the previous error.

I have read something about anottations like @AllowsPassByReference or
@Scope, but I don4t know if they are neccesary . 


Re: Fwd: Problem with "implementation.osgi" reference

Posted by Santiago Miguel Aranda Rojas <sa...@gmail.com>.
While I fix the previous error (register a SCA node without code) I am
writing the composite and componentType files.
I have chose the first option. But I need you check the content if it is
possible.

------------------------------------
BUNDLE CALCULATOR
------------------------------------
******OSGI-INF/sca/bundle.**composite.* Two java components (Calculator and
AddService) and one OSGi component (TestService)


<sca:composite xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
name="SensorNetworkManagement" targetNamespace="
http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement
">

  <sca:component name="CalculatorComponent">
    <sca:implementation.java
class="es.amivital.calculatorservice2.CalculatorServiceImpl"/>
     <sca:service name="CalculatorService">
  <sca:binding.ws uri="http://localhost:8085/CalculatorComponent"/>
     </sca:service>

     <sca:reference name="addService" target="AddServiceComponent"/>
     <sca:reference name="testService"
target="TestServiceComponent/TestService"/>
  </sca:component>


  <sca:component name="AddServiceComponent">
    <sca:implementation.java
class="es.amivital.calculatorservice2.AddServiceImpl"/>
  </sca:component>

  <sca:component name="TestServiceComponent">
   <sca:implementation.osgi bundleSymbolicName="TestService"
bundleVersion="1.0.0"/>
  </sca:component>
</sca:composite>


********OSGI-INF/sca/bundle.componentType*

<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1">
    <!-- The service elment defines an SCA view of the OSGi service -->
    <service name="CalculatorService">
        <!-- The interface will be mapped into the OSGi service class -->
        <interface.java
interface="es.amivital.calculatorservice2.CalculatorService"/>
        <!-- The list of OSGi properties -->

    </service>
</componentType>



-----------------------------------
BUNDLE TESTSERVICE
-------------------------------------

*******OSGI-INF/sca/bundle.componentType

*<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1">
    <!-- The service elment defines an SCA view of the OSGi service -->
    <service name="TestService">
        <!-- The interface will be mapped into the OSGi service class -->
        <interface.java interface="es.amivital.testservice.Test"/>
        <!-- The list of OSGi properties -->

    </service>
</componentType>
*
*
*
******OSGI-INF/sca/bundle.composite*
*<sca:composite xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
name="SensorNetworkManagement" targetNamespace="
http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement
">



  <sca:component name="TestServiceComponent">
   <sca:implementation.java class="es.amivital.testservice.TestImpl"/>
  </sca:component>
</sca:composite>


It is necessary to have a bundle.composite file in TestService?? and
bundle.componentType?? Can I remove these files from TestService bundle and
put the TestService´s bundle.componentType in the Calculator bundle. You
said "Alternatively, you have place the file as
OSGI-INF/sca/<bundleSymbolicName>/bundle.componentType in the calculator
bundle." Do you mean I can copy TestService´s bundle.componentType into a
CalculatorService bundle?


Thank you very much
-------------------------------------------------------------------
*




> Tuscany checks the OSGi bundle based on one of the following patterns:
>> * An "SCA-Composite" header in the MANIFEST.MF. It points to an SCA
>> composite file within the bundle.
>> * Any files under OSGI-INF/sca.
>>
>> In your case, the first bundle contains three java components. The second
>> bundle contains one OSGi component.  There are a few options to get them
>> work together (CalculatorService with a reference to TestService).
>>
>> Option 1:
>> 1) Place bundle.composite under OSGI-INF/sca in the calculator bundle. The
>> composite contains 4 components: 3 java components and 1 OSGi component.
>> The @target for CalculatorService component's testService reference will
>> be TestService/<serviceName>.
>>
>> 2) Place bundle.componentType under OSGI-INF/sca in the test service
>> bundle.
>> Alternatively, you have place the file as
>> OSGI-INF/sca/<bundleSymbolicName>/bundle.componentType in the calculator
>> bundle.
>>
>> In this case, we are going to start one Node.
>>
>> Option 2:
>> 1) Place bundle.composite under OSGI-INF/sca in the calculator bundle. The
>> composite contains 3 java components
>> 2) Place bundle.composite under OSGI-INF/sca in the test service bundle.
>> The composite contains 1 OSGi component.
>> 3) Place bundle.componentType under OSGI-INF/sca in the test service
>> bundle.
>>
>> In this case, we are going to start two nodes. You can configure the
>> CalculatorService.testService reference and the OSGi service to use the same
>> binding (such as RMI, or WS) to communicate. Make sure the interface is
>> remotable. binding.sca is not working yet.
>>
>> Thanks,
>> Raymond
>>
>> From: santiago.aranda@telvent.com
>> Sent: Tuesday, June 16, 2009 1:33 AM
>> To: user@tuscany.apache.org
>> Subject: Re: Fwd: Problem with "implementation.osgi" reference
>>
>>
>>
>>
>> So, I have to attach two files (componentType and composite) to my two
>> different bundles (TestService and Calculator) and model it as
>> "implementation.osgi".   I have TestService in a bundle I will add these two
>> file and I will design as "implementation.osgi" .
>>
>> But Calculator Service (this is in other bundle) has three components and
>> they are all "implementation.java" and it is working OK. How can I put a
>> reference to TestService?? Do I need change "implementation.osgi" in
>> CalculatorComponent instead "implementation.java"? and is it neccesary for
>> AddServiceComponent and SubstractService??
>>
>> I will try a example I will copy my files in the email.
>>
>> Thank you very much
>>
>> Un saludo.
>> Santiago Miguel Aranda Rojas
>> Telvent Interactiva
>> Extension: 35999
>> Telefono: 955637418
>>
>>
>> "Raymond Feng" <en...@gmail.com>
>> "Raymond Feng"
>> 15/06/2009 18:36
>> Para: <us...@tuscany.apache.org>, <sa...@telvent.com>
>> cc:
>> Asunto: Re: Fwd: Problem with "implementation.osgi" reference
>>
>>
>>
>>
>> To access an OSGi service from the SCA component, you will have to provide
>> SCA configurations for the OSGi bundle so that it becomes an SCA component
>> using implementation.osgi and the OSGi service becomes an SCA service so
>> that the Calculator component can wire to that TestService.
>>
>> There are two SCA files you to provide to model the OSGi bundle as an SCA
>> component.
>> * bundle.componentType to describe what OSGi services or references are
>> used
>> in the bundle (We potentially have better approach to introspect the OSGi
>> bundle to build this up)
>> * bundle.composite to configure the component, for example, setting the
>> bindings.
>>
>> These files can be in a separate OSGi bundle than the one that owns the
>> services/references.
>>
>> Thanks,
>> Raymond
>>
>> From: Santiago Miguel Aranda Rojas
>> Sent: Monday, June 15, 2009 4:01 AM
>> To: user@tuscany.apache.org
>> Subject: Fwd: Problem with "implementation.osgi" reference
>>
>>
>>
>>
>>
>>
>> Hi
>>
>>
>> I can not understand this sample because there are many new concepts for
>> me.
>> For example "bundle.componentType". There is not too much information
>> about
>> that . I think I need something more simple. I have attached a picture
>> with
>> my idea.
>>
>>
>> ** When my SCA service was working I had a main component
>> "implementacion.java" with two references to another two components
>> (implementation.java). The main component could be invoked as Web Service.
>>
>>
>> ** Now, I want another reference to a Service (TestService in the picture)
>> that was registered by another different bundle. But this is a OSGi
>> bundle,
>> without SCA information, Composite file nor ComponentType file. I mean it
>> is
>> a bundle that is registering a service in the OSGi registry. I need have a
>> instance wired to this OSGi service in the class of the main Component in
>> order to invoke their methods.
>>
>>
>> TestService testService;
>>
>>
>> //I need testService is not null in order to invoke their methods.
>> testService.sayHello();
>>
>>
>>
>>
>> I hope you can understand my problem. You can ask me if you want.
>>
>>
>> Thank you very mucha
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> 2009/6/10 Raymond Feng <en...@gmail.com>
>>
>> Please see:
>>
>>
>> https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator/
>>
>> https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator-operations/
>>
>>
>> http://cwiki.apache.org/confluence/display/TUSCANYWIKI/OSGi+RFC+119+Implementation
>>
>> Thanks,
>> Raymond
>>
>>
>> From: Santiago Miguel Aranda Rojas
>> Sent: Wednesday, June 10, 2009 12:07 AM
>> To: user@tuscany.apache.org
>> Subject: Re: Problem with "implementation.osgi" reference
>>
>>
>> Yes, you are right. I was doing some different tests and I copied you a
>> wrong composite. I wanted to see if the change of @target made an error in
>> tuscany.  But Tuscany doesn4t recognize this error because I think it
>> supposes that will be a "remote Component". I can see this in the tuscany
>> trace
>>
>>
>> ADVERTENCIA: Component reference target not found, it might be a remote
>> service running elsewhere in the SCA Domain: Composite =
>> {
>> http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement}SensorNetworkManagement<http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement%7DSensorNetworkManagement>
>> Service = PruebaComponent
>>
>>
>>
>> But it is Ok, because the component I want if an Osgi Service registered
>> in
>> the Osgi registry.
>> I have fixed the error in @target and it is not working yet.
>>
>>
>> Do you know any example when an <implementation.osgi> component is used?
>>
>>
>>
>>
>> I have tried to change  "xmlns" tag, but it doesn4t work.
>>
>>
>> <sca:component name="PruebaComponent">
>>      <sca:implementation.osgi
>> xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
>>           bundleSymbolicName="RegistroService"
>>           bundleVersion="1.0.0">
>>          <sca:properties service="prueba.PruebaImpl">
>>          </sca:properties>
>>      </sca:implementation.osgi>
>>    </sca:component>
>>
>>
>> Thank you very much.
>>
>>
>>
>> 2009/6/10 Raymond Feng <en...@gmail.com>
>>
>> The @target is pointing to a wrong componentName/serviceName. It should be
>> "Prueba" instead of "PruebaComponent" as the component name is "Prueba".
>>
>>
>> From: Santiago Miguel Aranda Rojas
>> Sent: Tuesday, June 09, 2009 1:28 PM
>> To: user@tuscany.apache.org
>> Subject: Re: Problem with "implementation.osgi" reference
>>
>>
>> Tuscany 2.02M. The last version I think. April 2009
>> ----- Original Message ----- From: Raymond Feng
>> To: user@tuscany.apache.org
>> Sent: Tuesday, June 09, 2009 7:12 PM
>> Subject: Re: Problem with "implementation.osgi" reference
>>
>>
>> Are you using Tuscany/SCA 2.x or 1.x?
>>
>>
>> From: santiago.aranda@telvent.com
>> Sent: Tuesday, June 09, 2009 9:15 AM
>> To: user@tuscany.apache.org
>> Subject: Problem with "implementation.osgi" reference
>>
>>
>>
>> Hello
>>
>> I want to use an osgi service as a SCA component. But I can not access to
>> their methods from other Component.  I mean I have created a wired
>> instance
>> to the Osgi Service ($Proxy25). It is not "null" but I can not invoke to
>> one
>> method because an error is happening
>>
>> --->Unable to create SCA binding invoker for local target
>> SensorNetworkManagementComponent reference prueba (bindingURI=null
>> operation=sayHello)
>>
>> This is my composite file. I want to have to two components. The first had
>> a
>> reference to the second and it is normal "implementation.java". The second
>> is the SCA component that is representing to the Osgi Service that I want
>> to
>> recover. This Osgi Service was registered in the Osgi registry by
>> Activator
>> class in "RegistroService" bundle.
>>
>> <sca:component name="SensorNetworkManagementComponent">
>>  <sca:implementation.java
>>
>> class="es.amivital.sensornetworkmanagement.sca.SensorNetworkManagementServiceImpl"/>
>>  <sca:service name="SensorNetworkManagementService">
>>   <sca:binding.ws
>> uri="http://localhost:8085/SensorNetworkManagementComponent"/>
>>  </sca:service>
>> <sca:reference name="prueba" target="PruebaComponent"/>
>> </sca:component>
>>
>>
>> <sca:component name="Prueba">
>>      <sca:implementation.osgi
>> xmlns="http://tuscany.apache.org/xmlns/sca/1.0"
>>           bundleSymbolicName="RegistroService"
>>           bundleVersion="1.0.0">
>>          <sca:properties service="prueba.PruebaImpl">
>>          </sca:properties>
>>      </sca:implementation.osgi>
>> </sca:component>
>>
>> ***The Java code--> The first component.
>>
>> public class SensorNetworkManagementServiceImpl  implements
>> SensorNetworkManagementService {
>> private Prueba prueba;
>> public Prueba getPrueba() {
>> return prueba;
>> }
>> @Reference
>> public void setPrueba(Prueba prueba) {
>> this.prueba = prueba;
>> }
>> }
>>
>> **Java code       --> The second component. It is another bundle that is
>> registering one simple Osgi Service. The interface was
>>
>> public interface Prueba {
>> public abstract String sayHello();
>>
>> }
>>
>>
>>
>>
>>
>> This instance (prueba) is not null when an outside client invoke to the
>> first component. But if I invoke to one method of this interface, for
>> example "prueba.sayHello" I obtained the previous error.
>>
>> I have read something about anottations like @AllowsPassByReference or
>> @Scope, but I don4t know if they are neccesary .
>>
>
>

Re: Fwd: Problem with "implementation.osgi" reference

Posted by Santiago Miguel Aranda Rojas <sa...@gmail.com>.
While I fix the previous error (register a SCA node without code) I am
writing the composite and componentType files.
I have chose the first option. But I need you check the content if it is
possible.

*****OSGI-INF/sca/bundle.composite


<sca:composite xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
name="SensorNetworkManagement" targetNamespace="
http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement
">

  <sca:component name="CalculatorComponent">
    <sca:implementation.java
class="es.amivital.calculatorservice2.CalculatorServiceImpl"/>
    <sca:service name="CalculatorService">
 <sca:binding.ws uri="http://localhost:8085/CalculatorComponent"/>
    </sca:service>

    <sca:reference name="addService" target="AddServiceComponent"/>

    <sca:reference name="testService"
target="TestServiceComponent/TestService"/>

  </sca:component>


  <sca:component name="AddServiceComponent">
    <sca:implementation.java
class="es.amivital.calculatorservice2.AddServiceImpl"/>
  </sca:component>

  <sca:component name="TestServiceComponent">
   <sca:implementation.osgi bundleSymbolicName="TestService"
bundleVersion="1.0.0"/>
  </sca:component>


</sca:composite>



2009/6/16 Raymond Feng <en...@gmail.com>

> Tuscany checks the OSGi bundle based on one of the following patterns:
> * An "SCA-Composite" header in the MANIFEST.MF. It points to an SCA
> composite file within the bundle.
> * Any files under OSGI-INF/sca.
>
> In your case, the first bundle contains three java components. The second
> bundle contains one OSGi component.  There are a few options to get them
> work together (CalculatorService with a reference to TestService).
>
> Option 1:
> 1) Place bundle.composite under OSGI-INF/sca in the calculator bundle. The
> composite contains 4 components: 3 java components and 1 OSGi component.
> The @target for CalculatorService component's testService reference will be
> TestService/<serviceName>.
>
> 2) Place bundle.componentType under OSGI-INF/sca in the test service
> bundle.
> Alternatively, you have place the file as
> OSGI-INF/sca/<bundleSymbolicName>/bundle.componentType in the calculator
> bundle.
>
> In this case, we are going to start one Node.
>
> Option 2:
> 1) Place bundle.composite under OSGI-INF/sca in the calculator bundle. The
> composite contains 3 java components
> 2) Place bundle.composite under OSGI-INF/sca in the test service bundle.
> The composite contains 1 OSGi component.
> 3) Place bundle.componentType under OSGI-INF/sca in the test service
> bundle.
>
> In this case, we are going to start two nodes. You can configure the
> CalculatorService.testService reference and the OSGi service to use the same
> binding (such as RMI, or WS) to communicate. Make sure the interface is
> remotable. binding.sca is not working yet.
>
> Thanks,
> Raymond
>
> From: santiago.aranda@telvent.com
> Sent: Tuesday, June 16, 2009 1:33 AM
> To: user@tuscany.apache.org
> Subject: Re: Fwd: Problem with "implementation.osgi" reference
>
>
>
>
> So, I have to attach two files (componentType and composite) to my two
> different bundles (TestService and Calculator) and model it as
> "implementation.osgi".   I have TestService in a bundle I will add these two
> file and I will design as "implementation.osgi" .
>
> But Calculator Service (this is in other bundle) has three components and
> they are all "implementation.java" and it is working OK. How can I put a
> reference to TestService?? Do I need change "implementation.osgi" in
> CalculatorComponent instead "implementation.java"? and is it neccesary for
> AddServiceComponent and SubstractService??
>
> I will try a example I will copy my files in the email.
>
> Thank you very much
>
> Un saludo.
> Santiago Miguel Aranda Rojas
> Telvent Interactiva
> Extension: 35999
> Telefono: 955637418
>
>
> "Raymond Feng" <en...@gmail.com>
> "Raymond Feng"
> 15/06/2009 18:36
> Para: <us...@tuscany.apache.org>, <sa...@telvent.com>
> cc:
> Asunto: Re: Fwd: Problem with "implementation.osgi" reference
>
>
>
>
> To access an OSGi service from the SCA component, you will have to provide
> SCA configurations for the OSGi bundle so that it becomes an SCA component
> using implementation.osgi and the OSGi service becomes an SCA service so
> that the Calculator component can wire to that TestService.
>
> There are two SCA files you to provide to model the OSGi bundle as an SCA
> component.
> * bundle.componentType to describe what OSGi services or references are
> used
> in the bundle (We potentially have better approach to introspect the OSGi
> bundle to build this up)
> * bundle.composite to configure the component, for example, setting the
> bindings.
>
> These files can be in a separate OSGi bundle than the one that owns the
> services/references.
>
> Thanks,
> Raymond
>
> From: Santiago Miguel Aranda Rojas
> Sent: Monday, June 15, 2009 4:01 AM
> To: user@tuscany.apache.org
> Subject: Fwd: Problem with "implementation.osgi" reference
>
>
>
>
>
>
> Hi
>
>
> I can not understand this sample because there are many new concepts for
> me.
> For example "bundle.componentType". There is not too much information about
> that . I think I need something more simple. I have attached a picture with
> my idea.
>
>
> ** When my SCA service was working I had a main component
> "implementacion.java" with two references to another two components
> (implementation.java). The main component could be invoked as Web Service.
>
>
> ** Now, I want another reference to a Service (TestService in the picture)
> that was registered by another different bundle. But this is a OSGi bundle,
> without SCA information, Composite file nor ComponentType file. I mean it
> is
> a bundle that is registering a service in the OSGi registry. I need have a
> instance wired to this OSGi service in the class of the main Component in
> order to invoke their methods.
>
>
> TestService testService;
>
>
> //I need testService is not null in order to invoke their methods.
> testService.sayHello();
>
>
>
>
> I hope you can understand my problem. You can ask me if you want.
>
>
> Thank you very mucha
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> 2009/6/10 Raymond Feng <en...@gmail.com>
>
> Please see:
>
> https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator/
>
> https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator-operations/
>
>
> http://cwiki.apache.org/confluence/display/TUSCANYWIKI/OSGi+RFC+119+Implementation
>
> Thanks,
> Raymond
>
>
> From: Santiago Miguel Aranda Rojas
> Sent: Wednesday, June 10, 2009 12:07 AM
> To: user@tuscany.apache.org
> Subject: Re: Problem with "implementation.osgi" reference
>
>
> Yes, you are right. I was doing some different tests and I copied you a
> wrong composite. I wanted to see if the change of @target made an error in
> tuscany.  But Tuscany doesn4t recognize this error because I think it
> supposes that will be a "remote Component". I can see this in the tuscany
> trace
>
>
> ADVERTENCIA: Component reference target not found, it might be a remote
> service running elsewhere in the SCA Domain: Composite =
> {
> http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement}SensorNetworkManagement<http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement%7DSensorNetworkManagement>
> Service = PruebaComponent
>
>
>
> But it is Ok, because the component I want if an Osgi Service registered in
> the Osgi registry.
> I have fixed the error in @target and it is not working yet.
>
>
> Do you know any example when an <implementation.osgi> component is used?
>
>
>
>
> I have tried to change  "xmlns" tag, but it doesn4t work.
>
>
> <sca:component name="PruebaComponent">
>      <sca:implementation.osgi
> xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
>           bundleSymbolicName="RegistroService"
>           bundleVersion="1.0.0">
>          <sca:properties service="prueba.PruebaImpl">
>          </sca:properties>
>      </sca:implementation.osgi>
>    </sca:component>
>
>
> Thank you very much.
>
>
>
> 2009/6/10 Raymond Feng <en...@gmail.com>
>
> The @target is pointing to a wrong componentName/serviceName. It should be
> "Prueba" instead of "PruebaComponent" as the component name is "Prueba".
>
>
> From: Santiago Miguel Aranda Rojas
> Sent: Tuesday, June 09, 2009 1:28 PM
> To: user@tuscany.apache.org
> Subject: Re: Problem with "implementation.osgi" reference
>
>
> Tuscany 2.02M. The last version I think. April 2009
> ----- Original Message ----- From: Raymond Feng
> To: user@tuscany.apache.org
> Sent: Tuesday, June 09, 2009 7:12 PM
> Subject: Re: Problem with "implementation.osgi" reference
>
>
> Are you using Tuscany/SCA 2.x or 1.x?
>
>
> From: santiago.aranda@telvent.com
> Sent: Tuesday, June 09, 2009 9:15 AM
> To: user@tuscany.apache.org
> Subject: Problem with "implementation.osgi" reference
>
>
>
> Hello
>
> I want to use an osgi service as a SCA component. But I can not access to
> their methods from other Component.  I mean I have created a wired instance
> to the Osgi Service ($Proxy25). It is not "null" but I can not invoke to
> one
> method because an error is happening
>
> --->Unable to create SCA binding invoker for local target
> SensorNetworkManagementComponent reference prueba (bindingURI=null
> operation=sayHello)
>
> This is my composite file. I want to have to two components. The first had
> a
> reference to the second and it is normal "implementation.java". The second
> is the SCA component that is representing to the Osgi Service that I want
> to
> recover. This Osgi Service was registered in the Osgi registry by Activator
> class in "RegistroService" bundle.
>
> <sca:component name="SensorNetworkManagementComponent">
>  <sca:implementation.java
>
> class="es.amivital.sensornetworkmanagement.sca.SensorNetworkManagementServiceImpl"/>
>  <sca:service name="SensorNetworkManagementService">
>   <sca:binding.ws
> uri="http://localhost:8085/SensorNetworkManagementComponent"/>
>  </sca:service>
> <sca:reference name="prueba" target="PruebaComponent"/>
> </sca:component>
>
>
> <sca:component name="Prueba">
>      <sca:implementation.osgi
> xmlns="http://tuscany.apache.org/xmlns/sca/1.0"
>           bundleSymbolicName="RegistroService"
>           bundleVersion="1.0.0">
>          <sca:properties service="prueba.PruebaImpl">
>          </sca:properties>
>      </sca:implementation.osgi>
> </sca:component>
>
> ***The Java code--> The first component.
>
> public class SensorNetworkManagementServiceImpl  implements
> SensorNetworkManagementService {
> private Prueba prueba;
> public Prueba getPrueba() {
> return prueba;
> }
> @Reference
> public void setPrueba(Prueba prueba) {
> this.prueba = prueba;
> }
> }
>
> **Java code       --> The second component. It is another bundle that is
> registering one simple Osgi Service. The interface was
>
> public interface Prueba {
> public abstract String sayHello();
>
> }
>
>
>
>
>
> This instance (prueba) is not null when an outside client invoke to the
> first component. But if I invoke to one method of this interface, for
> example "prueba.sayHello" I obtained the previous error.
>
> I have read something about anottations like @AllowsPassByReference or
> @Scope, but I don4t know if they are neccesary .
>

Re: Fwd: Problem with "implementation.osgi" reference

Posted by Raymond Feng <en...@gmail.com>.
Tuscany checks the OSGi bundle based on one of the following patterns:
* An "SCA-Composite" header in the MANIFEST.MF. It points to an SCA 
composite file within the bundle.
* Any files under OSGI-INF/sca.

In your case, the first bundle contains three java components. The second 
bundle contains one OSGi component.  There are a few options to get them 
work together (CalculatorService with a reference to TestService).

Option 1:
1) Place bundle.composite under OSGI-INF/sca in the calculator bundle. The 
composite contains 4 components: 3 java components and 1 OSGi component.
The @target for CalculatorService component's testService reference will be 
TestService/<serviceName>.

2) Place bundle.componentType under OSGI-INF/sca in the test service bundle.
Alternatively, you have place the file as 
OSGI-INF/sca/<bundleSymbolicName>/bundle.componentType in the calculator 
bundle.

In this case, we are going to start one Node.

Option 2:
1) Place bundle.composite under OSGI-INF/sca in the calculator bundle. The 
composite contains 3 java components
2) Place bundle.composite under OSGI-INF/sca in the test service bundle. The 
composite contains 1 OSGi component.
3) Place bundle.componentType under OSGI-INF/sca in the test service bundle.

In this case, we are going to start two nodes. You can configure the 
CalculatorService.testService reference and the OSGi service to use the same 
binding (such as RMI, or WS) to communicate. Make sure the interface is 
remotable. binding.sca is not working yet.

Thanks,
Raymond

From: santiago.aranda@telvent.com
Sent: Tuesday, June 16, 2009 1:33 AM
To: user@tuscany.apache.org
Subject: Re: Fwd: Problem with "implementation.osgi" reference



So, I have to attach two files (componentType and composite) to my two 
different bundles (TestService and Calculator) and model it as 
"implementation.osgi".   I have TestService in a bundle I will add these two 
file and I will design as "implementation.osgi" .

But Calculator Service (this is in other bundle) has three components and 
they are all "implementation.java" and it is working OK. How can I put a 
reference to TestService?? Do I need change "implementation.osgi" in 
CalculatorComponent instead "implementation.java"? and is it neccesary for 
AddServiceComponent and SubstractService??

I will try a example I will copy my files in the email.

Thank you very much

Un saludo.
Santiago Miguel Aranda Rojas
Telvent Interactiva
Extension: 35999
Telefono: 955637418


"Raymond Feng" <en...@gmail.com>
"Raymond Feng"
15/06/2009 18:36
Para: <us...@tuscany.apache.org>, <sa...@telvent.com>
cc:
Asunto: Re: Fwd: Problem with "implementation.osgi" reference




To access an OSGi service from the SCA component, you will have to provide
SCA configurations for the OSGi bundle so that it becomes an SCA component
using implementation.osgi and the OSGi service becomes an SCA service so
that the Calculator component can wire to that TestService.

There are two SCA files you to provide to model the OSGi bundle as an SCA
component.
* bundle.componentType to describe what OSGi services or references are used
in the bundle (We potentially have better approach to introspect the OSGi
bundle to build this up)
* bundle.composite to configure the component, for example, setting the
bindings.

These files can be in a separate OSGi bundle than the one that owns the
services/references.

Thanks,
Raymond

From: Santiago Miguel Aranda Rojas
Sent: Monday, June 15, 2009 4:01 AM
To: user@tuscany.apache.org
Subject: Fwd: Problem with "implementation.osgi" reference






Hi


I can not understand this sample because there are many new concepts for me.
For example "bundle.componentType". There is not too much information about
that . I think I need something more simple. I have attached a picture with
my idea.


** When my SCA service was working I had a main component
"implementacion.java" with two references to another two components
(implementation.java). The main component could be invoked as Web Service.


** Now, I want another reference to a Service (TestService in the picture)
that was registered by another different bundle. But this is a OSGi bundle,
without SCA information, Composite file nor ComponentType file. I mean it is
a bundle that is registering a service in the OSGi registry. I need have a
instance wired to this OSGi service in the class of the main Component in
order to invoke their methods.


TestService testService;


//I need testService is not null in order to invoke their methods.
testService.sayHello();




I hope you can understand my problem. You can ask me if you want.


Thank you very mucha

















2009/6/10 Raymond Feng <en...@gmail.com>

Please see:

https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator/
https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator-operations/

http://cwiki.apache.org/confluence/display/TUSCANYWIKI/OSGi+RFC+119+Implementation

Thanks,
Raymond


From: Santiago Miguel Aranda Rojas
Sent: Wednesday, June 10, 2009 12:07 AM
To: user@tuscany.apache.org
Subject: Re: Problem with "implementation.osgi" reference


Yes, you are right. I was doing some different tests and I copied you a
wrong composite. I wanted to see if the change of @target made an error in
tuscany.  But Tuscany doesn4t recognize this error because I think it
supposes that will be a "remote Component". I can see this in the tuscany
trace


ADVERTENCIA: Component reference target not found, it might be a remote
service running elsewhere in the SCA Domain: Composite =
{http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement}SensorNetworkManagement
Service = PruebaComponent



But it is Ok, because the component I want if an Osgi Service registered in
the Osgi registry.
I have fixed the error in @target and it is not working yet.


Do you know any example when an <implementation.osgi> component is used?




I have tried to change  "xmlns" tag, but it doesn4t work.


 <sca:component name="PruebaComponent">
       <sca:implementation.osgi
xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
            bundleSymbolicName="RegistroService"
            bundleVersion="1.0.0">
           <sca:properties service="prueba.PruebaImpl">
           </sca:properties>
       </sca:implementation.osgi>
     </sca:component>


Thank you very much.



2009/6/10 Raymond Feng <en...@gmail.com>

The @target is pointing to a wrong componentName/serviceName. It should be
"Prueba" instead of "PruebaComponent" as the component name is "Prueba".


From: Santiago Miguel Aranda Rojas
Sent: Tuesday, June 09, 2009 1:28 PM
To: user@tuscany.apache.org
Subject: Re: Problem with "implementation.osgi" reference


Tuscany 2.02M. The last version I think. April 2009
----- Original Message ----- 
From: Raymond Feng
To: user@tuscany.apache.org
Sent: Tuesday, June 09, 2009 7:12 PM
Subject: Re: Problem with "implementation.osgi" reference


Are you using Tuscany/SCA 2.x or 1.x?


From: santiago.aranda@telvent.com
Sent: Tuesday, June 09, 2009 9:15 AM
To: user@tuscany.apache.org
Subject: Problem with "implementation.osgi" reference



Hello

I want to use an osgi service as a SCA component. But I can not access to
their methods from other Component.  I mean I have created a wired instance
to the Osgi Service ($Proxy25). It is not "null" but I can not invoke to one
method because an error is happening

--->Unable to create SCA binding invoker for local target
SensorNetworkManagementComponent reference prueba (bindingURI=null
operation=sayHello)

This is my composite file. I want to have to two components. The first had a
reference to the second and it is normal "implementation.java". The second
is the SCA component that is representing to the Osgi Service that I want to
recover. This Osgi Service was registered in the Osgi registry by Activator
class in "RegistroService" bundle.

<sca:component name="SensorNetworkManagementComponent">
   <sca:implementation.java
class="es.amivital.sensornetworkmanagement.sca.SensorNetworkManagementServiceImpl"/>
   <sca:service name="SensorNetworkManagementService">
    <sca:binding.ws
uri="http://localhost:8085/SensorNetworkManagementComponent"/>
  </sca:service>
 <sca:reference name="prueba" target="PruebaComponent"/>
 </sca:component>


 <sca:component name="Prueba">
       <sca:implementation.osgi
xmlns="http://tuscany.apache.org/xmlns/sca/1.0"
            bundleSymbolicName="RegistroService"
            bundleVersion="1.0.0">
           <sca:properties service="prueba.PruebaImpl">
           </sca:properties>
       </sca:implementation.osgi>
</sca:component>

***The Java code--> The first component.

public class SensorNetworkManagementServiceImpl  implements
SensorNetworkManagementService {
private Prueba prueba;
public Prueba getPrueba() {
return prueba;
}
@Reference
public void setPrueba(Prueba prueba) {
this.prueba = prueba;
}
}

**Java code       --> The second component. It is another bundle that is
registering one simple Osgi Service. The interface was

public interface Prueba {
public abstract String sayHello();

}





This instance (prueba) is not null when an outside client invoke to the
first component. But if I invoke to one method of this interface, for
example "prueba.sayHello" I obtained the previous error.

I have read something about anottations like @AllowsPassByReference or
@Scope, but I don4t know if they are neccesary . 


Re: Fwd: Problem with "implementation.osgi" reference

Posted by sa...@telvent.com.
So, I have to attach two files (componentType and composite) to my two 
different bundles (TestService and Calculator) and model it as 
"implementation.osgi".   I have TestService in a bundle I will add these 
two file and I will design as "implementation.osgi" .

But Calculator Service (this is in other bundle) has three components and 
they are all "implementation.java" and it is working OK. How can I put a 
reference to TestService?? Do I need change "implementation.osgi" in 
CalculatorComponent instead "implementation.java"? and is it neccesary for 
AddServiceComponent and SubstractService??

I will try a example I will copy my files in the email.

Thank you very much

Un saludo.
Santiago Miguel Aranda Rojas
Telvent Interactiva 
Extension: 35999
Telefono: 955637418


"Raymond Feng" <en...@gmail.com>
"Raymond Feng"
15/06/2009 18:36

Para:
<us...@tuscany.apache.org>, <sa...@telvent.com>
cc:

Asunto:
Re: Fwd: Problem with "implementation.osgi" reference



To access an OSGi service from the SCA component, you will have to provide 

SCA configurations for the OSGi bundle so that it becomes an SCA component 

using implementation.osgi and the OSGi service becomes an SCA service so 
that the Calculator component can wire to that TestService.

There are two SCA files you to provide to model the OSGi bundle as an SCA 
component.
* bundle.componentType to describe what OSGi services or references are 
used 
in the bundle (We potentially have better approach to introspect the OSGi 
bundle to build this up)
* bundle.composite to configure the component, for example, setting the 
bindings.

These files can be in a separate OSGi bundle than the one that owns the 
services/references.

Thanks,
Raymond

From: Santiago Miguel Aranda Rojas
Sent: Monday, June 15, 2009 4:01 AM
To: user@tuscany.apache.org
Subject: Fwd: Problem with "implementation.osgi" reference






Hi


I can not understand this sample because there are many new concepts for 
me. 
For example "bundle.componentType". There is not too much information 
about 
that . I think I need something more simple. I have attached a picture 
with 
my idea.


** When my SCA service was working I had a main component 
"implementacion.java" with two references to another two components 
(implementation.java). The main component could be invoked as Web Service.


** Now, I want another reference to a Service (TestService in the picture) 

that was registered by another different bundle. But this is a OSGi 
bundle, 
without SCA information, Composite file nor ComponentType file. I mean it 
is 
a bundle that is registering a service in the OSGi registry. I need have a 

instance wired to this OSGi service in the class of the main Component in 
order to invoke their methods.


TestService testService;


//I need testService is not null in order to invoke their methods.
testService.sayHello();




I hope you can understand my problem. You can ask me if you want.


Thank you very mucha

















2009/6/10 Raymond Feng <en...@gmail.com>

Please see:

https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator/

https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator-operations/


http://cwiki.apache.org/confluence/display/TUSCANYWIKI/OSGi+RFC+119+Implementation


Thanks,
Raymond


From: Santiago Miguel Aranda Rojas
Sent: Wednesday, June 10, 2009 12:07 AM
To: user@tuscany.apache.org
Subject: Re: Problem with "implementation.osgi" reference


Yes, you are right. I was doing some different tests and I copied you a 
wrong composite. I wanted to see if the change of @target made an error in 

tuscany.  But Tuscany doesn4t recognize this error because I think it 
supposes that will be a "remote Component". I can see this in the tuscany 
trace


ADVERTENCIA: Component reference target not found, it might be a remote 
service running elsewhere in the SCA Domain: Composite = 
{http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement}SensorNetworkManagement 

Service = PruebaComponent



But it is Ok, because the component I want if an Osgi Service registered 
in 
the Osgi registry.
I have fixed the error in @target and it is not working yet.


Do you know any example when an <implementation.osgi> component is used?




I have tried to change  "xmlns" tag, but it doesn4t work.


  <sca:component name="PruebaComponent">
        <sca:implementation.osgi 
xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
             bundleSymbolicName="RegistroService"
             bundleVersion="1.0.0">
            <sca:properties service="prueba.PruebaImpl">
            </sca:properties>
        </sca:implementation.osgi>
      </sca:component>


Thank you very much.



2009/6/10 Raymond Feng <en...@gmail.com>

The @target is pointing to a wrong componentName/serviceName. It should be 

"Prueba" instead of "PruebaComponent" as the component name is "Prueba".


From: Santiago Miguel Aranda Rojas
Sent: Tuesday, June 09, 2009 1:28 PM
To: user@tuscany.apache.org
Subject: Re: Problem with "implementation.osgi" reference


Tuscany 2.02M. The last version I think. April 2009
----- Original Message ----- 
From: Raymond Feng
To: user@tuscany.apache.org
Sent: Tuesday, June 09, 2009 7:12 PM
Subject: Re: Problem with "implementation.osgi" reference


Are you using Tuscany/SCA 2.x or 1.x?


From: santiago.aranda@telvent.com
Sent: Tuesday, June 09, 2009 9:15 AM
To: user@tuscany.apache.org
Subject: Problem with "implementation.osgi" reference



Hello

I want to use an osgi service as a SCA component. But I can not access to 
their methods from other Component.  I mean I have created a wired 
instance 
to the Osgi Service ($Proxy25). It is not "null" but I can not invoke to 
one 
method because an error is happening

--->Unable to create SCA binding invoker for local target 
SensorNetworkManagementComponent reference prueba (bindingURI=null 
operation=sayHello)

This is my composite file. I want to have to two components. The first had 
a 
reference to the second and it is normal "implementation.java". The second 

is the SCA component that is representing to the Osgi Service that I want 
to 
recover. This Osgi Service was registered in the Osgi registry by 
Activator 
class in "RegistroService" bundle.

 <sca:component name="SensorNetworkManagementComponent">
    <sca:implementation.java 
class="es.amivital.sensornetworkmanagement.sca.SensorNetworkManagementServiceImpl"/>
    <sca:service name="SensorNetworkManagementService">
     <sca:binding.ws 
uri="http://localhost:8085/SensorNetworkManagementComponent"/>
   </sca:service>
  <sca:reference name="prueba" target="PruebaComponent"/>
  </sca:component>


  <sca:component name="Prueba">
        <sca:implementation.osgi 
xmlns="http://tuscany.apache.org/xmlns/sca/1.0"
             bundleSymbolicName="RegistroService"
             bundleVersion="1.0.0">
            <sca:properties service="prueba.PruebaImpl">
            </sca:properties>
        </sca:implementation.osgi>
</sca:component>

***The Java code--> The first component.

public class SensorNetworkManagementServiceImpl  implements 
SensorNetworkManagementService {
private Prueba prueba;
public Prueba getPrueba() {
return prueba;
}
@Reference
public void setPrueba(Prueba prueba) {
this.prueba = prueba;
}
}

**Java code       --> The second component. It is another bundle that is 
registering one simple Osgi Service. The interface was

public interface Prueba {
public abstract String sayHello();

}





This instance (prueba) is not null when an outside client invoke to the 
first component. But if I invoke to one method of this interface, for 
example "prueba.sayHello" I obtained the previous error.

I have read something about anottations like @AllowsPassByReference or 
@Scope, but I don4t know if they are neccesary . 



Re: Fwd: Problem with "implementation.osgi" reference

Posted by Raymond Feng <en...@gmail.com>.
To access an OSGi service from the SCA component, you will have to provide 
SCA configurations for the OSGi bundle so that it becomes an SCA component 
using implementation.osgi and the OSGi service becomes an SCA service so 
that the Calculator component can wire to that TestService.

There are two SCA files you to provide to model the OSGi bundle as an SCA 
component.
* bundle.componentType to describe what OSGi services or references are used 
in the bundle (We potentially have better approach to introspect the OSGi 
bundle to build this up)
* bundle.composite to configure the component, for example, setting the 
bindings.

These files can be in a separate OSGi bundle than the one that owns the 
services/references.

Thanks,
Raymond

From: Santiago Miguel Aranda Rojas
Sent: Monday, June 15, 2009 4:01 AM
To: user@tuscany.apache.org
Subject: Fwd: Problem with "implementation.osgi" reference






Hi


I can not understand this sample because there are many new concepts for me. 
For example "bundle.componentType". There is not too much information about 
that . I think I need something more simple. I have attached a picture with 
my idea.


** When my SCA service was working I had a main component 
"implementacion.java" with two references to another two components 
(implementation.java). The main component could be invoked as Web Service.


** Now, I want another reference to a Service (TestService in the picture) 
that was registered by another different bundle. But this is a OSGi bundle, 
without SCA information, Composite file nor ComponentType file. I mean it is 
a bundle that is registering a service in the OSGi registry. I need have a 
instance wired to this OSGi service in the class of the main Component in 
order to invoke their methods.


TestService testService;


//I need testService is not null in order to invoke their methods.
testService.sayHello();




I hope you can understand my problem. You can ask me if you want.


Thank you very mucha

















2009/6/10 Raymond Feng <en...@gmail.com>

Please see:

https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator/
https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator-operations/

http://cwiki.apache.org/confluence/display/TUSCANYWIKI/OSGi+RFC+119+Implementation

Thanks,
Raymond


From: Santiago Miguel Aranda Rojas
Sent: Wednesday, June 10, 2009 12:07 AM
To: user@tuscany.apache.org
Subject: Re: Problem with "implementation.osgi" reference


Yes, you are right. I was doing some different tests and I copied you a 
wrong composite. I wanted to see if the change of @target made an error in 
tuscany.  But Tuscany doesn´t recognize this error because I think it 
supposes that will be a "remote Component". I can see this in the tuscany 
trace


ADVERTENCIA: Component reference target not found, it might be a remote 
service running elsewhere in the SCA Domain: Composite = 
{http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement}SensorNetworkManagement 
Service = PruebaComponent



But it is Ok, because the component I want if an Osgi Service registered in 
the Osgi registry.
I have fixed the error in @target and it is not working yet.


Do you know any example when an <implementation.osgi> component is used?




I have tried to change  "xmlns" tag, but it doesn´t work.


  <sca:component name="PruebaComponent">
        <sca:implementation.osgi 
xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
             bundleSymbolicName="RegistroService"
             bundleVersion="1.0.0">
            <sca:properties service="prueba.PruebaImpl">
            </sca:properties>
        </sca:implementation.osgi>
      </sca:component>


Thank you very much.



2009/6/10 Raymond Feng <en...@gmail.com>

The @target is pointing to a wrong componentName/serviceName. It should be 
"Prueba" instead of "PruebaComponent" as the component name is "Prueba".


From: Santiago Miguel Aranda Rojas
Sent: Tuesday, June 09, 2009 1:28 PM
To: user@tuscany.apache.org
Subject: Re: Problem with "implementation.osgi" reference


Tuscany 2.02M. The last version I think. April 2009
----- Original Message ----- 
From: Raymond Feng
To: user@tuscany.apache.org
Sent: Tuesday, June 09, 2009 7:12 PM
Subject: Re: Problem with "implementation.osgi" reference


Are you using Tuscany/SCA 2.x or 1.x?


From: santiago.aranda@telvent.com
Sent: Tuesday, June 09, 2009 9:15 AM
To: user@tuscany.apache.org
Subject: Problem with "implementation.osgi" reference



Hello

I want to use an osgi service as a SCA component. But I can not access to 
their methods from other Component.  I mean I have created a wired instance 
to the Osgi Service ($Proxy25). It is not "null" but I can not invoke to one 
method because an error is happening

--->Unable to create SCA binding invoker for local target 
SensorNetworkManagementComponent reference prueba (bindingURI=null 
operation=sayHello)

This is my composite file. I want to have to two components. The first had a 
reference to the second and it is normal "implementation.java". The second 
is the SCA component that is representing to the Osgi Service that I want to 
recover. This Osgi Service was registered in the Osgi registry by Activator 
class in "RegistroService" bundle.

 <sca:component name="SensorNetworkManagementComponent">
    <sca:implementation.java 
class="es.amivital.sensornetworkmanagement.sca.SensorNetworkManagementServiceImpl"/>
    <sca:service name="SensorNetworkManagementService">
     <sca:binding.ws 
uri="http://localhost:8085/SensorNetworkManagementComponent"/>
   </sca:service>
  <sca:reference name="prueba" target="PruebaComponent"/>
  </sca:component>


  <sca:component name="Prueba">
        <sca:implementation.osgi 
xmlns="http://tuscany.apache.org/xmlns/sca/1.0"
             bundleSymbolicName="RegistroService"
             bundleVersion="1.0.0">
            <sca:properties service="prueba.PruebaImpl">
            </sca:properties>
        </sca:implementation.osgi>
</sca:component>

***The Java code--> The first component.

public class SensorNetworkManagementServiceImpl  implements 
SensorNetworkManagementService {
private Prueba prueba;
public Prueba getPrueba() {
return prueba;
}
@Reference
public void setPrueba(Prueba prueba) {
this.prueba = prueba;
}
}

**Java code       --> The second component. It is another bundle that is 
registering one simple Osgi Service. The interface was

public interface Prueba {
public abstract String sayHello();

}





This instance (prueba) is not null when an outside client invoke to the 
first component. But if I invoke to one method of this interface, for 
example "prueba.sayHello" I obtained the previous error.

I have read something about anottations like @AllowsPassByReference or 
@Scope, but I don´t know if they are neccesary . 


Fwd: Problem with "implementation.osgi" reference

Posted by Santiago Miguel Aranda Rojas <sa...@gmail.com>.
Hi

I can not understand this sample because there are many new concepts for me.
For example "bundle.componentType". There is not too much information about
that . I think I need something more simple. I have attached a picture with
my idea.

** When my SCA service was working I had a main component
"implementacion.java" with two references to another two components
(implementation.java). The main component could be invoked as Web Service.

** Now, I want another reference to a Service (TestService in the picture)
that was registered by another different bundle. But this is a OSGi bundle,
without SCA information, Composite file nor ComponentType file. I mean it is
a bundle that is registering a service in the OSGi registry. I need have a
instance wired to this OSGi service in the class of the main Component in
order to invoke their methods.

TestService testService;

//I need testService is not null in order to invoke their methods.
testService.sayHello();


I hope you can understand my problem. You can ask me if you want.

Thank you very mucha









2009/6/10 Raymond Feng <en...@gmail.com>

>  Please see:
>
> https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator/
>
> https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator-operations/
>
>
> http://cwiki.apache.org/confluence/display/TUSCANYWIKI/OSGi+RFC+119+Implementation
>
> Thanks,
> Raymond
>
>  *From:* Santiago Miguel Aranda Rojas <sa...@gmail.com>
> *Sent:* Wednesday, June 10, 2009 12:07 AM
> *To:* user@tuscany.apache.org
> *Subject:* Re: Problem with "implementation.osgi" reference
>
> Yes, you are right. I was doing some different tests and I copied you a
> wrong composite. I wanted to see if the change of @target made an error in
> tuscany.  But Tuscany doesn´t recognize this error because I think it
> supposes that will be a "remote Component". I can see this in the tuscany
> trace
>
> ADVERTENCIA: Component reference target not found, it might be a remote
> service running elsewhere in the SCA Domain: Composite = {
> http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement}SensorNetworkManagement<http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement%7DSensorNetworkManagement>Service = PruebaComponent
>
> But it is Ok, because the component I want if an Osgi Service registered in
> the Osgi registry.
> I have fixed the error in @target and it is not working yet.
>
> Do you know any example when an <implementation.osgi> component is used?
>
>
> I have tried to change  "xmlns" tag, but it doesn´t work.
>
>    <sca:component name="PruebaComponent">
>         <sca:implementation.osgi xmlns="
> http://docs.oasis-open.org/ns/opencsa/sca/200903"
>              bundleSymbolicName="RegistroService"
>              bundleVersion="1.0.0">
>             <sca:properties service="prueba.PruebaImpl">
>             </sca:properties>
>         </sca:implementation.osgi>
>       </sca:component>
>
> Thank you very much.
>
>
> 2009/6/10 Raymond Feng <en...@gmail.com>
>
>>  The @target is pointing to a wrong componentName/serviceName. It should
>> be "Prueba" instead of "PruebaComponent" as the component name is "Prueba".
>>
>>  *From:* Santiago Miguel Aranda Rojas <sa...@gmail.com>
>> *Sent:* Tuesday, June 09, 2009 1:28 PM
>>  *To:* user@tuscany.apache.org
>>   *Subject:* Re: Problem with "implementation.osgi" reference
>>
>> Tuscany 2.02M. The last version I think. April 2009
>>
>> ----- Original Message -----
>> *From:* Raymond Feng <en...@gmail.com>
>> *To:* user@tuscany.apache.org
>> *Sent:* Tuesday, June 09, 2009 7:12 PM
>> *Subject:* Re: Problem with "implementation.osgi" reference
>>
>> Are you using Tuscany/SCA 2.x or 1.x?
>>
>>  *From:* santiago.aranda@telvent.com
>> *Sent:* Tuesday, June 09, 2009 9:15 AM
>> *To:* user@tuscany.apache.org
>> *Subject:* Problem with "implementation.osgi" reference
>>
>>
>> Hello
>>
>> I want to use an osgi service as a SCA component. But I can not access to
>> their methods from other Component.  I mean I have created a wired instance
>> to the Osgi Service ($Proxy25). It is not "null" but I can not invoke to one
>> method because an error is happening
>>
>> --->Unable to create SCA binding invoker for local target
>> SensorNetworkManagementComponent reference prueba (bindingURI=null
>> operation=sayHello)
>>
>> This is my composite file. I want to have to two components. The first had
>> a reference to the second and it is normal "implementation.java". The second
>> is the SCA component that is representing to the Osgi Service that I want to
>> recover. This Osgi Service was registered in the Osgi registry by Activator
>> class in "RegistroService" bundle.
>>
>>  <sca:component name="SensorNetworkManagementComponent">
>>     <sca:implementation.java
>> class="es.amivital.sensornetworkmanagement.sca.SensorNetworkManagementServiceImpl"/>
>>     <sca:service name="SensorNetworkManagementService">
>>      <sca:*binding.ws* <http://binding.ws/> uri="*
>> http://localhost:8085/SensorNetworkManagementComponent*<http://localhost:8085/SensorNetworkManagementComponent>
>> "/>
>>    </sca:service>
>>   <sca:reference name="prueba" target="PruebaComponent"/>
>>   </sca:component>
>>
>>
>>   <sca:component name="Prueba">
>>         <sca:implementation.osgi xmlns="*
>> http://tuscany.apache.org/xmlns/sca/1.0*<http://tuscany.apache.org/xmlns/sca/1.0>
>> "
>>              bundleSymbolicName="RegistroService"
>>              bundleVersion="1.0.0">
>>             <sca:properties service="prueba.PruebaImpl">
>>             </sca:properties>
>>         </sca:implementation.osgi>
>> </sca:component>
>>
>> ***The Java code--> The first component.
>>
>> public class SensorNetworkManagementServiceImpl  implements
>> SensorNetworkManagementService {
>> private Prueba prueba;
>> public Prueba getPrueba() {
>> return prueba;
>> }
>> @Reference
>> public void setPrueba(Prueba prueba) {
>> this.prueba = prueba;
>> }
>> }
>>
>> **Java code       --> The second component. It is another bundle that is
>> registering one simple Osgi Service. The interface was
>>
>> public interface Prueba {
>> public abstract String sayHello();
>>
>> }
>>
>>
>>
>>
>>
>> This instance (prueba) is not null when an outside client invoke to the
>> first component. But if I invoke to one method of this interface, for
>> example "prueba.sayHello" I obtained the previous error.
>>
>> I have read something about anottations like @AllowsPassByReference
>> or @Scope, but I don´t know if they are neccesary .
>>
>>
>

Re: Problem with "implementation.osgi" reference

Posted by Raymond Feng <en...@gmail.com>.
Please see:

https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator/
https://svn.apache.org/repos/asf/tuscany/java/sca/samples/dosgi-calculator-operations/

http://cwiki.apache.org/confluence/display/TUSCANYWIKI/OSGi+RFC+119+Implementation

Thanks,
Raymond


From: Santiago Miguel Aranda Rojas 
Sent: Wednesday, June 10, 2009 12:07 AM
To: user@tuscany.apache.org 
Subject: Re: Problem with "implementation.osgi" reference


Yes, you are right. I was doing some different tests and I copied you a wrong composite. I wanted to see if the change of @target made an error in tuscany.  But Tuscany doesn´t recognize this error because I think it supposes that will be a "remote Component". I can see this in the tuscany trace


ADVERTENCIA: Component reference target not found, it might be a remote service running elsewhere in the SCA Domain: Composite = {http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement}SensorNetworkManagement Service = PruebaComponent



But it is Ok, because the component I want if an Osgi Service registered in the Osgi registry.
I have fixed the error in @target and it is not working yet.


Do you know any example when an <implementation.osgi> component is used?




I have tried to change  "xmlns" tag, but it doesn´t work.


  <sca:component name="PruebaComponent">
        <sca:implementation.osgi xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
             bundleSymbolicName="RegistroService"                         
             bundleVersion="1.0.0">
            <sca:properties service="prueba.PruebaImpl">                
            </sca:properties>
        </sca:implementation.osgi>
      </sca:component>


Thank you very much.



2009/6/10 Raymond Feng <en...@gmail.com>

  The @target is pointing to a wrong componentName/serviceName. It should be "Prueba" instead of "PruebaComponent" as the component name is "Prueba".


  From: Santiago Miguel Aranda Rojas 
  Sent: Tuesday, June 09, 2009 1:28 PM
  To: user@tuscany.apache.org 
  Subject: Re: Problem with "implementation.osgi" reference


  Tuscany 2.02M. The last version I think. April 2009
    ----- Original Message ----- 
    From: Raymond Feng 
    To: user@tuscany.apache.org 
    Sent: Tuesday, June 09, 2009 7:12 PM
    Subject: Re: Problem with "implementation.osgi" reference


    Are you using Tuscany/SCA 2.x or 1.x?


    From: santiago.aranda@telvent.com 
    Sent: Tuesday, June 09, 2009 9:15 AM
    To: user@tuscany.apache.org 
    Subject: Problem with "implementation.osgi" reference



    Hello 

    I want to use an osgi service as a SCA component. But I can not access to their methods from other Component.  I mean I have created a wired instance to the Osgi Service ($Proxy25). It is not "null" but I can not invoke to one method because an error is happening  

    --->Unable to create SCA binding invoker for local target SensorNetworkManagementComponent reference prueba (bindingURI=null operation=sayHello) 

    This is my composite file. I want to have to two components. The first had a reference to the second and it is normal "implementation.java". The second is the SCA component that is representing to the Osgi Service that I want to recover. This Osgi Service was registered in the Osgi registry by Activator class in "RegistroService" bundle. 

     <sca:component name="SensorNetworkManagementComponent"> 
        <sca:implementation.java class="es.amivital.sensornetworkmanagement.sca.SensorNetworkManagementServiceImpl"/> 
        <sca:service name="SensorNetworkManagementService">       
         <sca:binding.ws uri="http://localhost:8085/SensorNetworkManagementComponent"/> 
       </sca:service> 
      <sca:reference name="prueba" target="PruebaComponent"/> 
      </sca:component> 


      <sca:component name="Prueba"> 
            <sca:implementation.osgi xmlns="http://tuscany.apache.org/xmlns/sca/1.0" 
                 bundleSymbolicName="RegistroService"                          
                 bundleVersion="1.0.0"> 
                <sca:properties service="prueba.PruebaImpl">                 
                </sca:properties> 
            </sca:implementation.osgi> 
    </sca:component> 

    ***The Java code--> The first component. 

    public class SensorNetworkManagementServiceImpl  implements SensorNetworkManagementService { 
    private Prueba prueba; 
    public Prueba getPrueba() { 
    return prueba; 
    } 
    @Reference 
    public void setPrueba(Prueba prueba) { 
    this.prueba = prueba; 
    } 
    } 

    **Java code       --> The second component. It is another bundle that is registering one simple Osgi Service. The interface was 

    public interface Prueba { 
    public abstract String sayHello(); 

    } 





    This instance (prueba) is not null when an outside client invoke to the first component. But if I invoke to one method of this interface, for example "prueba.sayHello" I obtained the previous error. 

    I have read something about anottations like @AllowsPassByReference or @Scope, but I don´t know if they are neccesary . 


Re: Problem with "implementation.osgi" reference

Posted by Santiago Miguel Aranda Rojas <sa...@gmail.com>.
Yes, you are right. I was doing some different tests and I copied you a
wrong composite. I wanted to see if the change of @target made an error in
tuscany.  But Tuscany doesn´t recognize this error because I think it
supposes that will be a "remote Component". I can see this in the tuscany
trace

ADVERTENCIA: Component reference target not found, it might be a remote
service running elsewhere in the SCA Domain: Composite = {
http://eclipse.org/SensorNetworkManagement/src/main/resources/SensorNetworkManagement}SensorNetworkManagementService
= PruebaComponent

But it is Ok, because the component I want if an Osgi Service registered in
the Osgi registry.
I have fixed the error in @target and it is not working yet.

Do you know any example when an <implementation.osgi> component is used?


I have tried to change  "xmlns" tag, but it doesn´t work.

  <sca:component name="PruebaComponent">
        <sca:implementation.osgi xmlns="
http://docs.oasis-open.org/ns/opencsa/sca/200903"
             bundleSymbolicName="RegistroService"
             bundleVersion="1.0.0">
            <sca:properties service="prueba.PruebaImpl">
            </sca:properties>
        </sca:implementation.osgi>
      </sca:component>

Thank you very much.


2009/6/10 Raymond Feng <en...@gmail.com>

>  The @target is pointing to a wrong componentName/serviceName. It should
> be "Prueba" instead of "PruebaComponent" as the component name is "Prueba".
>
>  *From:* Santiago Miguel Aranda Rojas <sa...@gmail.com>
> *Sent:* Tuesday, June 09, 2009 1:28 PM
> *To:* user@tuscany.apache.org
> *Subject:* Re: Problem with "implementation.osgi" reference
>
> Tuscany 2.02M. The last version I think. April 2009
>
> ----- Original Message -----
> *From:* Raymond Feng <en...@gmail.com>
> *To:* user@tuscany.apache.org
> *Sent:* Tuesday, June 09, 2009 7:12 PM
> *Subject:* Re: Problem with "implementation.osgi" reference
>
> Are you using Tuscany/SCA 2.x or 1.x?
>
>  *From:* santiago.aranda@telvent.com
> *Sent:* Tuesday, June 09, 2009 9:15 AM
> *To:* user@tuscany.apache.org
> *Subject:* Problem with "implementation.osgi" reference
>
>
> Hello
>
> I want to use an osgi service as a SCA component. But I can not access to
> their methods from other Component.  I mean I have created a wired instance
> to the Osgi Service ($Proxy25). It is not "null" but I can not invoke to one
> method because an error is happening
>
> --->Unable to create SCA binding invoker for local target
> SensorNetworkManagementComponent reference prueba (bindingURI=null
> operation=sayHello)
>
> This is my composite file. I want to have to two components. The first had
> a reference to the second and it is normal "implementation.java". The second
> is the SCA component that is representing to the Osgi Service that I want to
> recover. This Osgi Service was registered in the Osgi registry by Activator
> class in "RegistroService" bundle.
>
>  <sca:component name="SensorNetworkManagementComponent">
>     <sca:implementation.java
> class="es.amivital.sensornetworkmanagement.sca.SensorNetworkManagementServiceImpl"/>
>     <sca:service name="SensorNetworkManagementService">
>      <sca:*binding.ws* <http://binding.ws/> uri="*
> http://localhost:8085/SensorNetworkManagementComponent*<http://localhost:8085/SensorNetworkManagementComponent>
> "/>
>    </sca:service>
>   <sca:reference name="prueba" target="PruebaComponent"/>
>   </sca:component>
>
>
>   <sca:component name="Prueba">
>         <sca:implementation.osgi xmlns="*
> http://tuscany.apache.org/xmlns/sca/1.0*<http://tuscany.apache.org/xmlns/sca/1.0>
> "
>              bundleSymbolicName="RegistroService"
>              bundleVersion="1.0.0">
>             <sca:properties service="prueba.PruebaImpl">
>             </sca:properties>
>         </sca:implementation.osgi>
> </sca:component>
>
> ***The Java code--> The first component.
>
> public class SensorNetworkManagementServiceImpl  implements
> SensorNetworkManagementService {
> private Prueba prueba;
> public Prueba getPrueba() {
> return prueba;
> }
> @Reference
> public void setPrueba(Prueba prueba) {
> this.prueba = prueba;
> }
> }
>
> **Java code       --> The second component. It is another bundle that is
> registering one simple Osgi Service. The interface was
>
> public interface Prueba {
> public abstract String sayHello();
>
> }
>
>
>
>
>
> This instance (prueba) is not null when an outside client invoke to the
> first component. But if I invoke to one method of this interface, for
> example "prueba.sayHello" I obtained the previous error.
>
> I have read something about anottations like @AllowsPassByReference
> or @Scope, but I don´t know if they are neccesary .
>
>

Re: Problem with "implementation.osgi" reference

Posted by Raymond Feng <en...@gmail.com>.
The @target is pointing to a wrong componentName/serviceName. It should be "Prueba" instead of "PruebaComponent" as the component name is "Prueba".


From: Santiago Miguel Aranda Rojas 
Sent: Tuesday, June 09, 2009 1:28 PM
To: user@tuscany.apache.org 
Subject: Re: Problem with "implementation.osgi" reference


Tuscany 2.02M. The last version I think. April 2009
  ----- Original Message ----- 
  From: Raymond Feng 
  To: user@tuscany.apache.org 
  Sent: Tuesday, June 09, 2009 7:12 PM
  Subject: Re: Problem with "implementation.osgi" reference


  Are you using Tuscany/SCA 2.x or 1.x?


  From: santiago.aranda@telvent.com 
  Sent: Tuesday, June 09, 2009 9:15 AM
  To: user@tuscany.apache.org 
  Subject: Problem with "implementation.osgi" reference



  Hello 

  I want to use an osgi service as a SCA component. But I can not access to their methods from other Component.  I mean I have created a wired instance to the Osgi Service ($Proxy25). It is not "null" but I can not invoke to one method because an error is happening  

  --->Unable to create SCA binding invoker for local target SensorNetworkManagementComponent reference prueba (bindingURI=null operation=sayHello) 

  This is my composite file. I want to have to two components. The first had a reference to the second and it is normal "implementation.java". The second is the SCA component that is representing to the Osgi Service that I want to recover. This Osgi Service was registered in the Osgi registry by Activator class in "RegistroService" bundle. 

   <sca:component name="SensorNetworkManagementComponent"> 
      <sca:implementation.java class="es.amivital.sensornetworkmanagement.sca.SensorNetworkManagementServiceImpl"/> 
      <sca:service name="SensorNetworkManagementService">       
       <sca:binding.ws uri="http://localhost:8085/SensorNetworkManagementComponent"/> 
     </sca:service> 
    <sca:reference name="prueba" target="PruebaComponent"/> 
    </sca:component> 


    <sca:component name="Prueba"> 
          <sca:implementation.osgi xmlns="http://tuscany.apache.org/xmlns/sca/1.0" 
               bundleSymbolicName="RegistroService"                          
               bundleVersion="1.0.0"> 
              <sca:properties service="prueba.PruebaImpl">                 
              </sca:properties> 
          </sca:implementation.osgi> 
  </sca:component> 

  ***The Java code--> The first component. 

  public class SensorNetworkManagementServiceImpl  implements SensorNetworkManagementService { 
  private Prueba prueba; 
  public Prueba getPrueba() { 
  return prueba; 
  } 
  @Reference 
  public void setPrueba(Prueba prueba) { 
  this.prueba = prueba; 
  } 
  } 

  **Java code       --> The second component. It is another bundle that is registering one simple Osgi Service. The interface was 

  public interface Prueba { 
  public abstract String sayHello(); 

  } 





  This instance (prueba) is not null when an outside client invoke to the first component. But if I invoke to one method of this interface, for example "prueba.sayHello" I obtained the previous error. 

  I have read something about anottations like @AllowsPassByReference or @Scope, but I don´t know if they are neccesary . 

Re: Problem with "implementation.osgi" reference

Posted by Santiago Miguel Aranda Rojas <sa...@gmail.com>.
Tuscany 2.02M. The last version I think. April 2009
  ----- Original Message ----- 
  From: Raymond Feng 
  To: user@tuscany.apache.org 
  Sent: Tuesday, June 09, 2009 7:12 PM
  Subject: Re: Problem with "implementation.osgi" reference


  Are you using Tuscany/SCA 2.x or 1.x?


  From: santiago.aranda@telvent.com 
  Sent: Tuesday, June 09, 2009 9:15 AM
  To: user@tuscany.apache.org 
  Subject: Problem with "implementation.osgi" reference



  Hello 

  I want to use an osgi service as a SCA component. But I can not access to their methods from other Component.  I mean I have created a wired instance to the Osgi Service ($Proxy25). It is not "null" but I can not invoke to one method because an error is happening  

  --->Unable to create SCA binding invoker for local target SensorNetworkManagementComponent reference prueba (bindingURI=null operation=sayHello) 

  This is my composite file. I want to have to two components. The first had a reference to the second and it is normal "implementation.java". The second is the SCA component that is representing to the Osgi Service that I want to recover. This Osgi Service was registered in the Osgi registry by Activator class in "RegistroService" bundle. 

   <sca:component name="SensorNetworkManagementComponent"> 
      <sca:implementation.java class="es.amivital.sensornetworkmanagement.sca.SensorNetworkManagementServiceImpl"/> 
      <sca:service name="SensorNetworkManagementService">       
       <sca:binding.ws uri="http://localhost:8085/SensorNetworkManagementComponent"/> 
     </sca:service> 
    <sca:reference name="prueba" target="PruebaComponent"/> 
    </sca:component> 


    <sca:component name="Prueba"> 
          <sca:implementation.osgi xmlns="http://tuscany.apache.org/xmlns/sca/1.0" 
               bundleSymbolicName="RegistroService"                          
               bundleVersion="1.0.0"> 
              <sca:properties service="prueba.PruebaImpl">                 
              </sca:properties> 
          </sca:implementation.osgi> 
  </sca:component> 

  ***The Java code--> The first component. 

  public class SensorNetworkManagementServiceImpl  implements SensorNetworkManagementService { 
  private Prueba prueba; 
  public Prueba getPrueba() { 
  return prueba; 
  } 
  @Reference 
  public void setPrueba(Prueba prueba) { 
  this.prueba = prueba; 
  } 
  } 

  **Java code       --> The second component. It is another bundle that is registering one simple Osgi Service. The interface was 

  public interface Prueba { 
  public abstract String sayHello(); 

  } 





  This instance (prueba) is not null when an outside client invoke to the first component. But if I invoke to one method of this interface, for example "prueba.sayHello" I obtained the previous error. 

  I have read something about anottations like @AllowsPassByReference or @Scope, but I don´t know if they are neccesary . 

Re: Problem with "implementation.osgi" reference

Posted by Raymond Feng <en...@gmail.com>.
Are you using Tuscany/SCA 2.x or 1.x?


From: santiago.aranda@telvent.com 
Sent: Tuesday, June 09, 2009 9:15 AM
To: user@tuscany.apache.org 
Subject: Problem with "implementation.osgi" reference



Hello 

I want to use an osgi service as a SCA component. But I can not access to their methods from other Component.  I mean I have created a wired instance to the Osgi Service ($Proxy25). It is not "null" but I can not invoke to one method because an error is happening  

--->Unable to create SCA binding invoker for local target SensorNetworkManagementComponent reference prueba (bindingURI=null operation=sayHello) 

This is my composite file. I want to have to two components. The first had a reference to the second and it is normal "implementation.java". The second is the SCA component that is representing to the Osgi Service that I want to recover. This Osgi Service was registered in the Osgi registry by Activator class in "RegistroService" bundle. 

 <sca:component name="SensorNetworkManagementComponent"> 
    <sca:implementation.java class="es.amivital.sensornetworkmanagement.sca.SensorNetworkManagementServiceImpl"/> 
    <sca:service name="SensorNetworkManagementService">       
     <sca:binding.ws uri="http://localhost:8085/SensorNetworkManagementComponent"/> 
   </sca:service> 
  <sca:reference name="prueba" target="PruebaComponent"/> 
  </sca:component> 


  <sca:component name="Prueba"> 
        <sca:implementation.osgi xmlns="http://tuscany.apache.org/xmlns/sca/1.0" 
             bundleSymbolicName="RegistroService"                          
             bundleVersion="1.0.0"> 
            <sca:properties service="prueba.PruebaImpl">                 
            </sca:properties> 
        </sca:implementation.osgi> 
</sca:component> 

***The Java code--> The first component. 

public class SensorNetworkManagementServiceImpl  implements SensorNetworkManagementService { 
private Prueba prueba; 
public Prueba getPrueba() { 
return prueba; 
} 
@Reference 
public void setPrueba(Prueba prueba) { 
this.prueba = prueba; 
} 
} 

**Java code       --> The second component. It is another bundle that is registering one simple Osgi Service. The interface was 

public interface Prueba { 
public abstract String sayHello(); 

} 





This instance (prueba) is not null when an outside client invoke to the first component. But if I invoke to one method of this interface, for example "prueba.sayHello" I obtained the previous error. 

I have read something about anottations like @AllowsPassByReference or @Scope, but I don´t know if they are neccesary .