You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by ant elder <an...@gmail.com> on 2009/05/26 15:00:34 UTC

Tuscany Tomcat integration

I've started looking at Tuscany integration with Tomcat again and
created a new 2.x tomcat distribution in the distribution/tomcat
folder. That creates a war that can be deployed into Tomcat which
makes embedding Tuscany into Tomcat really easy - just deploy the war,
go to http://localhost:8080/tuscany and click install, and then
restart Tomcat. Thats it, and then you can use SCA in web applications
without needing to include the Tuscany runtime with each web
application.

If you want to give it a try without building it yourself the
tuscany.war is available at:
http://people.apache.org/~antelder/tuscany/tomcat/tuscany.war
and there is a helloworld sample which uses SCA without including
Tuscany at: http://people.apache.org/~antelder/tuscany/tomcat/sample-helloworld-jsp.war

This seems quite cool to me, and with potential for helping with lots
of things in 2.x such as using multiple Nodes, endpoints, dynamic
domains, backward compatibility etc. It also helps with making
portable samples that can easily be used in other SCA runtimes because
as the samples don't need to include Tuscany they should run as-is on
Tomact, or Geronimo with the Tuscany plugin, or WebSphere, etc.

Comments?

   ...ant

Re: Tuscany Tomcat integration

Posted by ant elder <an...@apache.org>.
Its an interesting idea, I'm not sure, i mean yes we could easily
enough but i'm not sure how practical it would be as I can't find any
way to avoid needing the server restart afterwards. I guess there
could be messages output to the system console saying now you need to
restart but it might be easy to miss, at least with needing to go to
the install page and clicking a button we know the user is aware of
whats going on.

   ...ant

On Wed, May 27, 2009 at 6:43 PM, Raymond Feng <en...@gmail.com> wrote:
> Can we automatically install the Tuscany when the tuscany.war is started for
> the first time?
>
> Thanks,
> Raymond
> --------------------------------------------------
> From: "ant elder" <an...@apache.org>
> Sent: Wednesday, May 27, 2009 12:03 AM
> To: <de...@tuscany.apache.org>
> Subject: Re: Tuscany Tomcat integration
>
>> On Tue, May 26, 2009 at 6:28 PM, ant elder <an...@apache.org> wrote:
>>>
>>> On Tue, May 26, 2009 at 5:49 PM, Raymond Feng <en...@gmail.com>
>>> wrote:
>>>>
>>>> See my comments inline.
>>>>
>>>> --------------------------------------------------
>>>> From: "ant elder" <an...@apache.org>
>>>> Sent: Tuesday, May 26, 2009 6:56 AM
>>>> To: <de...@tuscany.apache.org>
>>>> Subject: Re: Tuscany Tomcat integration
>>>>
>>>> [[snip]]
>>>>
>>>>>
>>>>> The tuscany.war includes the Tuscany runtime inside the webapp but in
>>>>> separate folders (tomcat-lib and tuscan-lib) and clicking the install
>>>>> button updates the tomcat conf/server.xml file to add those folders to
>>>>> the tomcat system classpath and adds a tuscany lifecycle listener to
>>>>> the tomcat runtime. Then when webapps are being started Tuscany
>>>>> intercepts the start and looks for the presence of a web.composite or
>>>>> sca-contribution.xml in the webapp and if so dynamically adds the
>>>>> tuscany runtime jars to the webapp classpath and adds the Tuscany
>>>>> listener and filter to the webapp.
>>>>
>>>> Using a webapp to install/uninstall sounds interesting.
>>>>
>>>> If the jars are added to the system classpath, why do we have to update
>>>> the
>>>> webapp classpath? Are the Tuscany classes shared by all of the webapps
>>>> or
>>>> each webapp has their own copy (separate classloader)?
>>>>
>>>
>>> The tuscany runtime jars are not on the system or shared classpath,
>>> only the one tuscany-tomcat-hook jar in the tuscany webapp tomcat-lib
>>> folder is on the tomcat system classpath, the jars in the tuscany-lib
>>> get added to the application classpath only for sca enabled webapps.
>>>
>>>> http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html
>>>>
>>>>>
>>>>> The result of that is just the same as if the webapp had included the
>>>>> tuscany jars within its web-inf/lib and had the Tuscany listener and
>>>>> filter defined in its web.xml. So right now that means a sinlge
>>>>> standalone Node is started for each webapp just the same as with the
>>>>> existing Tuscany webapp support.
>>>>
>>>> With the recent enhancement that multiple nodes can be started in the
>>>> same
>>>> JVM, we can install the Tuscany jars into the Tomcat common lib so that
>>>> the
>>>> runtime can be shared by the webapps.
>>>>
>>>
>>> Yes that can be done (and it also works with the old 1.x webapp
>>> support) but its a different scenario. That just means there's only
>>> one copy of the tuscany jars but each webapp still needs to be
>>> "tuscany enabled", ie have each web.xml include the tuscany specific
>>> listener and filter definitions, and it has the limitation that we
>>> can't do SCA injection into JEE artifacts like servlets which the deep
>>> integration will allow.
>>>
>>>  ...ant
>>>
>>
>> And of course the other big benefit of this is that it provides a
>> useful place to work on the domain story - having multiple Nodes wired
>> together so you can have sca references in one webapp wired to sca
>> services in another webapp or sca contribution. Thats something users
>> have ask for several times, and it would be a much more useful and
>> compelling demonstration of the sca domain than just a couple of JSE
>> nodes talking to each other.
>>
>> What i'd like to get to with this would be to have the this
>> tuscany.war include a domain manager application along with the
>> installer app, and to be able to create and manage domains, install
>> sca contributions, and assign sca webapps to domains. It would also be
>> nice if the tuscany.war web pages looked like the Tuscany website
>> pages so use the tuscany website CSS etc. If anyone would like to help
>> with any of this that would be wonderful and i'd be happy to help you
>> get started.
>>
>>  ...ant
>
>

Re: Tuscany Tomcat integration

Posted by Raymond Feng <en...@gmail.com>.
Can we automatically install the Tuscany when the tuscany.war is started for 
the first time?

Thanks,
Raymond
--------------------------------------------------
From: "ant elder" <an...@apache.org>
Sent: Wednesday, May 27, 2009 12:03 AM
To: <de...@tuscany.apache.org>
Subject: Re: Tuscany Tomcat integration

> On Tue, May 26, 2009 at 6:28 PM, ant elder <an...@apache.org> wrote:
>> On Tue, May 26, 2009 at 5:49 PM, Raymond Feng <en...@gmail.com> 
>> wrote:
>>> See my comments inline.
>>>
>>> --------------------------------------------------
>>> From: "ant elder" <an...@apache.org>
>>> Sent: Tuesday, May 26, 2009 6:56 AM
>>> To: <de...@tuscany.apache.org>
>>> Subject: Re: Tuscany Tomcat integration
>>>
>>> [[snip]]
>>>
>>>>
>>>> The tuscany.war includes the Tuscany runtime inside the webapp but in
>>>> separate folders (tomcat-lib and tuscan-lib) and clicking the install
>>>> button updates the tomcat conf/server.xml file to add those folders to
>>>> the tomcat system classpath and adds a tuscany lifecycle listener to
>>>> the tomcat runtime. Then when webapps are being started Tuscany
>>>> intercepts the start and looks for the presence of a web.composite or
>>>> sca-contribution.xml in the webapp and if so dynamically adds the
>>>> tuscany runtime jars to the webapp classpath and adds the Tuscany
>>>> listener and filter to the webapp.
>>>
>>> Using a webapp to install/uninstall sounds interesting.
>>>
>>> If the jars are added to the system classpath, why do we have to update 
>>> the
>>> webapp classpath? Are the Tuscany classes shared by all of the webapps 
>>> or
>>> each webapp has their own copy (separate classloader)?
>>>
>>
>> The tuscany runtime jars are not on the system or shared classpath,
>> only the one tuscany-tomcat-hook jar in the tuscany webapp tomcat-lib
>> folder is on the tomcat system classpath, the jars in the tuscany-lib
>> get added to the application classpath only for sca enabled webapps.
>>
>>> http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html
>>>
>>>>
>>>> The result of that is just the same as if the webapp had included the
>>>> tuscany jars within its web-inf/lib and had the Tuscany listener and
>>>> filter defined in its web.xml. So right now that means a sinlge
>>>> standalone Node is started for each webapp just the same as with the
>>>> existing Tuscany webapp support.
>>>
>>> With the recent enhancement that multiple nodes can be started in the 
>>> same
>>> JVM, we can install the Tuscany jars into the Tomcat common lib so that 
>>> the
>>> runtime can be shared by the webapps.
>>>
>>
>> Yes that can be done (and it also works with the old 1.x webapp
>> support) but its a different scenario. That just means there's only
>> one copy of the tuscany jars but each webapp still needs to be
>> "tuscany enabled", ie have each web.xml include the tuscany specific
>> listener and filter definitions, and it has the limitation that we
>> can't do SCA injection into JEE artifacts like servlets which the deep
>> integration will allow.
>>
>>   ...ant
>>
>
> And of course the other big benefit of this is that it provides a
> useful place to work on the domain story - having multiple Nodes wired
> together so you can have sca references in one webapp wired to sca
> services in another webapp or sca contribution. Thats something users
> have ask for several times, and it would be a much more useful and
> compelling demonstration of the sca domain than just a couple of JSE
> nodes talking to each other.
>
> What i'd like to get to with this would be to have the this
> tuscany.war include a domain manager application along with the
> installer app, and to be able to create and manage domains, install
> sca contributions, and assign sca webapps to domains. It would also be
> nice if the tuscany.war web pages looked like the Tuscany website
> pages so use the tuscany website CSS etc. If anyone would like to help
> with any of this that would be wonderful and i'd be happy to help you
> get started.
>
>   ...ant 


Re: Tuscany Tomcat integration

Posted by ant elder <an...@apache.org>.
On Tue, May 26, 2009 at 6:28 PM, ant elder <an...@apache.org> wrote:
> On Tue, May 26, 2009 at 5:49 PM, Raymond Feng <en...@gmail.com> wrote:
>> See my comments inline.
>>
>> --------------------------------------------------
>> From: "ant elder" <an...@apache.org>
>> Sent: Tuesday, May 26, 2009 6:56 AM
>> To: <de...@tuscany.apache.org>
>> Subject: Re: Tuscany Tomcat integration
>>
>> [[snip]]
>>
>>>
>>> The tuscany.war includes the Tuscany runtime inside the webapp but in
>>> separate folders (tomcat-lib and tuscan-lib) and clicking the install
>>> button updates the tomcat conf/server.xml file to add those folders to
>>> the tomcat system classpath and adds a tuscany lifecycle listener to
>>> the tomcat runtime. Then when webapps are being started Tuscany
>>> intercepts the start and looks for the presence of a web.composite or
>>> sca-contribution.xml in the webapp and if so dynamically adds the
>>> tuscany runtime jars to the webapp classpath and adds the Tuscany
>>> listener and filter to the webapp.
>>
>> Using a webapp to install/uninstall sounds interesting.
>>
>> If the jars are added to the system classpath, why do we have to update the
>> webapp classpath? Are the Tuscany classes shared by all of the webapps or
>> each webapp has their own copy (separate classloader)?
>>
>
> The tuscany runtime jars are not on the system or shared classpath,
> only the one tuscany-tomcat-hook jar in the tuscany webapp tomcat-lib
> folder is on the tomcat system classpath, the jars in the tuscany-lib
> get added to the application classpath only for sca enabled webapps.
>
>> http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html
>>
>>>
>>> The result of that is just the same as if the webapp had included the
>>> tuscany jars within its web-inf/lib and had the Tuscany listener and
>>> filter defined in its web.xml. So right now that means a sinlge
>>> standalone Node is started for each webapp just the same as with the
>>> existing Tuscany webapp support.
>>
>> With the recent enhancement that multiple nodes can be started in the same
>> JVM, we can install the Tuscany jars into the Tomcat common lib so that the
>> runtime can be shared by the webapps.
>>
>
> Yes that can be done (and it also works with the old 1.x webapp
> support) but its a different scenario. That just means there's only
> one copy of the tuscany jars but each webapp still needs to be
> "tuscany enabled", ie have each web.xml include the tuscany specific
> listener and filter definitions, and it has the limitation that we
> can't do SCA injection into JEE artifacts like servlets which the deep
> integration will allow.
>
>   ...ant
>

And of course the other big benefit of this is that it provides a
useful place to work on the domain story - having multiple Nodes wired
together so you can have sca references in one webapp wired to sca
services in another webapp or sca contribution. Thats something users
have ask for several times, and it would be a much more useful and
compelling demonstration of the sca domain than just a couple of JSE
nodes talking to each other.

What i'd like to get to with this would be to have the this
tuscany.war include a domain manager application along with the
installer app, and to be able to create and manage domains, install
sca contributions, and assign sca webapps to domains. It would also be
nice if the tuscany.war web pages looked like the Tuscany website
pages so use the tuscany website CSS etc. If anyone would like to help
with any of this that would be wonderful and i'd be happy to help you
get started.

   ...ant

Re: Tuscany Tomcat integration

Posted by Raymond Feng <en...@gmail.com>.
It seems the hook is not tolerating the case where the webapp is already 
configured with Tuscany listener/filter and packaged with Tuscany jars. I 
got the following error as I already have the helloworld webapp installed 
before adding tuscany.war.

May 27, 2009 9:43:01 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
May 27, 2009 9:43:01 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
May 27, 2009 9:43:37 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
May 27, 2009 9:43:37 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()
May 27, 2009 9:43:47 AM org.apache.catalina.core.StandardContext 
listenerStart
SEVERE: Exception sending context initialized event to listener instance of 
class org.apache.tuscany.sca.host.webapp.TuscanyContextListener
java.lang.IllegalStateException: 
org.apache.tuscany.sca.contribution.processor.ContributionResolveException: 
org.apache.tuscany.sca.implementation.java.introspect.impl.DuplicateInitException: 
More than one initializer found on implementaton
	at org.apache.tuscany.sca.node.impl.NodeImpl.start(NodeImpl.java:89)
	at 
org.apache.tuscany.sca.host.webapp.ServletHostHelper.createNode(ServletHostHelper.java:172)
	at 
org.apache.tuscany.sca.host.webapp.ServletHostHelper.init(ServletHostHelper.java:124)
	at 
org.apache.tuscany.sca.host.webapp.TuscanyContextListener.contextInitialized(TuscanyContextListener.java:33)
	at 
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
	at 
org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
	at 
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
	at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:830)
	at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:719)
	at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490)
	at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
	at 
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
	at 
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
	at org.apache.catalina.core.StandardService.start(StandardService.java:516)
	at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: 
org.apache.tuscany.sca.contribution.processor.ContributionResolveException: 
org.apache.tuscany.sca.implementation.java.introspect.impl.DuplicateInitException: 
More than one initializer found on implementaton
	at 
org.apache.tuscany.sca.implementation.java.xml.JavaImplementationProcessor.resolve(JavaImplementationProcessor.java:185)
	at 
org.apache.tuscany.sca.implementation.java.xml.JavaImplementationProcessor.resolve(JavaImplementationProcessor.java:1)
	at 
org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint$LazyStAXArtifactProcessor.resolve(DefaultStAXArtifactProcessorExtensionPoint.java:416)
	at 
org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor.resolve(ExtensibleStAXArtifactProcessor.java:196)
	at 
org.apache.tuscany.sca.assembly.xml.BaseAssemblyProcessor.resolveImplementation(BaseAssemblyProcessor.java:353)
	at 
org.apache.tuscany.sca.assembly.xml.CompositeProcessor.resolve(CompositeProcessor.java:991)
	at 
org.apache.tuscany.sca.assembly.xml.CompositeProcessor.resolve(CompositeProcessor.java:1)
	at 
org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint$LazyStAXArtifactProcessor.resolve(DefaultStAXArtifactProcessorExtensionPoint.java:416)
	at 
org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor.resolve(ExtensibleStAXArtifactProcessor.java:196)
	at 
org.apache.tuscany.sca.assembly.xml.CompositeDocumentProcessor.resolve(CompositeDocumentProcessor.java:167)
	at 
org.apache.tuscany.sca.assembly.xml.CompositeDocumentProcessor.resolve(CompositeDocumentProcessor.java:1)
	at 
org.apache.tuscany.sca.contribution.processor.DefaultURLArtifactProcessorExtensionPoint$LazyURLArtifactProcessor.resolve(DefaultURLArtifactProcessorExtensionPoint.java:357)
	at 
org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor.resolve(ExtensibleURLArtifactProcessor.java:121)
	at 
org.apache.tuscany.sca.contribution.processor.impl.ContributionContentProcessor.resolve(ContributionContentProcessor.java:216)
	at 
org.apache.tuscany.sca.contribution.processor.impl.ContributionContentProcessor.resolve(ContributionContentProcessor.java:1)
	at 
org.apache.tuscany.sca.contribution.processor.DefaultURLArtifactProcessorExtensionPoint$LazyURLArtifactProcessor.resolve(DefaultURLArtifactProcessorExtensionPoint.java:357)
	at 
org.apache.tuscany.sca.node.impl.NodeFactoryImpl.configureNode(NodeFactoryImpl.java:581)
	at org.apache.tuscany.sca.node.impl.NodeImpl.start(NodeImpl.java:75)
	... 27 more
Caused by: 
org.apache.tuscany.sca.implementation.java.introspect.impl.DuplicateInitException: 
More than one initializer found on implementaton
	at 
org.apache.tuscany.sca.implementation.java.introspect.impl.InitProcessor.visitMethod(InitProcessor.java:55)
	at 
org.apache.tuscany.sca.implementation.java.impl.JavaClassIntrospectorImpl.introspectClass(JavaClassIntrospectorImpl.java:109)
	at 
org.apache.tuscany.sca.implementation.java.impl.JavaImplementationFactoryImpl.createJavaImplementation(JavaImplementationFactoryImpl.java:55)
	at 
org.apache.tuscany.sca.implementation.java.xml.JavaImplementationProcessor.resolve(JavaImplementationProcessor.java:183)
	... 44 more
May 27, 2009 9:43:47 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
May 27, 2009 9:43:47 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()


--------------------------------------------------
From: "ant elder" <an...@apache.org>
Sent: Tuesday, May 26, 2009 11:43 PM
To: <de...@tuscany.apache.org>
Subject: Re: Tuscany Tomcat integration

> On Tue, May 26, 2009 at 6:28 PM, ant elder <an...@apache.org> wrote:
>
>> and it has the limitation that we
>> can't do SCA injection into JEE artifacts like servlets which the deep
>> integration will allow.
>>
>
> FYI in r779023 i've added this injection support so you can now use
> SCA annotations in things like Servlets, and added a
> helloworld-servlet example to demonstrate this.
>
>   ...ant 


Re: Tuscany Tomcat integration

Posted by ant elder <an...@apache.org>.
On Tue, May 26, 2009 at 6:28 PM, ant elder <an...@apache.org> wrote:

> and it has the limitation that we
> can't do SCA injection into JEE artifacts like servlets which the deep
> integration will allow.
>

FYI in r779023 i've added this injection support so you can now use
SCA annotations in things like Servlets, and added a
helloworld-servlet example to demonstrate this.

   ...ant

Re: Tuscany Tomcat integration

Posted by ant elder <an...@apache.org>.
On Tue, May 26, 2009 at 5:49 PM, Raymond Feng <en...@gmail.com> wrote:
> See my comments inline.
>
> --------------------------------------------------
> From: "ant elder" <an...@apache.org>
> Sent: Tuesday, May 26, 2009 6:56 AM
> To: <de...@tuscany.apache.org>
> Subject: Re: Tuscany Tomcat integration
>
> [[snip]]
>
>>
>> The tuscany.war includes the Tuscany runtime inside the webapp but in
>> separate folders (tomcat-lib and tuscan-lib) and clicking the install
>> button updates the tomcat conf/server.xml file to add those folders to
>> the tomcat system classpath and adds a tuscany lifecycle listener to
>> the tomcat runtime. Then when webapps are being started Tuscany
>> intercepts the start and looks for the presence of a web.composite or
>> sca-contribution.xml in the webapp and if so dynamically adds the
>> tuscany runtime jars to the webapp classpath and adds the Tuscany
>> listener and filter to the webapp.
>
> Using a webapp to install/uninstall sounds interesting.
>
> If the jars are added to the system classpath, why do we have to update the
> webapp classpath? Are the Tuscany classes shared by all of the webapps or
> each webapp has their own copy (separate classloader)?
>

The tuscany runtime jars are not on the system or shared classpath,
only the one tuscany-tomcat-hook jar in the tuscany webapp tomcat-lib
folder is on the tomcat system classpath, the jars in the tuscany-lib
get added to the application classpath only for sca enabled webapps.

> http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html
>
>>
>> The result of that is just the same as if the webapp had included the
>> tuscany jars within its web-inf/lib and had the Tuscany listener and
>> filter defined in its web.xml. So right now that means a sinlge
>> standalone Node is started for each webapp just the same as with the
>> existing Tuscany webapp support.
>
> With the recent enhancement that multiple nodes can be started in the same
> JVM, we can install the Tuscany jars into the Tomcat common lib so that the
> runtime can be shared by the webapps.
>

Yes that can be done (and it also works with the old 1.x webapp
support) but its a different scenario. That just means there's only
one copy of the tuscany jars but each webapp still needs to be
"tuscany enabled", ie have each web.xml include the tuscany specific
listener and filter definitions, and it has the limitation that we
can't do SCA injection into JEE artifacts like servlets which the deep
integration will allow.

   ...ant

Re: Tuscany Tomcat integration

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

--------------------------------------------------
From: "ant elder" <an...@apache.org>
Sent: Tuesday, May 26, 2009 6:56 AM
To: <de...@tuscany.apache.org>
Subject: Re: Tuscany Tomcat integration

[[snip]]

>
> The tuscany.war includes the Tuscany runtime inside the webapp but in
> separate folders (tomcat-lib and tuscan-lib) and clicking the install
> button updates the tomcat conf/server.xml file to add those folders to
> the tomcat system classpath and adds a tuscany lifecycle listener to
> the tomcat runtime. Then when webapps are being started Tuscany
> intercepts the start and looks for the presence of a web.composite or
> sca-contribution.xml in the webapp and if so dynamically adds the
> tuscany runtime jars to the webapp classpath and adds the Tuscany
> listener and filter to the webapp.

Using a webapp to install/uninstall sounds interesting.

If the jars are added to the system classpath, why do we have to update the 
webapp classpath? Are the Tuscany classes shared by all of the webapps or 
each webapp has their own copy (separate classloader)?

http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html

>
> The result of that is just the same as if the webapp had included the
> tuscany jars within its web-inf/lib and had the Tuscany listener and
> filter defined in its web.xml. So right now that means a sinlge
> standalone Node is started for each webapp just the same as with the
> existing Tuscany webapp support.

With the recent enhancement that multiple nodes can be started in the same 
JVM, we can install the Tuscany jars into the Tomcat common lib so that the 
runtime can be shared by the webapps.

>
> With that in place we could now start to change the way this works and
> how the Nodes are used. For example, the tuscany webapp could include
> both 1.x and 2.x runtimes and configure webapps to use either
> depending on the namespace of the sca-contributions.xml file. We could
> add some sca domain configuration to Tomcat so webapps get associated
> with a domain and have the Node configured to be part of that domain,
> and use the endpoint facilities to do cross webapp wiring of sca
> services and references.
>
>  ...ant 


Re: Tuscany Tomcat integration

Posted by ant elder <an...@apache.org>.
On Tue, May 26, 2009 at 2:38 PM, Simon Laws <si...@googlemail.com> wrote:
> On Tue, May 26, 2009 at 2:00 PM, ant elder <an...@gmail.com> wrote:
>> I've started looking at Tuscany integration with Tomcat again and
>> created a new 2.x tomcat distribution in the distribution/tomcat
>> folder. That creates a war that can be deployed into Tomcat which
>> makes embedding Tuscany into Tomcat really easy - just deploy the war,
>> go to http://localhost:8080/tuscany and click install, and then
>> restart Tomcat. Thats it, and then you can use SCA in web applications
>> without needing to include the Tuscany runtime with each web
>> application.
>>
>> If you want to give it a try without building it yourself the
>> tuscany.war is available at:
>> http://people.apache.org/~antelder/tuscany/tomcat/tuscany.war
>> and there is a helloworld sample which uses SCA without including
>> Tuscany at: http://people.apache.org/~antelder/tuscany/tomcat/sample-helloworld-jsp.war
>>
>> This seems quite cool to me, and with potential for helping with lots
>> of things in 2.x such as using multiple Nodes, endpoints, dynamic
>> domains, backward compatibility etc. It also helps with making
>> portable samples that can easily be used in other SCA runtimes because
>> as the samples don't need to include Tuscany they should run as-is on
>> Tomact, or Geronimo with the Tuscany plugin, or WebSphere, etc.
>>
>> Comments?
>>
>>   ...ant
>>
>
> Hi Ant
>
> Interesting. Can you say something about what is happening under the
> covers? For example, what is the mapping between deployed wars and
> Tuscany nodes?
>
> Simon
>

The tuscany.war includes the Tuscany runtime inside the webapp but in
separate folders (tomcat-lib and tuscan-lib) and clicking the install
button updates the tomcat conf/server.xml file to add those folders to
the tomcat system classpath and adds a tuscany lifecycle listener to
the tomcat runtime. Then when webapps are being started Tuscany
intercepts the start and looks for the presence of a web.composite or
sca-contribution.xml in the webapp and if so dynamically adds the
tuscany runtime jars to the webapp classpath and adds the Tuscany
listener and filter to the webapp.

The result of that is just the same as if the webapp had included the
tuscany jars within its web-inf/lib and had the Tuscany listener and
filter defined in its web.xml. So right now that means a sinlge
standalone Node is started for each webapp just the same as with the
existing Tuscany webapp support.

With that in place we could now start to change the way this works and
how the Nodes are used. For example, the tuscany webapp could include
both 1.x and 2.x runtimes and configure webapps to use either
depending on the namespace of the sca-contributions.xml file. We could
add some sca domain configuration to Tomcat so webapps get associated
with a domain and have the Node configured to be part of that domain,
and use the endpoint facilities to do cross webapp wiring of sca
services and references.

  ...ant

Re: Tuscany Tomcat integration

Posted by Simon Laws <si...@googlemail.com>.
On Tue, May 26, 2009 at 2:00 PM, ant elder <an...@gmail.com> wrote:
> I've started looking at Tuscany integration with Tomcat again and
> created a new 2.x tomcat distribution in the distribution/tomcat
> folder. That creates a war that can be deployed into Tomcat which
> makes embedding Tuscany into Tomcat really easy - just deploy the war,
> go to http://localhost:8080/tuscany and click install, and then
> restart Tomcat. Thats it, and then you can use SCA in web applications
> without needing to include the Tuscany runtime with each web
> application.
>
> If you want to give it a try without building it yourself the
> tuscany.war is available at:
> http://people.apache.org/~antelder/tuscany/tomcat/tuscany.war
> and there is a helloworld sample which uses SCA without including
> Tuscany at: http://people.apache.org/~antelder/tuscany/tomcat/sample-helloworld-jsp.war
>
> This seems quite cool to me, and with potential for helping with lots
> of things in 2.x such as using multiple Nodes, endpoints, dynamic
> domains, backward compatibility etc. It also helps with making
> portable samples that can easily be used in other SCA runtimes because
> as the samples don't need to include Tuscany they should run as-is on
> Tomact, or Geronimo with the Tuscany plugin, or WebSphere, etc.
>
> Comments?
>
>   ...ant
>

Hi Ant

Interesting. Can you say something about what is happening under the
covers? For example, what is the mapping between deployed wars and
Tuscany nodes?

Simon