You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by Richard Jones <ri...@hp.com> on 2008/06/19 15:57:09 UTC

starting tuscany outside of eclipse

Hi Folks,

I'm brand new to Tuscany, and I've been working my way through the 
documentation on the website.  I don't use Eclipse, but much of the 
documentation is geared towards using the Eclipse plugin to start the 
tuscany application server.  I can't find documentation on how to do 
this /without/ eclipse, can someone point me in the right direction?

I'm trying to do the very basic "Hello World" example.

Is there perhaps a TuscanyServlet that I can set in my own web.xml, and 
do my normal deployment through tomcat?

Cheers,

Richard

-- 
=======================================================================
Richard Jones                     |       Hewlett-Packard Limited
Research Engineer, HP Labs        |       registered office:
Bristol, UK                       |       Cain Road, Bracknell,
                                  |       Berks, RG12 1HN.
                                  |       Registered No: 690597 England
eml: richard.d.jones@hp.com       -------------------------------------
blg: http://chronicles-of-richard.blogspot.com/
-----------------------------------------------------------------------
The contents of this message and any attachments to it are confidential
and may be legally privileged. If you have received this message in
error, you should delete it from your system immediately and advise the
sender. To any recipient of this message within HP, unless otherwise
stated you should consider this message and attachments as "HP
CONFIDENTIAL".
========================================================================


Re: starting tuscany outside of eclipse

Posted by Richard Jones <ri...@hp.com>.
Hi Simon,

>>> Let me take a quick look at the code to remind myself what goes on behind
>>> the scenes here. In this particular case are you running this test from
>>> Eclipse or from the command line. If from Eclipse can you tell me what the
>>> output folder for this Eclipse project is set to. Is it
>>> file:/home/richard/workspace/tuscany-helloworld/out for example.
>>>
>>>
>>>       
>> I'm actually running it from inside IDEA, but it should be effectively the
>> same as running it from the command line.  I can spam the classpath if it's
>> any use, but it's /really/ long.  It does contain the directory in which
>> HelloWorld.composite is stored, though.
>>
>>     
> I find that the DefaultSCADomain class is trying to locate the composite
> file via the thread context classloader. Could that be causing problems for
> you?
>   

Ah, yes.  I've just tried loading the resource with

URL uri = 
Thread.currentThread().getContextClassLoader().getResource("HelloWorld.composite");

and it isn't working either.

This could be a problem with the classloader that IDEA sets on classes 
that you execute from inside it.  I'll see if there's a way around that.

Cheers,

Richard

-- 
=======================================================================
Richard Jones                     |       Hewlett-Packard Limited
Research Engineer, HP Labs        |       registered office:
Bristol, UK                       |       Cain Road, Bracknell,
                                  |       Berks, RG12 1HN.
                                  |       Registered No: 690597 England
eml: richard.d.jones@hp.com       -------------------------------------
blg: http://chronicles-of-richard.blogspot.com/
-----------------------------------------------------------------------
The contents of this message and any attachments to it are confidential
and may be legally privileged. If you have received this message in
error, you should delete it from your system immediately and advise the
sender. To any recipient of this message within HP, unless otherwise
stated you should consider this message and attachments as "HP
CONFIDENTIAL".
========================================================================


Re: starting tuscany outside of eclipse

Posted by Simon Laws <si...@googlemail.com>.
On Fri, Jun 20, 2008 at 11:43 AM, Richard Jones <ri...@hp.com>
wrote:

> Hi Simon,
>
>  Hi Richard.
>>
>> Let me take a quick look at the code to remind myself what goes on behind
>> the scenes here. In this particular case are you running this test from
>> Eclipse or from the command line. If from Eclipse can you tell me what the
>> output folder for this Eclipse project is set to. Is it
>> file:/home/richard/workspace/tuscany-helloworld/out for example.
>>
>>
>
> I'm actually running it from inside IDEA, but it should be effectively the
> same as running it from the command line.  I can spam the classpath if it's
> any use, but it's /really/ long.  It does contain the directory in which
> HelloWorld.composite is stored, though.
>
>
> Cheers,
>
> Richard
>
> --
> =======================================================================
> Richard Jones                     |       Hewlett-Packard Limited
> Research Engineer, HP Labs        |       registered office:
> Bristol, UK                       |       Cain Road, Bracknell,
>                                 |       Berks, RG12 1HN.
>                                 |       Registered No: 690597 England
> eml: richard.d.jones@hp.com       -------------------------------------
> blg: http://chronicles-of-richard.blogspot.com/
> -----------------------------------------------------------------------
> The contents of this message and any attachments to it are confidential
> and may be legally privileged. If you have received this message in
> error, you should delete it from your system immediately and advise the
> sender. To any recipient of this message within HP, unless otherwise
> stated you should consider this message and attachments as "HP
> CONFIDENTIAL".
> ========================================================================
>
>
I find that the DefaultSCADomain class is trying to locate the composite
file via the thread context classloader. Could that be causing problems for
you?

Simon

Re: starting tuscany outside of eclipse

Posted by Richard Jones <ri...@hp.com>.
Hi Simon,

> Hi Richard.
>
> Let me take a quick look at the code to remind myself what goes on behind
> the scenes here. In this particular case are you running this test from
> Eclipse or from the command line. If from Eclipse can you tell me what the
> output folder for this Eclipse project is set to. Is it
> file:/home/richard/workspace/tuscany-helloworld/out for example.
>   

I'm actually running it from inside IDEA, but it should be effectively 
the same as running it from the command line.  I can spam the classpath 
if it's any use, but it's /really/ long.  It does contain the directory 
in which HelloWorld.composite is stored, though.

Cheers,

Richard

-- 
=======================================================================
Richard Jones                     |       Hewlett-Packard Limited
Research Engineer, HP Labs        |       registered office:
Bristol, UK                       |       Cain Road, Bracknell,
                                  |       Berks, RG12 1HN.
                                  |       Registered No: 690597 England
eml: richard.d.jones@hp.com       -------------------------------------
blg: http://chronicles-of-richard.blogspot.com/
-----------------------------------------------------------------------
The contents of this message and any attachments to it are confidential
and may be legally privileged. If you have received this message in
error, you should delete it from your system immediately and advise the
sender. To any recipient of this message within HP, unless otherwise
stated you should consider this message and attachments as "HP
CONFIDENTIAL".
========================================================================


Re: starting tuscany outside of eclipse

Posted by Simon Laws <si...@googlemail.com>.
On Fri, Jun 20, 2008 at 11:28 AM, Richard Jones <ri...@hp.com>
wrote:

> Hi Simon,
>
>  The Tuscany runtime runs SCA composite applications described in
>> .composite
>> files. Components within these composite files can define references and
>> service and each can have bindings associated with them. When you specify
>> a
>> service binding, for example, binding.ws the runtime will do it's best to
>> provide the endpoint that that binding describes and it may do slightly
>> different things depending on how the runtime is being hosted, for
>> example,
>>
>> If you are running from the command line and have a simple launcher than
>> creates an SCADomain then to create HTTP endpoints for the web service
>> bindings Tuscany will fire up an instance of Tomcat or Jetty depending on
>> whether you have host-tomcat or host-jetty on the classpath.
>>
>>
>
> OK, I see!  Very smart.
>
>  If you are packaging Tuscany in a webapp and want to use the web service
>> binding then we would expect you to have host-webapp on the classpath.
>> This
>> allows the runtime to use the servlet container where the webapp is
>> running
>> to provide the HTTP endpoints for bindings like binding.ws.
>>
>> The bottom line being that the composite file should fully describe the
>> composite application and the runtime will honour what is in there.
>>
>>
>
> <snip/>
>
>
>  So the bit I'm stuck on here is how to create the SCADomain for the
>>> HelloWorld example automatically:
>>>
>>> http://tuscany.apache.org/build-your-first-web-services-with-tuscany.html
>>>
>>> It looks as though the Eclipse plugin can take the HelloWorld.composite
>>> and
>>> turns it into a web application without having to add this extra layer of
>>> a
>>> ServletFilter and a JSP.  The differences that I can see are that the
>>> Calculator.composite doesn't define a service, and instead the
>>> TuscanyServletFilter is reading in that file and then making itself the
>>> effective web-service interface.  Meanwhile, the HelloWorld example has a
>>> different kind of definition:
>>>
>>> <component name="HelloWorldComponent">
>>>      <implementation.java class="hw.HelloWorldImpl"/>
>>>      <service name="HelloWorld">
>>>          <binding.ws uri="http://localhost:8080/HelloWorld"/>
>>>      </service>
>>> </component>
>>>
>>> The Eclipse plugin looks like it understands how to take this service
>>> binding and turn it into an actual service.  I think what I need to know
>>> is
>>> how to deploy this particular type of composite definition (although I'm
>>> also possibly off base here).
>>>
>>>
>>
>>
>> There is a bit of slight of hand happening with the Eclipse plugin. The
>> tutorial says...
>>
>> "First select the "helloworld.composite" file, in your "ws" project.
>> *Right
>> click* to get the
>> context menu, select *Run As*, and then *Tuscany*. The Tuscany runtime
>> will
>> start up adding"
>>
>> What this is doing behind the scenes is passing "helloworld.composite" to
>> a
>> command line like launcher which fires up the Tuscany runtime to read the
>> composite file and create the endpoints for the specified bindings. As the
>> binding here is binding.ws here Tuscany will fire or Tomcat or Jetty to
>> make
>> it work.
>>
>>
>>
>>
>>> I tried writing a Launch class as per:
>>>
>>> http://tuscany.apache.org/getting-started-with-tuscany.html
>>>
>>> which basically did:
>>>
>>> public static void main(String[] args)
>>>          throws Exception
>>> {
>>>      SCADomain scaDomain = SCADomain.newInstance("HelloWorld.composite");
>>>      System.in.read();
>>>      scaDomain.close();
>>> }
>>>
>>> But this is throwing exceptions:
>>>
>>> Exception in thread "main" org.osoa.sca.ServiceRuntimeException:
>>> org.osoa.sca.ServiceRuntimeException: java.lang.IllegalArgumentException:
>>> Composite not found: HelloWorld.composite
>>>
>>>
>>
>>
>> This should work but this error suggests that the composite file is not on
>> your classpath.
>>
>>
>
> OK, so I've verified that the composite is on the classpath, but I'm still
> getting the same error.  I wedged in a check to show me where the file
> actually is:
>
> public class Launch
> {
>   public static void main(String[] args)
>           throws Exception
>   {
>       URL url = (new
> Launch()).getClass().getResource("HelloWorld.composite");
>       System.out.println(url.toString());         SCADomain scaDomain =
> SCADomain.newInstance("HelloWorld.composite");
>   }
> }
>
> outputs:
>
>
> file:/home/richard/workspace/tuscany-helloworld/out/production/tuscany-helloworld/hw/HelloWorld.composite
> Exception in thread "main" org.osoa.sca.ServiceRuntimeException:
> org.osoa.sca.ServiceRuntimeException: java.lang.IllegalArgumentException:
> Composite not found: HelloWorld.composite
>
> Am I still missing something?  I'm stumped :)
>
>  * - what mechanism does SCADomain.newInstance use to locate the resource?
>>>  is it just a Class.getResource or somesuch?
>>>
>>>
>>>
>>
>> Yes, Tuscany looks for the named file on the classpath and then uses the
>> directory in which it finds that file as what SCA calls the contribution.
>> The contribution should collect together all of the artifacts that are
>> required to run the composite application, e.g. the composite file itself
>> and the files that provide component implementations etc.
>>
>>
>
> OK, so I'm pretty certain that I've done this right, in that I have in the
> directory:
>
>
> file:/home/richard/workspace/tuscany-helloworld/out/production/tuscany-helloworld/hw/
>
> The files:
>
> HelloWorld
> HelloWorldImpl
> HelloWorld.composite
> Launch
>
>
> Cheers,
>
> Richard
>
> --
> =======================================================================
> Richard Jones                     |       Hewlett-Packard Limited
> Research Engineer, HP Labs        |       registered office:
> Bristol, UK                       |       Cain Road, Bracknell,
>                                 |       Berks, RG12 1HN.
>                                 |       Registered No: 690597 England
> eml: richard.d.jones@hp.com       -------------------------------------
> blg: http://chronicles-of-richard.blogspot.com/
> -----------------------------------------------------------------------
> The contents of this message and any attachments to it are confidential
> and may be legally privileged. If you have received this message in
> error, you should delete it from your system immediately and advise the
> sender. To any recipient of this message within HP, unless otherwise
> stated you should consider this message and attachments as "HP
> CONFIDENTIAL".
> ========================================================================
>
>
Hi Richard.

Let me take a quick look at the code to remind myself what goes on behind
the scenes here. In this particular case are you running this test from
Eclipse or from the command line. If from Eclipse can you tell me what the
output folder for this Eclipse project is set to. Is it
file:/home/richard/workspace/tuscany-helloworld/out for example.

Regards

Simon

Re: starting tuscany outside of eclipse

Posted by Richard Jones <ri...@hp.com>.
Hi Simon,

> The Tuscany runtime runs SCA composite applications described in .composite
> files. Components within these composite files can define references and
> service and each can have bindings associated with them. When you specify a
> service binding, for example, binding.ws the runtime will do it's best to
> provide the endpoint that that binding describes and it may do slightly
> different things depending on how the runtime is being hosted, for example,
>
> If you are running from the command line and have a simple launcher than
> creates an SCADomain then to create HTTP endpoints for the web service
> bindings Tuscany will fire up an instance of Tomcat or Jetty depending on
> whether you have host-tomcat or host-jetty on the classpath.
>   

OK, I see!  Very smart.

> If you are packaging Tuscany in a webapp and want to use the web service
> binding then we would expect you to have host-webapp on the classpath. This
> allows the runtime to use the servlet container where the webapp is running
> to provide the HTTP endpoints for bindings like binding.ws.
>
> The bottom line being that the composite file should fully describe the
> composite application and the runtime will honour what is in there.
>   

<snip/>

>> So the bit I'm stuck on here is how to create the SCADomain for the
>> HelloWorld example automatically:
>>
>> http://tuscany.apache.org/build-your-first-web-services-with-tuscany.html
>>
>> It looks as though the Eclipse plugin can take the HelloWorld.composite and
>> turns it into a web application without having to add this extra layer of a
>> ServletFilter and a JSP.  The differences that I can see are that the
>> Calculator.composite doesn't define a service, and instead the
>> TuscanyServletFilter is reading in that file and then making itself the
>> effective web-service interface.  Meanwhile, the HelloWorld example has a
>> different kind of definition:
>>
>> <component name="HelloWorldComponent">
>>       <implementation.java class="hw.HelloWorldImpl"/>
>>       <service name="HelloWorld">
>>           <binding.ws uri="http://localhost:8080/HelloWorld"/>
>>       </service>
>> </component>
>>
>> The Eclipse plugin looks like it understands how to take this service
>> binding and turn it into an actual service.  I think what I need to know is
>> how to deploy this particular type of composite definition (although I'm
>> also possibly off base here).
>>     
>
>
> There is a bit of slight of hand happening with the Eclipse plugin. The
> tutorial says...
>
> "First select the "helloworld.composite" file, in your "ws" project. *Right
> click* to get the
> context menu, select *Run As*, and then *Tuscany*. The Tuscany runtime will
> start up adding"
>
> What this is doing behind the scenes is passing "helloworld.composite" to a
> command line like launcher which fires up the Tuscany runtime to read the
> composite file and create the endpoints for the specified bindings. As the
> binding here is binding.ws here Tuscany will fire or Tomcat or Jetty to make
> it work.
>
>
>   
>> I tried writing a Launch class as per:
>>
>> http://tuscany.apache.org/getting-started-with-tuscany.html
>>
>> which basically did:
>>
>> public static void main(String[] args)
>>           throws Exception
>> {
>>       SCADomain scaDomain = SCADomain.newInstance("HelloWorld.composite");
>>       System.in.read();
>>       scaDomain.close();
>> }
>>
>> But this is throwing exceptions:
>>
>> Exception in thread "main" org.osoa.sca.ServiceRuntimeException:
>> org.osoa.sca.ServiceRuntimeException: java.lang.IllegalArgumentException:
>> Composite not found: HelloWorld.composite
>>     
>
>
> This should work but this error suggests that the composite file is not on
> your classpath.
>   

OK, so I've verified that the composite is on the classpath, but I'm 
still getting the same error.  I wedged in a check to show me where the 
file actually is:

public class Launch
{
    public static void main(String[] args)
            throws Exception
    {
        URL url = (new 
Launch()).getClass().getResource("HelloWorld.composite");
        System.out.println(url.toString());   
        SCADomain scaDomain = SCADomain.newInstance("HelloWorld.composite");
    }
}

outputs:

file:/home/richard/workspace/tuscany-helloworld/out/production/tuscany-helloworld/hw/HelloWorld.composite
Exception in thread "main" org.osoa.sca.ServiceRuntimeException: 
org.osoa.sca.ServiceRuntimeException: 
java.lang.IllegalArgumentException: Composite not found: 
HelloWorld.composite

Am I still missing something?  I'm stumped :)

>> * - what mechanism does SCADomain.newInstance use to locate the resource?
>>  is it just a Class.getResource or somesuch?
>>
>>     
>
> Yes, Tuscany looks for the named file on the classpath and then uses the
> directory in which it finds that file as what SCA calls the contribution.
> The contribution should collect together all of the artifacts that are
> required to run the composite application, e.g. the composite file itself
> and the files that provide component implementations etc.
>   

OK, so I'm pretty certain that I've done this right, in that I have in 
the directory:

file:/home/richard/workspace/tuscany-helloworld/out/production/tuscany-helloworld/hw/

The files:

HelloWorld
HelloWorldImpl
HelloWorld.composite
Launch

Cheers,

Richard

-- 
=======================================================================
Richard Jones                     |       Hewlett-Packard Limited
Research Engineer, HP Labs        |       registered office:
Bristol, UK                       |       Cain Road, Bracknell,
                                  |       Berks, RG12 1HN.
                                  |       Registered No: 690597 England
eml: richard.d.jones@hp.com       -------------------------------------
blg: http://chronicles-of-richard.blogspot.com/
-----------------------------------------------------------------------
The contents of this message and any attachments to it are confidential
and may be legally privileged. If you have received this message in
error, you should delete it from your system immediately and advise the
sender. To any recipient of this message within HP, unless otherwise
stated you should consider this message and attachments as "HP
CONFIDENTIAL".
========================================================================


Re: starting tuscany outside of eclipse

Posted by Simon Laws <si...@googlemail.com>.
Hi Richard

Let me give you a quick summary of how the Tuscany runtime works and then
I've put some comments in line below.

The Tuscany runtime runs SCA composite applications described in .composite
files. Components within these composite files can define references and
service and each can have bindings associated with them. When you specify a
service binding, for example, binding.ws the runtime will do it's best to
provide the endpoint that that binding describes and it may do slightly
different things depending on how the runtime is being hosted, for example,

If you are running from the command line and have a simple launcher than
creates an SCADomain then to create HTTP endpoints for the web service
bindings Tuscany will fire up an instance of Tomcat or Jetty depending on
whether you have host-tomcat or host-jetty on the classpath.

If you are packaging Tuscany in a webapp and want to use the web service
binding then we would expect you to have host-webapp on the classpath. This
allows the runtime to use the servlet container where the webapp is running
to provide the HTTP endpoints for bindings like binding.ws.

The bottom line being that the composite file should fully describe the
composite application and the runtime will honour what is in there.

Regards

Simon

On Thu, Jun 19, 2008 at 4:06 PM, Richard Jones <ri...@hp.com>
wrote:

> Hi Simon,
>
> Thanks for the pointers, I've taken a trawl through some more code, and
> have a couple more questions if you don't mind ...
>

No problem at all


>
>
>  Hi Folks,
>>>
>>> I'm brand new to Tuscany, and I've been working my way through the
>>> documentation on the website.  I don't use Eclipse, but much of the
>>> documentation is geared towards using the Eclipse plugin to start the
>>> tuscany application server.  I can't find documentation on how to do this
>>> /without/ eclipse, can someone point me in the right direction?
>>>
>>> I'm trying to do the very basic "Hello World" example.
>>>
>>> Is there perhaps a TuscanyServlet that I can set in my own web.xml, and
>>> do
>>> my normal deployment through tomcat?
>>>
>>> Cheers,
>>>
>>> Richard
>>>
>>>
>>>
>>
>  Hi Richard. Welcome to Tuscany.
>>
>> There are a few words about how to develop an SCA application from the
>> command line in [1] but it doesn't cover doing webapp development. You
>> could
>> take a look at one of the Tuscany samples that do this. For example, look
>> in
>> samples/calculator-webapp [2]. You will see that the basic layout of this
>> webapp is that an SCA application (the calculator sample) is packaged as a
>> webapp and a jsp is fired up and makes a call to the Calculator component
>> described in the SCA composite file [3]. The web.xml file in this case
>> defines a servlet filter as follows.
>>
>>
>
> OK, I see, it uses an SCADomain created by the TuscanyServletFilter, and
> pulls the appropriate service out of that:
>
> SCADomain scaDomain = (SCADomain)
> application.getAttribute("org.apache.tuscany.sca.SCADomain");
> CalculatorService calculatorService =
> (CalculatorService)scaDomain.getService(CalculatorService.class,
> "CalculatorServiceComponent");
>
> So the bit I'm stuck on here is how to create the SCADomain for the
> HelloWorld example automatically:
>
> http://tuscany.apache.org/build-your-first-web-services-with-tuscany.html
>
> It looks as though the Eclipse plugin can take the HelloWorld.composite and
> turns it into a web application without having to add this extra layer of a
> ServletFilter and a JSP.  The differences that I can see are that the
> Calculator.composite doesn't define a service, and instead the
> TuscanyServletFilter is reading in that file and then making itself the
> effective web-service interface.  Meanwhile, the HelloWorld example has a
> different kind of definition:
>
> <component name="HelloWorldComponent">
>       <implementation.java class="hw.HelloWorldImpl"/>
>       <service name="HelloWorld">
>           <binding.ws uri="http://localhost:8080/HelloWorld"/>
>       </service>
> </component>
>
> The Eclipse plugin looks like it understands how to take this service
> binding and turn it into an actual service.  I think what I need to know is
> how to deploy this particular type of composite definition (although I'm
> also possibly off base here).


There is a bit of slight of hand happening with the Eclipse plugin. The
tutorial says...

"First select the "helloworld.composite" file, in your "ws" project. *Right
click* to get the
context menu, select *Run As*, and then *Tuscany*. The Tuscany runtime will
start up adding"

What this is doing behind the scenes is passing "helloworld.composite" to a
command line like launcher which fires up the Tuscany runtime to read the
composite file and create the endpoints for the specified bindings. As the
binding here is binding.ws here Tuscany will fire or Tomcat or Jetty to make
it work.


>
>
> I tried writing a Launch class as per:
>
> http://tuscany.apache.org/getting-started-with-tuscany.html
>
> which basically did:
>
> public static void main(String[] args)
>           throws Exception
> {
>       SCADomain scaDomain = SCADomain.newInstance("HelloWorld.composite");
>       System.in.read();
>       scaDomain.close();
> }
>
> But this is throwing exceptions:
>
> Exception in thread "main" org.osoa.sca.ServiceRuntimeException:
> org.osoa.sca.ServiceRuntimeException: java.lang.IllegalArgumentException:
> Composite not found: HelloWorld.composite


This should work but this error suggests that the composite file is not on
your classpath.


>
> That last part might be a classpath problem* which I haven't figured out
> yet, but supposing it didn't balk, is this the right approach to launching
> the application?


It depends what you want to do. It's an excellent approach when you want to
learn Tuscany and play around with a few things. You may want to deploy
Tuscany in a webbapp in the future but I wouldn't recommend you start by
doing that. Running from a command line launcher like you have here is much
simpler to start with.


>
> * - what mechanism does SCADomain.newInstance use to locate the resource?
>  is it just a Class.getResource or somesuch?
>

Yes, Tuscany looks for the named file on the classpath and then uses the
directory in which it finds that file as what SCA calls the contribution.
The contribution should collect together all of the artifacts that are
required to run the composite application, e.g. the composite file itself
and the files that provide component implementations etc.


>
> Cheers,
>
> Richard
>
> --
> =======================================================================
> Richard Jones                     |       Hewlett-Packard Limited
> Research Engineer, HP Labs        |       registered office:
> Bristol, UK                       |       Cain Road, Bracknell,
>                                 |       Berks, RG12 1HN.
>                                 |       Registered No: 690597 England
> eml: richard.d.jones@hp.com       -------------------------------------
> blg: http://chronicles-of-richard.blogspot.com/
> -----------------------------------------------------------------------
> The contents of this message and any attachments to it are confidential
> and may be legally privileged. If you have received this message in
> error, you should delete it from your system immediately and advise the
> sender. To any recipient of this message within HP, unless otherwise
> stated you should consider this message and attachments as "HP
> CONFIDENTIAL".
> ========================================================================
>
>

Re: starting tuscany outside of eclipse

Posted by Richard Jones <ri...@hp.com>.
Hi Simon,

Thanks for the pointers, I've taken a trawl through some more code, and 
have a couple more questions if you don't mind ...

>> Hi Folks,
>>
>> I'm brand new to Tuscany, and I've been working my way through the
>> documentation on the website.  I don't use Eclipse, but much of the
>> documentation is geared towards using the Eclipse plugin to start the
>> tuscany application server.  I can't find documentation on how to do this
>> /without/ eclipse, can someone point me in the right direction?
>>
>> I'm trying to do the very basic "Hello World" example.
>>
>> Is there perhaps a TuscanyServlet that I can set in my own web.xml, and do
>> my normal deployment through tomcat?
>>
>> Cheers,
>>
>> Richard
>>
>>     

> Hi Richard. Welcome to Tuscany.
>
> There are a few words about how to develop an SCA application from the
> command line in [1] but it doesn't cover doing webapp development. You could
> take a look at one of the Tuscany samples that do this. For example, look in
> samples/calculator-webapp [2]. You will see that the basic layout of this
> webapp is that an SCA application (the calculator sample) is packaged as a
> webapp and a jsp is fired up and makes a call to the Calculator component
> described in the SCA composite file [3]. The web.xml file in this case
> defines a servlet filter as follows.
>   

OK, I see, it uses an SCADomain created by the TuscanyServletFilter, and 
pulls the appropriate service out of that:

SCADomain scaDomain = (SCADomain) 
application.getAttribute("org.apache.tuscany.sca.SCADomain");
CalculatorService calculatorService = 
(CalculatorService)scaDomain.getService(CalculatorService.class, 
"CalculatorServiceComponent");

So the bit I'm stuck on here is how to create the SCADomain for the 
HelloWorld example automatically:

http://tuscany.apache.org/build-your-first-web-services-with-tuscany.html

It looks as though the Eclipse plugin can take the HelloWorld.composite 
and turns it into a web application without having to add this extra 
layer of a ServletFilter and a JSP.  The differences that I can see are 
that the Calculator.composite doesn't define a service, and instead the 
TuscanyServletFilter is reading in that file and then making itself the 
effective web-service interface.  Meanwhile, the HelloWorld example has 
a different kind of definition:

<component name="HelloWorldComponent">
        <implementation.java class="hw.HelloWorldImpl"/>
        <service name="HelloWorld">
            <binding.ws uri="http://localhost:8080/HelloWorld"/>
        </service>
</component>

The Eclipse plugin looks like it understands how to take this service 
binding and turn it into an actual service.  I think what I need to know 
is how to deploy this particular type of composite definition (although 
I'm also possibly off base here).

I tried writing a Launch class as per:

http://tuscany.apache.org/getting-started-with-tuscany.html

which basically did:

public static void main(String[] args)
            throws Exception
{
        SCADomain scaDomain = SCADomain.newInstance("HelloWorld.composite");
        System.in.read();
        scaDomain.close();
}

But this is throwing exceptions:

Exception in thread "main" org.osoa.sca.ServiceRuntimeException: 
org.osoa.sca.ServiceRuntimeException: 
java.lang.IllegalArgumentException: Composite not found: 
HelloWorld.composite

That last part might be a classpath problem* which I haven't figured out 
yet, but supposing it didn't balk, is this the right approach to 
launching the application?

* - what mechanism does SCADomain.newInstance use to locate the 
resource?  is it just a Class.getResource or somesuch?

Cheers,

Richard

-- 
=======================================================================
Richard Jones                     |       Hewlett-Packard Limited
Research Engineer, HP Labs        |       registered office:
Bristol, UK                       |       Cain Road, Bracknell,
                                  |       Berks, RG12 1HN.
                                  |       Registered No: 690597 England
eml: richard.d.jones@hp.com       -------------------------------------
blg: http://chronicles-of-richard.blogspot.com/
-----------------------------------------------------------------------
The contents of this message and any attachments to it are confidential
and may be legally privileged. If you have received this message in
error, you should delete it from your system immediately and advise the
sender. To any recipient of this message within HP, unless otherwise
stated you should consider this message and attachments as "HP
CONFIDENTIAL".
========================================================================


Re: starting tuscany outside of eclipse

Posted by Raymond Feng <en...@gmail.com>.
For a better understanding of the webapp approach, please see the following 
document:

http://cwiki.apache.org/confluence/display/TUSCANYWIKI/Tuscany+Web+Application+based+Integration+with+Geronimo

Thanks,
Raymond

--------------------------------------------------
From: "Simon Laws" <si...@googlemail.com>
Sent: Thursday, June 19, 2008 7:24 AM
To: <us...@tuscany.apache.org>
Subject: Re: starting tuscany outside of eclipse

> On Thu, Jun 19, 2008 at 2:57 PM, Richard Jones <ri...@hp.com>
> wrote:
>
>> Hi Folks,
>>
>> I'm brand new to Tuscany, and I've been working my way through the
>> documentation on the website.  I don't use Eclipse, but much of the
>> documentation is geared towards using the Eclipse plugin to start the
>> tuscany application server.  I can't find documentation on how to do this
>> /without/ eclipse, can someone point me in the right direction?
>>
>> I'm trying to do the very basic "Hello World" example.
>>
>> Is there perhaps a TuscanyServlet that I can set in my own web.xml, and 
>> do
>> my normal deployment through tomcat?
>>
>> Cheers,
>>
>> Richard
>>
>> --
>> =======================================================================
>> Richard Jones                     |       Hewlett-Packard Limited
>> Research Engineer, HP Labs        |       registered office:
>> Bristol, UK                       |       Cain Road, Bracknell,
>>                                 |       Berks, RG12 1HN.
>>                                 |       Registered No: 690597 England
>> eml: richard.d.jones@hp.com       -------------------------------------
>> blg: http://chronicles-of-richard.blogspot.com/
>> -----------------------------------------------------------------------
>> The contents of this message and any attachments to it are confidential
>> and may be legally privileged. If you have received this message in
>> error, you should delete it from your system immediately and advise the
>> sender. To any recipient of this message within HP, unless otherwise
>> stated you should consider this message and attachments as "HP
>> CONFIDENTIAL".
>> ========================================================================
>>
>>
> Hi Richard. Welcome to Tuscany.
>
> There are a few words about how to develop an SCA application from the
> command line in [1] but it doesn't cover doing webapp development. You 
> could
> take a look at one of the Tuscany samples that do this. For example, look 
> in
> samples/calculator-webapp [2]. You will see that the basic layout of this
> webapp is that an SCA application (the calculator sample) is packaged as a
> webapp and a jsp is fired up and makes a call to the Calculator component
> described in the SCA composite file [3]. The web.xml file in this case
> defines a servlet filter as follows.
>
>  <filter>
>    <filter-name>tuscany</filter-name>
> 
> <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class>
>  </filter>
>
>
> You will also note that the war file for this sample includes both the
> application class and all the Tuscany jars and dependencies required to 
> run
> the sample so in theory this should run on most webapp containers.
>
> There are several other webapp samples so there may be one that is closer 
> to
> you requirements. Let us know how you get on or if you need more pointers.
>
> Regards
>
> Simon
>
> [1]
> http://tuscany.apache.org/getting-started-with-tuscany-using-the-command-line.html
> [2]
> http://svn.apache.org/repos/asf/tuscany/java/sca/samples/calculator-webapp/
> [3]
> http://svn.apache.org/repos/asf/tuscany/java/sca/samples/calculator-webapp/calculator-web.png
> 

Re: starting tuscany outside of eclipse

Posted by Simon Laws <si...@googlemail.com>.
On Thu, Jun 19, 2008 at 2:57 PM, Richard Jones <ri...@hp.com>
wrote:

> Hi Folks,
>
> I'm brand new to Tuscany, and I've been working my way through the
> documentation on the website.  I don't use Eclipse, but much of the
> documentation is geared towards using the Eclipse plugin to start the
> tuscany application server.  I can't find documentation on how to do this
> /without/ eclipse, can someone point me in the right direction?
>
> I'm trying to do the very basic "Hello World" example.
>
> Is there perhaps a TuscanyServlet that I can set in my own web.xml, and do
> my normal deployment through tomcat?
>
> Cheers,
>
> Richard
>
> --
> =======================================================================
> Richard Jones                     |       Hewlett-Packard Limited
> Research Engineer, HP Labs        |       registered office:
> Bristol, UK                       |       Cain Road, Bracknell,
>                                 |       Berks, RG12 1HN.
>                                 |       Registered No: 690597 England
> eml: richard.d.jones@hp.com       -------------------------------------
> blg: http://chronicles-of-richard.blogspot.com/
> -----------------------------------------------------------------------
> The contents of this message and any attachments to it are confidential
> and may be legally privileged. If you have received this message in
> error, you should delete it from your system immediately and advise the
> sender. To any recipient of this message within HP, unless otherwise
> stated you should consider this message and attachments as "HP
> CONFIDENTIAL".
> ========================================================================
>
>
Hi Richard. Welcome to Tuscany.

There are a few words about how to develop an SCA application from the
command line in [1] but it doesn't cover doing webapp development. You could
take a look at one of the Tuscany samples that do this. For example, look in
samples/calculator-webapp [2]. You will see that the basic layout of this
webapp is that an SCA application (the calculator sample) is packaged as a
webapp and a jsp is fired up and makes a call to the Calculator component
described in the SCA composite file [3]. The web.xml file in this case
defines a servlet filter as follows.

  <filter>
    <filter-name>tuscany</filter-name>
    <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class>
  </filter>


You will also note that the war file for this sample includes both the
application class and all the Tuscany jars and dependencies required to run
the sample so in theory this should run on most webapp containers.

There are several other webapp samples so there may be one that is closer to
you requirements. Let us know how you get on or if you need more pointers.

Regards

Simon

[1]
http://tuscany.apache.org/getting-started-with-tuscany-using-the-command-line.html
[2]
http://svn.apache.org/repos/asf/tuscany/java/sca/samples/calculator-webapp/
[3]
http://svn.apache.org/repos/asf/tuscany/java/sca/samples/calculator-webapp/calculator-web.png