<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Using a shared parent application context in a multi-war Spring application</title>
	<atom:link href="http://blog.springsource.com/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.springsource.com/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/</link>
	<description>The voice of SpringSource</description>
	<lastBuildDate>Wed, 17 Mar 2010 01:53:19 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Joel</title>
		<link>http://blog.springsource.com/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/comment-page-2/#comment-171476</link>
		<dc:creator>Joel</dc:creator>
		<pubDate>Wed, 03 Mar 2010 18:50:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/#comment-171476</guid>
		<description>The code also appears to work fine on WebSphere 7.0.</description>
		<content:encoded><![CDATA[<p>The code also appears to work fine on WebSphere 7.0.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joel</title>
		<link>http://blog.springsource.com/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/comment-page-2/#comment-171473</link>
		<dc:creator>Joel</dc:creator>
		<pubDate>Wed, 03 Mar 2010 17:50:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/#comment-171473</guid>
		<description>Concur with above comment.  Works fine on JBoss 4.2.3 and fails on JBoss 5.1.</description>
		<content:encoded><![CDATA[<p>Concur with above comment.  Works fine on JBoss 4.2.3 and fails on JBoss 5.1.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Berkay</title>
		<link>http://blog.springsource.com/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/comment-page-2/#comment-171264</link>
		<dc:creator>Berkay</dc:creator>
		<pubDate>Sun, 07 Feb 2010 14:45:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/#comment-171264</guid>
		<description>doesnt work in jboss 5.x enviroment..</description>
		<content:encoded><![CDATA[<p>doesnt work in jboss 5.x enviroment..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jürgen</title>
		<link>http://blog.springsource.com/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/comment-page-2/#comment-170253</link>
		<dc:creator>Jürgen</dc:creator>
		<pubDate>Sun, 13 Dec 2009 22:55:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/#comment-170253</guid>
		<description>Hi Joris,
I managed to deploy and reproduce your your example in Glassfish 2.1.
Unfortunately, the situation in Glassfish v3 (final) is quite different.
I&#039;m facing different object ids in both web apps.

Are you aware of any difference in both versions, concerning e.g. classloader hierarchy?

Thanks in advance
Jürgen</description>
		<content:encoded><![CDATA[<p>Hi Joris,<br />
I managed to deploy and reproduce your your example in Glassfish 2.1.<br />
Unfortunately, the situation in Glassfish v3 (final) is quite different.<br />
I&#039;m facing different object ids in both web apps.</p>
<p>Are you aware of any difference in both versions, concerning e.g. classloader hierarchy?</p>
<p>Thanks in advance<br />
Jürgen</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joris Kuipers</title>
		<link>http://blog.springsource.com/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/comment-page-2/#comment-169431</link>
		<dc:creator>Joris Kuipers</dc:creator>
		<pubDate>Fri, 13 Nov 2009 12:21:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/#comment-169431</guid>
		<description>Hi Andrew,

if you&#039;d want to share instances across ears, they would need to be loaded by a classloader that is a parent of all ears: not something you could achieve by deploying a &#039;master ear&#039;, I&#039;d say. This not being possible has nothing to do with Spring, it has to do with the J2EE architecture your server uses. 
In fact, OSGi with its services registry sounds like the perfect solution to what you&#039;re trying to achieve; doesn&#039;t JBoss have something as well with its new microkernel in this space?</description>
		<content:encoded><![CDATA[<p>Hi Andrew,</p>
<p>if you&#039;d want to share instances across ears, they would need to be loaded by a classloader that is a parent of all ears: not something you could achieve by deploying a &#039;master ear&#039;, I&#039;d say. This not being possible has nothing to do with Spring, it has to do with the J2EE architecture your server uses.<br />
In fact, OSGi with its services registry sounds like the perfect solution to what you&#039;re trying to achieve; doesn&#039;t JBoss have something as well with its new microkernel in this space?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://blog.springsource.com/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/comment-page-2/#comment-169382</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Fri, 06 Nov 2009 22:23:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/#comment-169382</guid>
		<description>Hi Joris, thanks for the great post.  I have this example working with a single ear and multiple wars contained in the ear.  That works ok for some things, but what we are running into (and have been able to work around in the J2EE realm) is that we have many developers deploying to a single jboss instance.  Therefore, we typically like to be able to isolate our applications (war/ears) from each other.  So what we would like to do is deploy a single ear that contains a core set of services (DOAs, main services that most things will depend on) and then allow each developer create services that just depend on those and deploy them separately from the main ear.  So we would have mainStuff.ear and simpleService.war and simpleService.war would want a reference to the application context exposed by mainStuff.ear (i.e. ear.context in your example).  This setup additionally allows us to hot deploy sub-services without having to disturb the main/core set of services.  I can&#039;t figure out how to make this work.  Do you have any hints, or is this simply not possible with Spring?  Let me know if that doesn&#039;t make sense.</description>
		<content:encoded><![CDATA[<p>Hi Joris, thanks for the great post.  I have this example working with a single ear and multiple wars contained in the ear.  That works ok for some things, but what we are running into (and have been able to work around in the J2EE realm) is that we have many developers deploying to a single jboss instance.  Therefore, we typically like to be able to isolate our applications (war/ears) from each other.  So what we would like to do is deploy a single ear that contains a core set of services (DOAs, main services that most things will depend on) and then allow each developer create services that just depend on those and deploy them separately from the main ear.  So we would have mainStuff.ear and simpleService.war and simpleService.war would want a reference to the application context exposed by mainStuff.ear (i.e. ear.context in your example).  This setup additionally allows us to hot deploy sub-services without having to disturb the main/core set of services.  I can&#039;t figure out how to make this work.  Do you have any hints, or is this simply not possible with Spring?  Let me know if that doesn&#039;t make sense.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joris Kuipers</title>
		<link>http://blog.springsource.com/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/comment-page-2/#comment-167692</link>
		<dc:creator>Joris Kuipers</dc:creator>
		<pubDate>Sat, 25 Jul 2009 07:03:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/#comment-167692</guid>
		<description>&quot;If I package multiple WARS in one EAR will this allow me to share one security context, thus essentially having SSO across all the web applications?&quot;

Unfortunately it&#039;s not that simple: by default, the SecurityContextHolder is populated with a SecurityContext that&#039;s stored in the HttpSession between requests. Each WAR will still have its own HttpSession, even though it can share a single WebApplicationContext as its parent context, so you&#039;d need either a true SSO mechanism or a different storage location for the SecurityContext than the HttpSession, one that&#039;s shared between all WARs in the EAR on a per-user basis. This could be a singleton Map keyed on a shared cookie, for example, but you would also need to write a custom ServletFilter to replace the standard HttpSessionContextIntegrationFilter to actually use that. Haven&#039;t tried that myself, but I&#039;m sure it wouldn&#039;t be too hard to come up with something that does the job.</description>
		<content:encoded><![CDATA[<p>&#034;If I package multiple WARS in one EAR will this allow me to share one security context, thus essentially having SSO across all the web applications?&#034;</p>
<p>Unfortunately it&#039;s not that simple: by default, the SecurityContextHolder is populated with a SecurityContext that&#039;s stored in the HttpSession between requests. Each WAR will still have its own HttpSession, even though it can share a single WebApplicationContext as its parent context, so you&#039;d need either a true SSO mechanism or a different storage location for the SecurityContext than the HttpSession, one that&#039;s shared between all WARs in the EAR on a per-user basis. This could be a singleton Map keyed on a shared cookie, for example, but you would also need to write a custom ServletFilter to replace the standard HttpSessionContextIntegrationFilter to actually use that. Haven&#039;t tried that myself, but I&#039;m sure it wouldn&#039;t be too hard to come up with something that does the job.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://blog.springsource.com/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/comment-page-2/#comment-167690</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Sat, 25 Jul 2009 00:04:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/#comment-167690</guid>
		<description>This has very interesting possibilities.  I am curious if anyone has tried using this with Spring Security.  If I package multiple WARS in one EAR will this allow me to share one security context, thus essentially having SSO across all the web applications?</description>
		<content:encoded><![CDATA[<p>This has very interesting possibilities.  I am curious if anyone has tried using this with Spring Security.  If I package multiple WARS in one EAR will this allow me to share one security context, thus essentially having SSO across all the web applications?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joris Kuipers</title>
		<link>http://blog.springsource.com/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/comment-page-2/#comment-165481</link>
		<dc:creator>Joris Kuipers</dc:creator>
		<pubDate>Wed, 06 May 2009 18:31:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/#comment-165481</guid>
		<description>You should think about what it means to share a domain layer first: typically I&#039;d say it involves sharing *types* (classes, mostly) and not *instances*. You can easily do that, and even share the same Spring XML config files if you like, without needing anything like a shared ApplicationContext. 
A shared context is only of interest if you need to share beans (not just bean definitions), so managed *instances*, between multiple ApplicationContexts. Stateful services are the typical example here, that cache data for example. A domain layer is not even known to Spring in most applications, as instances of domain classes are not Spring-managed beans. 

There are certainly workarounds you can come up with if you really need to access multiple contexts and not just a single parent: you can use the (ContextSingleton)BeanFactoryLocator yourself to obtain a reference to the context and perform a lookup by name or by type, for example. However, I wouldn&#039;t recommend that: again, if you really have requirements to do in-VM SOA I would recommend to use OSGi services instead. That gives you an extremely robust and fully dynamic model that goes way beyond what you can achieve with context hierarchies. By using Spring-DM the programming model remains the same as always, and with dm Server most enterprise libraries and frameworks will work just fine combined with OSGi.</description>
		<content:encoded><![CDATA[<p>You should think about what it means to share a domain layer first: typically I&#039;d say it involves sharing *types* (classes, mostly) and not *instances*. You can easily do that, and even share the same Spring XML config files if you like, without needing anything like a shared ApplicationContext.<br />
A shared context is only of interest if you need to share beans (not just bean definitions), so managed *instances*, between multiple ApplicationContexts. Stateful services are the typical example here, that cache data for example. A domain layer is not even known to Spring in most applications, as instances of domain classes are not Spring-managed beans. </p>
<p>There are certainly workarounds you can come up with if you really need to access multiple contexts and not just a single parent: you can use the (ContextSingleton)BeanFactoryLocator yourself to obtain a reference to the context and perform a lookup by name or by type, for example. However, I wouldn&#039;t recommend that: again, if you really have requirements to do in-VM SOA I would recommend to use OSGi services instead. That gives you an extremely robust and fully dynamic model that goes way beyond what you can achieve with context hierarchies. By using Spring-DM the programming model remains the same as always, and with dm Server most enterprise libraries and frameworks will work just fine combined with OSGi.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phil</title>
		<link>http://blog.springsource.com/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/comment-page-2/#comment-165479</link>
		<dc:creator>Phil</dc:creator>
		<pubDate>Wed, 06 May 2009 18:00:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/#comment-165479</guid>
		<description>Thanks for the feedback.

So having only 1 parent shared context means in order to support 2 domain layers packed separately you would need to do something like the following:

Domain-1 is Parent to Domain-2, and Domain-2 is Parent to WAR-1. 
 
Is there any tricks that can be done in the configuration to allow for also this configuration:
Domain-1 is the Parent to WAR-2 or Domain-2 is the parent to WAR-3, but not both Domain-1 and Domain-2.

I understand your previous point, but it seems like this approach is really application centric.  I&#039;d like to know if there is an easier way to create the configurations so the dependencies are not so tightly coupled.

Thanks again Joris.</description>
		<content:encoded><![CDATA[<p>Thanks for the feedback.</p>
<p>So having only 1 parent shared context means in order to support 2 domain layers packed separately you would need to do something like the following:</p>
<p>Domain-1 is Parent to Domain-2, and Domain-2 is Parent to WAR-1. </p>
<p>Is there any tricks that can be done in the configuration to allow for also this configuration:<br />
Domain-1 is the Parent to WAR-2 or Domain-2 is the parent to WAR-3, but not both Domain-1 and Domain-2.</p>
<p>I understand your previous point, but it seems like this approach is really application centric.  I&#039;d like to know if there is an easier way to create the configurations so the dependencies are not so tightly coupled.</p>
<p>Thanks again Joris.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
