Different War Files, Shared Resources

Different WAR files, shared same user permission

You can enable SSO, as detailed here: JBoss7 Web SSO (Non-Clustered) or here: http://www.mastertheboss.com/jboss-server/jboss-security/configuring-single-signon-on-jboss-as-7

Add sso tag to your standalone.xml:

<virtual-server name="default-host" enable-welcome-root="false">
...
<sso domain="local" reauthenticate="false"/>
</virtual-server>

And add/update your war/WEB-INF/jboss-web.xml:

<jboss-web>
<security-domain>sso</security-domain>
<valve>
<class-name>org.apache.catalina.authenticator.SingleSignOn</class-name>
</valve>
</jboss-web>

2 war files under same single tomcat - static resource sharing

Yes, you can. You simply need to put the context root of application A in the path for the script reference, e.g. like this

<script src="/A/sample.js"></script>

How does Tomcat load the different war files?

Tomcat creates (Web) application class loaders for each deployed WAR. It has some common class loaders. The overall hierachy is best described in the class loader howto:

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

BTW: Tomcat does an incredible amount of resource management in order to allow applications to be undeployed. This is described here:

http://wiki.apache.org/tomcat/MemoryLeakProtection

and ties tightly into class loaders and class unloading.

Tomcat ServletContext vs JNDI for Sharing session data across multiple war files

I'm not sure if you understood correctly, but the HttpSession is different for each user (browser session), and for each application as well, AFAIK, so you can't use it to share data.

Basically, you need communication between your web applications.
You could have one war to act as data manager for your UserSession, and all other wars communicating to this one. The data manager application needs to expose a service, e.g. UserSessionManager that can be accessed via other applications.

JNDI is a traditional solution for this. Spring has some helpers for this, but the JNDI API is not too complicated either. In the data manager war, you could do something like this in an initialization method:

DataManager mgr = new DataManagerImpl(...);
InitialContext ic = new InitialContext();
ic.rebind("java:global/env/datamanager", mgr);

The interface and the data objects you use needs to be put in a jar that is shared in all 'client' wars, the implementation is only in the data manager war. In your client wars, you can then do:

InitialContext ic = new InitialContext();
DataManager mgr = (DataManager)ic.lookup("java:global/env/datamanager");

Hope this helps,
Geert.



Related Topics



Leave a reply



Submit