You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by "Millies, Sebastian" <Se...@ids-scheer.com> on 2010/09/27 19:42:34 UTC

Nested composites and the classpath

Hello there,

I'm having a problem with nested composites, that is composites included
as a component implementation in another composite. This seems to work only
when the XML file containing the referenced composite sits in the same
directory as the XML file with the including composite. It is not enough
that the referenced composite is in a file somewhere on the classpath, e. g.
in some jar-file.

I'm using Tuscany 1.6. Has anyone else noticed this? Perhaps it has something 
to do with things on the classpath not being considered part of the contribution 
being loaded. But I'd find that exceedingly strange. 

What I would really like to do is have an Eclipse project for each composite,
export them in jar-files, put those jar files on the class path, and start a
main composite in which I define components with reference to some of those
ready-made parts. I certainly don't want to compile all the projects to
the same location. 

See below for an example.

-- Sebastian

Here's an example:
Main composite (in file ./com/foobaz/main.composite):

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <sca:composite xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" xmlns:logservice-container="http://foobaz.com/logservice-container/" xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0" name="main" targetNamespace="http://foobaz.com/">
 <sca:component name="LogServiceContainer">
    <sca:implementation.composite name="logservice-container:logservice-container"/> <!-- ** here ** -->
    <sca:reference name="LogService">
      <sca:interface.java interface="foobaz.com.LogService"/>
      <sca:binding.jms initialContextFactory="org.apache.activemq.jndi.ActiveMQInitialContextFactory" jndiURL="tcp://localhost:61619" uri="jms:/LoggerComponent/LogService">
        <sca:destination create="ifnotexist" name="LoggingRequestQueue" type="queue"/>
        <tuscany:wireFormat.jmsTextXML/>
      </sca:binding.jms>
    </sca:reference>
  </sca:component>
  </sca:composite>

Included composite, referenced by main composite at marked line above: 

<?xml version="1.0" encoding="UTF-8"?>
<sca:composite xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0" name="logservice-container" targetNamespace="http://foobaz.com/logservice-container/">
  <sca:component name="LogServiceContainer">
    <sca:implementation.java class="foobaz.com.LogServiceContainer"/>
    <sca:reference name="LogService"/>
  </sca:component>
  <sca:reference name="LogService" promote="LogServiceContainer/LogService"/>
</sca:composite>

I would start a domain in the root directory with
SCADomain.newInstance( "com/foobaz/main.composite" );

This works fine if both composite files are in the same directory. However,
if the included composite is not in the same directory (i. e. also under com/foobaz),
but inside a jar-file somewhere on the classpath of my Eclipse launch configuration, 
I get errors:

FATAL: Reference not found for component reference: Component = LogServiceContainer Reference = LogService
WARNING: Component implementation not found: Component = LogServiceContainer Uri = null


Re: Nested composites and the classpath

Posted by Simon Nash <na...@apache.org>.
Luciano Resende wrote:
> On Mon, Sep 27, 2010 at 10:42 AM, Millies, Sebastian
> <Se...@ids-scheer.com> wrote:
>> Hello there,
>>
>> I'm having a problem with nested composites, that is composites included
>> as a component implementation in another composite. This seems to work only
>> when the XML file containing the referenced composite sits in the same
>> directory as the XML file with the including composite. It is not enough
>> that the referenced composite is in a file somewhere on the classpath, e. g.
>> in some jar-file.
>>
>> I'm using Tuscany 1.6. Has anyone else noticed this? Perhaps it has something
>> to do with things on the classpath not being considered part of the contribution
>> being loaded. But I'd find that exceedingly strange.
>>
>> What I would really like to do is have an Eclipse project for each composite,
>> export them in jar-files, put those jar files on the class path, and start a
>> main composite in which I define components with reference to some of those
>> ready-made parts. I certainly don't want to compile all the projects to
>> the same location.
>>
>> See below for an example.
>>
>> -- Sebastian
>>
>> Here's an example:
>> Main composite (in file ./com/foobaz/main.composite):
>>
>> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
>>  <sca:composite xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" xmlns:logservice-container="http://foobaz.com/logservice-container/" xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0" name="main" targetNamespace="http://foobaz.com/">
>>  <sca:component name="LogServiceContainer">
>>    <sca:implementation.composite name="logservice-container:logservice-container"/> <!-- ** here ** -->
>>    <sca:reference name="LogService">
>>      <sca:interface.java interface="foobaz.com.LogService"/>
>>      <sca:binding.jms initialContextFactory="org.apache.activemq.jndi.ActiveMQInitialContextFactory" jndiURL="tcp://localhost:61619" uri="jms:/LoggerComponent/LogService">
>>        <sca:destination create="ifnotexist" name="LoggingRequestQueue" type="queue"/>
>>        <tuscany:wireFormat.jmsTextXML/>
>>      </sca:binding.jms>
>>    </sca:reference>
>>  </sca:component>
>>  </sca:composite>
>>
>> Included composite, referenced by main composite at marked line above:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <sca:composite xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0" name="logservice-container" targetNamespace="http://foobaz.com/logservice-container/">
>>  <sca:component name="LogServiceContainer">
>>    <sca:implementation.java class="foobaz.com.LogServiceContainer"/>
>>    <sca:reference name="LogService"/>
>>  </sca:component>
>>  <sca:reference name="LogService" promote="LogServiceContainer/LogService"/>
>> </sca:composite>
>>
>> I would start a domain in the root directory with
>> SCADomain.newInstance( "com/foobaz/main.composite" );
>>
>> This works fine if both composite files are in the same directory. However,
>> if the included composite is not in the same directory (i. e. also under com/foobaz),
>> but inside a jar-file somewhere on the classpath of my Eclipse launch configuration,
>> I get errors:
>>
>> FATAL: Reference not found for component reference: Component = LogServiceContainer Reference = LogService
>> WARNING: Component implementation not found: Component = LogServiceContainer Uri = null
>>
These composites look fine.  By putting them in the same directory,
you have implicitly made them part of the same contribution.  It should
also work if they are in a subdirectory, because this is considered
part of the contribution as well.

>>
> 
> If I remember correctly, in 1.6 we only discover classes from
> classPath, other type of resources such as composites, wsdl, xsd are
> resolved by URI or by contribution import/export. From what you
> described, the composite referenced in the impl.composite might be on
> a folder outside of the current contribution thus you have to
> contribute that other contribution to the domain, and use
> import/export.
> 
> See this for an example
> https://svn.apache.org/repos/asf/tuscany/sca-java-1.x/trunk/itest/contribution-import-export/
> 
> 
You'll find that things work best if you follow the SCA contribution
packaging model and avoid relying on the classpath.   As Luciano says,
in some cases Tuscany will allow you to "break" the contribution
packaging model for classes.  However you need to be very careful if
you do this because if you include the same classes in a contribution
you might run into problems with imports and exports not being resolved
correctly.  See point 3 in reference [1].

   Simon

[1] http://www.mail-archive.com/user@tuscany.apache.org/msg02597.html


Re: Nested composites and the classpath

Posted by Luciano Resende <lu...@gmail.com>.
On Mon, Sep 27, 2010 at 10:42 AM, Millies, Sebastian
<Se...@ids-scheer.com> wrote:
> Hello there,
>
> I'm having a problem with nested composites, that is composites included
> as a component implementation in another composite. This seems to work only
> when the XML file containing the referenced composite sits in the same
> directory as the XML file with the including composite. It is not enough
> that the referenced composite is in a file somewhere on the classpath, e. g.
> in some jar-file.
>
> I'm using Tuscany 1.6. Has anyone else noticed this? Perhaps it has something
> to do with things on the classpath not being considered part of the contribution
> being loaded. But I'd find that exceedingly strange.
>
> What I would really like to do is have an Eclipse project for each composite,
> export them in jar-files, put those jar files on the class path, and start a
> main composite in which I define components with reference to some of those
> ready-made parts. I certainly don't want to compile all the projects to
> the same location.
>
> See below for an example.
>
> -- Sebastian
>
> Here's an example:
> Main composite (in file ./com/foobaz/main.composite):
>
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
>  <sca:composite xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" xmlns:logservice-container="http://foobaz.com/logservice-container/" xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0" name="main" targetNamespace="http://foobaz.com/">
>  <sca:component name="LogServiceContainer">
>    <sca:implementation.composite name="logservice-container:logservice-container"/> <!-- ** here ** -->
>    <sca:reference name="LogService">
>      <sca:interface.java interface="foobaz.com.LogService"/>
>      <sca:binding.jms initialContextFactory="org.apache.activemq.jndi.ActiveMQInitialContextFactory" jndiURL="tcp://localhost:61619" uri="jms:/LoggerComponent/LogService">
>        <sca:destination create="ifnotexist" name="LoggingRequestQueue" type="queue"/>
>        <tuscany:wireFormat.jmsTextXML/>
>      </sca:binding.jms>
>    </sca:reference>
>  </sca:component>
>  </sca:composite>
>
> Included composite, referenced by main composite at marked line above:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <sca:composite xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0" name="logservice-container" targetNamespace="http://foobaz.com/logservice-container/">
>  <sca:component name="LogServiceContainer">
>    <sca:implementation.java class="foobaz.com.LogServiceContainer"/>
>    <sca:reference name="LogService"/>
>  </sca:component>
>  <sca:reference name="LogService" promote="LogServiceContainer/LogService"/>
> </sca:composite>
>
> I would start a domain in the root directory with
> SCADomain.newInstance( "com/foobaz/main.composite" );
>
> This works fine if both composite files are in the same directory. However,
> if the included composite is not in the same directory (i. e. also under com/foobaz),
> but inside a jar-file somewhere on the classpath of my Eclipse launch configuration,
> I get errors:
>
> FATAL: Reference not found for component reference: Component = LogServiceContainer Reference = LogService
> WARNING: Component implementation not found: Component = LogServiceContainer Uri = null
>
>

If I remember correctly, in 1.6 we only discover classes from
classPath, other type of resources such as composites, wsdl, xsd are
resolved by URI or by contribution import/export. From what you
described, the composite referenced in the impl.composite might be on
a folder outside of the current contribution thus you have to
contribute that other contribution to the domain, and use
import/export.

See this for an example
https://svn.apache.org/repos/asf/tuscany/sca-java-1.x/trunk/itest/contribution-import-export/


-- 
Luciano Resende
http://people.apache.org/~lresende
http://twitter.com/lresende1975
http://lresende.blogspot.com/