You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by Jean-Sebastien Delfino <js...@apache.org> on 2010/05/18 18:44:56 UTC

Example of how to bootstrap a Tuscany 2.x runtime?

Can you point me a good example or test case showing how to bootstrap a 
Tuscany runtime?

I have the URL of a contribution, the qname of a composite in that 
contribution, the name of a component in that composite. I'd like to 
start a Tuscany runtime instance and run the component on it.

I remember several attempts at different designs and APIs to manage 
Tuscany runtime instances, but I'm not sure which of these now works 
with the 2.x runtime.

The tests in samples/launcher-embedded-jse fail for me with this error:

Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 2.441 
sec <<< FAILURE!
testCOntributionBindingSCACalculator(launcher.LauncherTestCase)  Time 
elapsed: 1.939 sec  <<< ERROR!
java.lang.IllegalStateException: 
org.apache.tuscany.sca.contribution.processor.ContributionReadException: 
java.io.FileNotFoundException: 
/home/delfinoj/SCA/Source/tuscany-sca-java/samples/launcher-embedded-jse/../contribution-binding-sca-calculator/target/classes 
(No such file or directory)
     at org.apache.tuscany.sca.node.impl.NodeImpl.start(NodeImpl.java:173)
     at launcher.RuntimeIntegration.startNode(RuntimeIntegration.java:35)
     at 
launcher.SampleJSELauncher.launchBindingSCACalculator(SampleJSELauncher.java:61)
     at launcher.SampleJSELauncher.main(SampleJSELauncher.java:48)
     at 
launcher.LauncherTestCase.testCOntributionBindingSCACalculator(LauncherTestCase.java:30)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
     at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     at java.lang.reflect.Method.invoke(Method.java:616)
     at 
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
     at 
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
     at 
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
     at 
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
     at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
     at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
     at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
     at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
     at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
     at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
     at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
     at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
     at 
org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
     at 
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
     at 
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
     at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
     at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     at java.lang.reflect.Method.invoke(Method.java:616)
     at 
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
     at 
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)


Thanks
-- 
Jean-Sebastien

Re: Example of how to bootstrap a Tuscany 2.x runtime?

Posted by Mike Edwards <mi...@gmail.com>.
Jean-Sebastien Delfino wrote:
> Can you point me a good example or test case showing how to bootstrap a 
> Tuscany runtime?
> 
> I have the URL of a contribution, the qname of a composite in that 
> contribution, the name of a component in that composite. I'd like to 
> start a Tuscany runtime instance and run the component on it.
> 
> I remember several attempts at different designs and APIs to manage 
> Tuscany runtime instances, but I'm not sure which of these now works 
> with the 2.x runtime.
> 
> The tests in samples/launcher-embedded-jse fail for me with this error:
> 
> Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 2.441 
> sec <<< FAILURE!
> testCOntributionBindingSCACalculator(launcher.LauncherTestCase)  Time 
> elapsed: 1.939 sec  <<< ERROR!
> java.lang.IllegalStateException: 
> org.apache.tuscany.sca.contribution.processor.ContributionReadException: 
> java.io.FileNotFoundException: 
> /home/delfinoj/SCA/Source/tuscany-sca-java/samples/launcher-embedded-jse/../contribution-binding-sca-calculator/target/classes 
> (No such file or directory)
>     at org.apache.tuscany.sca.node.impl.NodeImpl.start(NodeImpl.java:173)
>     at launcher.RuntimeIntegration.startNode(RuntimeIntegration.java:35)
>     at 
> launcher.SampleJSELauncher.launchBindingSCACalculator(SampleJSELauncher.java:61) 
<snip>
Jean_Sebastien,

The technique I use in the Client for the OASIS SCA test suite is as follows:

------
	public boolean startContribution(String compositeName,
			                         String contributionLocation,
			                         String[] contributionNames) throws Exception {
	try {
	// Tuscany specific code which starts the contribution(s) holding the test
         launcher = NodeLauncher.newInstance();

         Contribution[] contributions = new Contribution[contributionNames.length];
         String[] contributionURIs = getContributionURIs( contributionLocation, contributionNames );
         for( int i = 0; i < contributions.length ; i++ ) {
         	contributions[i] = new Contribution(contributionNames[i], contributionURIs[i]);
         } // end for

		node = launcher.createNode(compositeName, contributions );
         // Start the node
         node.start();
	} catch (Exception e) {
		System.out.println( "Exception during startup: " + e.getMessage() );
		throw e;
	} // end try

         return true;
	} // end method startContribution
-----

This deals with a set of contributions and a single composite to deploy as the "root" of the 
application.

Hope this helps,


Yours,  Mike.



Re: Example of how to bootstrap a Tuscany 2.x runtime?

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

You can try this one:

          NodeFactory factory = NodeFactory.newInstance(); // Use NodeFactory.getInstance() if you want to share the Tuscany runtime within the same classloading space
            String contribution = ContributionLocationHelper.getContributionLocation(HelloWorldClient.class); // You can use a URL for contribution too
            node =
                factory.createNode("helloworldwsclient.composite", new Contribution("helloworld", contribution))
                    .start(); // There are a few variants of createNode() methods

            helloWorldService = node.getService(HelloWorldService.class, "HelloWorldServiceComponent");
http://tuscany.apache.org/documentation-2x/development-guides.data/Tuscany%20SCA%20Domain%20Node.odp

Thanks,
Raymond
________________________________________________________________ 
Raymond Feng
rfeng@apache.org
Apache Tuscany PMC member and committer: tuscany.apache.org
Co-author of Tuscany SCA In Action book: www.tuscanyinaction.com
Personal Web Site: www.enjoyjava.com
________________________________________________________________

On May 18, 2010, at 9:44 AM, Jean-Sebastien Delfino wrote:

> Can you point me a good example or test case showing how to bootstrap a Tuscany runtime?
> 
> I have the URL of a contribution, the qname of a composite in that contribution, the name of a component in that composite. I'd like to start a Tuscany runtime instance and run the component on it.
> 
> I remember several attempts at different designs and APIs to manage Tuscany runtime instances, but I'm not sure which of these now works with the 2.x runtime.
> 
> The tests in samples/launcher-embedded-jse fail for me with this error:
> 
> Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 2.441 sec <<< FAILURE!
> testCOntributionBindingSCACalculator(launcher.LauncherTestCase)  Time elapsed: 1.939 sec  <<< ERROR!
> java.lang.IllegalStateException: org.apache.tuscany.sca.contribution.processor.ContributionReadException: java.io.FileNotFoundException: /home/delfinoj/SCA/Source/tuscany-sca-java/samples/launcher-embedded-jse/../contribution-binding-sca-calculator/target/classes (No such file or directory)
>    at org.apache.tuscany.sca.node.impl.NodeImpl.start(NodeImpl.java:173)
>    at launcher.RuntimeIntegration.startNode(RuntimeIntegration.java:35)
>    at launcher.SampleJSELauncher.launchBindingSCACalculator(SampleJSELauncher.java:61)
>    at launcher.SampleJSELauncher.main(SampleJSELauncher.java:48)
>    at launcher.LauncherTestCase.testCOntributionBindingSCACalculator(LauncherTestCase.java:30)
>    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>    at java.lang.reflect.Method.invoke(Method.java:616)
>    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
>    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
>    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
>    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
>    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
>    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
>    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
>    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
>    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
>    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
>    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
>    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
>    at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
>    at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
>    at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
>    at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
>    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>    at java.lang.reflect.Method.invoke(Method.java:616)
>    at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
>    at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
> 
> 
> Thanks
> -- 
> Jean-Sebastien


Re: Example of how to bootstrap a Tuscany 2.x runtime?

Posted by Yang Lei <yl...@gmail.com>.
If you have a single contribution jar which you want to bootstrap all the
deployable composite defined in the sca-contribution.xml. Here is my code
sample to bootstrap:


String storeLocation =
"File:///C:/ASV/Tuscany2x/Test/TestCase/sample-store-all.jar";

*node1* = NodeFactory.*newInstance*().createNode(*new* Contribution("store"
,storeLocation));

*node1*.start();

If you have multiple contributions, you can add as many Contributions in
createNode(..) e.g.



String storeLocation =
File:///C:/ASV/Tuscany2x/Test/TestCase/sample-store.jar<file:///C:/ASV/Tuscany2x/Test/TestCase/sample-store.jar>
;

String storeClientLocation =
File:///C:/ASV/Tuscany2x/Test/TestCase/sample-store-client.jar<file:///C:/ASV/Tuscany2x/Test/TestCase/sample-store-client.jar>
;

*node1* = NodeFactory.*newInstance*().createNode(*new*
Contribution("store",storeLocation),
*new* Contribution("storeClient", storeClientLocation));

*node1*.start();

You can also create multiple nodes to bootstrap different composites in
them.

Re: Example of how to bootstrap a Tuscany 2.x runtime?

Posted by Jean-Sebastien Delfino <js...@apache.org>.
Simon Laws wrote:
> On Tue, May 18, 2010 at 5:44 PM, Jean-Sebastien Delfino
> <js...@apache.org> wrote:
>> Can you point me a good example or test case showing how to bootstrap a
>> Tuscany runtime?
>>
>> I have the URL of a contribution, the qname of a composite in that
>> contribution, the name of a component in that composite. I'd like to start a
>> Tuscany runtime instance and run the component on it.
>>
>> I remember several attempts at different designs and APIs to manage Tuscany
>> runtime instances, but I'm not sure which of these now works with the 2.x
>> runtime.
>>
>> The tests in samples/launcher-embedded-jse fail for me with this error:
>>
>> Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 2.441 sec
>> <<< FAILURE!
>> testCOntributionBindingSCACalculator(launcher.LauncherTestCase)  Time
>> elapsed: 1.939 sec  <<< ERROR!
>> java.lang.IllegalStateException:
>> org.apache.tuscany.sca.contribution.processor.ContributionReadException:
>> java.io.FileNotFoundException:
>> /home/delfinoj/SCA/Source/tuscany-sca-java/samples/launcher-embedded-jse/../contribution-binding-sca-calculator/target/classes
>> (No such file or directory)
>>    at org.apache.tuscany.sca.node.impl.NodeImpl.start(NodeImpl.java:173)
>>    at launcher.RuntimeIntegration.startNode(RuntimeIntegration.java:35)
>>    at
>> launcher.SampleJSELauncher.launchBindingSCACalculator(SampleJSELauncher.java:61)
>>    at launcher.SampleJSELauncher.main(SampleJSELauncher.java:48)
>>    at
>> launcher.LauncherTestCase.testCOntributionBindingSCACalculator(LauncherTestCase.java:30)
>>    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>    at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>    at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>    at java.lang.reflect.Method.invoke(Method.java:616)
>>    at
>> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
>>    at
>> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
>>    at
>> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
>>    at
>> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
>>    at
>> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
>>    at
>> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
>>    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
>>    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
>>    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
>>    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
>>    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
>>    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
>>    at
>> org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
>>    at
>> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
>>    at
>> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
>>    at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
>>    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>    at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>    at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>    at java.lang.reflect.Method.invoke(Method.java:616)
>>    at
>> org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
>>    at
>> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
>>
>>
>> Thanks
>> --
>> Jean-Sebastien
>>
> 
> Hi Jean-Sebastien
> 
> Raymond pipped me to the post. There are many different variations on
> the createNode() operation so if that doesn't precisely suit there may
> be an alternative that does.
> 
> Note. I'm just working on the samples and launchers now. I need to
> change it to look for the jars rather than the target/classes. In the
> mean time did you compile the contribution? It's complaining that it
> can't find the directory where the contribution is.
> 
> Simon
> 

You're correct, I was missing the contributions. After rebuilding them 
the test in samples/launcher-embedded-jse now work. They use the same 
Node API people have described in this thread, so I'm OK for now. Thanks!

-- 
Jean-Sebastien

Re: Example of how to bootstrap a Tuscany 2.x runtime?

Posted by Simon Laws <si...@googlemail.com>.
On Tue, May 18, 2010 at 5:44 PM, Jean-Sebastien Delfino
<js...@apache.org> wrote:
> Can you point me a good example or test case showing how to bootstrap a
> Tuscany runtime?
>
> I have the URL of a contribution, the qname of a composite in that
> contribution, the name of a component in that composite. I'd like to start a
> Tuscany runtime instance and run the component on it.
>
> I remember several attempts at different designs and APIs to manage Tuscany
> runtime instances, but I'm not sure which of these now works with the 2.x
> runtime.
>
> The tests in samples/launcher-embedded-jse fail for me with this error:
>
> Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 2.441 sec
> <<< FAILURE!
> testCOntributionBindingSCACalculator(launcher.LauncherTestCase)  Time
> elapsed: 1.939 sec  <<< ERROR!
> java.lang.IllegalStateException:
> org.apache.tuscany.sca.contribution.processor.ContributionReadException:
> java.io.FileNotFoundException:
> /home/delfinoj/SCA/Source/tuscany-sca-java/samples/launcher-embedded-jse/../contribution-binding-sca-calculator/target/classes
> (No such file or directory)
>    at org.apache.tuscany.sca.node.impl.NodeImpl.start(NodeImpl.java:173)
>    at launcher.RuntimeIntegration.startNode(RuntimeIntegration.java:35)
>    at
> launcher.SampleJSELauncher.launchBindingSCACalculator(SampleJSELauncher.java:61)
>    at launcher.SampleJSELauncher.main(SampleJSELauncher.java:48)
>    at
> launcher.LauncherTestCase.testCOntributionBindingSCACalculator(LauncherTestCase.java:30)
>    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>    at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>    at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>    at java.lang.reflect.Method.invoke(Method.java:616)
>    at
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
>    at
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
>    at
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
>    at
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
>    at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
>    at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
>    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
>    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
>    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
>    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
>    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
>    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
>    at
> org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
>    at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
>    at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
>    at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
>    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>    at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>    at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>    at java.lang.reflect.Method.invoke(Method.java:616)
>    at
> org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
>    at
> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
>
>
> Thanks
> --
> Jean-Sebastien
>

Hi Jean-Sebastien

Raymond pipped me to the post. There are many different variations on
the createNode() operation so if that doesn't precisely suit there may
be an alternative that does.

Note. I'm just working on the samples and launchers now. I need to
change it to look for the jars rather than the target/classes. In the
mean time did you compile the contribution? It's complaining that it
can't find the directory where the contribution is.

Simon

-- 
Apache Tuscany committer: tuscany.apache.org
Co-author of a book about Tuscany and SCA: tuscanyinaction.com