On Wed, Jun 23, 2010 at 4:00 PM, Roberts, Keith (SAIC)
<[email protected]> wrote:
> Hi all
>
>
>
> I’m a newbie, trying to get a better understanding of Tuscany be studying
> and executing the examples…
>
>
>
> I’m embarrassed to admit that I have not gotten past the simplest helloworld
> example.
>
>
>
> I’ve looked at the ‘store’ example and feel that I understand it pretty
> well. I went through the tutorial and was able to get it to work.
>
>
>
> I am assuming that the helloworld example needs to be launched to host the
> helloworld service just like the store example. I tried installing the
> eclipse Tuscany plugin but had problems with the eclipse update manager.
>
>
>
> I didn’t see a launcher so I built one like the store example listed below.
>
>
>
> package launch;
>
>
>
> import org.apache.tuscany.sca.node.Contribution;
>
> import org.apache.tuscany.sca.node.ContributionLocationHelper;
>
> import org.apache.tuscany.sca.node.Node;
>
> import org.apache.tuscany.sca.node.NodeFactory;
>
>
>
> public class Launch {
>
>
>
>             /**
>
>              * @param args
>
>              */
>
>             public static void main(String[] args)  throws Exception {
>
>         System.out.println("Starting ...");
>
>         String contribution =
> ContributionLocationHelper.getContributionLocation(Launch.class);
>
>         Node node =
> NodeFactory.newInstance().createNode("helloworld.composite", new
> Contribution("test", contribution));
>
>         node.start();
>
>         System.out.println("store.composite ready for big business !!!");
>
>         System.in.read();
>
>         System.out.println("Stopping ...");
>
>         node.stop();
>
>         System.out.println();
>
>             }
>
>
>
> }
>
>
>
>
>
> But when I launch I get this exception.
>
>
>
> SEVERE: Element
> {http://docs.oasis-open.org/ns/opencsa/sca/200912}implementation.java cannot
> be processed. ([row,col,system-id]:
> [26,9,"file:/C:/data/frameworks/tuscany-sca-2.0-M5/samples/helloworld/target/classes/helloworld.composite"])
>
> Exception in thread "main" java.lang.IllegalStateException:
> org.oasisopen.sca.ServiceRuntimeException: [Contribution: test, Artifact:
> helloworld.composite] - Element
> {http://docs.oasis-open.org/ns/opencsa/sca/200912}implementation.java cannot
> be processed. ([row,col,system-id]:
> [26,9,"file:/C:/data/frameworks/tuscany-sca-2.0-M5/samples/helloworld/target/classes/helloworld.composite"])
>
>       at org.apache.tuscany.sca.node.impl.NodeImpl.start(NodeImpl.java:173)
>
>       at launch.Launch.main(Launch.java:17)
>
> Caused by: org.oasisopen.sca.ServiceRuntimeException: [Contribution: test,
> Artifact: helloworld.composite] - Element
> {http://docs.oasis-open.org/ns/opencsa/sca/200912}implementation.java cannot
> be processed. ([row,col,system-id]:
> [26,9,"file:/C:/data/frameworks/tuscany-sca-2.0-M5/samples/helloworld/target/classes/helloworld.composite"])
>
>       at
> org.apache.tuscany.sca.node.impl.NodeFactoryImpl.analyzeProblems(NodeFactoryImpl.java:199)
>
>       at
> org.apache.tuscany.sca.node.impl.NodeFactoryImpl.loadContributions(NodeFactoryImpl.java:432)
>
>       at org.apache.tuscany.sca.node.impl.NodeImpl.start(NodeImpl.java:125)
>
>       ... 1 more
>
>
>
> I expected this to run. I’m not sure if there is an issue with how I have
> specified the helloworld.composite in the launcher or if there is a problem
> instantiating the HelloWorldImpl class, or some other issue.
>
>
>
> Once I get the helloworld example to run on the server; I’m expecting the
> helloworld-scaclient – HelloworldSCAClient application to run as the client
> to the helloworld server service.
>
>
>
> I think I’m on the right track but not sure. This is probably some little
> simple thing that I’m overlooking.
>
>
>
> Thanks in advance…
>
>
>
>
>
>
>
> Keith G. Roberts
>
> SAIC/Evolvent VA Account
>
> CHDR team
>
> 801-924-2130
>
>

Hi Keith,

You can run the helloworld sample without needing to write any code by
using the Tuscany Maven plugin (which is defined inthe samples
pom.xml) by simply doing "mvn tuscany:run" in the helloworld sample
directory. That will start a Tuscany runtime with the helloworld
contribution installed. You can then test that by invoking that
helloworld service by using the helloworld-scaclient sample, in that
sample directory do "mvn exec:java" which will run the
HelloworldSCAClient main method.

You can also start a Tuscany runtime programatically like you were
trying to do, but to do that you need all the jars necessary to run
Tuscany. It looks like you are trying to run your code from within the
helloworld project which only has the SCA API jar defined as that is
all thats needed to compile an SCA contribution. The simplest way to
get all the jars is to copy what the helloworld-scaclient project does
which is to include this dependency:

        <dependency>
            <groupId>org.apache.tuscany.sca.shades</groupId>
            <artifactId>tuscany-base</artifactId>
            <version>2.0-M5</version>
        </dependency>

The code you have showed could also be simplified to just this:

        Node node = NodeFactory.newInstance().createNode((String)null,
new String[]{"../helloworld/target/classes"});
        node.start();
        Helloworld hw = node.getService(Helloworld.class,
"HelloworldComponent");
        System.out.println(hw.sayHello("Keith"));

The key points to get from those samples is that there are two
separate parts - one is creating SCA contributions, and the other is
using Tuscany to run SCA contributions.

HTH,

   ...ant

Reply via email to