Class and Object sharing across domain and its sub-domains
I use Apache Tomcat (5.5.9) to host the website (xyz.com) along with a couple of sub-domains (photos.xyz.com and documents.xyz.com). You can find the relevant portion of server.xml file below. Hosting the websites in this way has lead to two main headaches. 1. I cannot share my Java code between xyz.com, photos.xyz.com and documents.xyz.com: For example, if I have written a simple Java Bean Class and its deployed in Tomcat/webapps/xyz/WEB-INF/classes, the Class is not available to photos.xyz.com and documents.xyz.com. The only way to make it available to all three domains is deploying the Java Bean class in Tomcat/shared/lib or Tomcat/common/lib directories. 2. Problems with session sharing across the domain (xyz.com) and its sub-domains: For example, when a user performs a search on xyz.com, I store the search results in a Java Bean Object in the session. Lets say the user clicks on one of the search results and ends up on a page at documents.xyz.com. Here I won't have access to the Search Results Java Bean object, which I would love to have. These two problems should be pretty common, right? I am wondering how should I structure my application(s) to take care of the above two. Please advise! Thank you, Kristin /* server.xml */ Host name=xyz.com appBase=webapps Context path= docbase=xyz /Context /Host Host name=photos.xyz.com appBase=webapps Context path= docbase=photos /Context /Host Host name=documents.xyz.com appBase=webapps Context path= docbase=documents /Context /Host
Re: Class and Object sharing across domain and its sub-domains
Since your 3 webapps need to share classes code, object instances and session information, i don't see why you want to make 3 webapps instead of just one. So my advise would be to make a single webapp. Kristin Coles a écrit : I use Apache Tomcat (5.5.9) to host the website (xyz.com) along with a couple of sub-domains (photos.xyz.com and documents.xyz.com). You can find the relevant portion of server.xml file below. Hosting the websites in this way has lead to two main headaches. 1. I cannot share my Java code between xyz.com, photos.xyz.com and documents.xyz.com: For example, if I have written a simple Java Bean Class and its deployed in Tomcat/webapps/xyz/WEB-INF/classes, the Class is not available to photos.xyz.com and documents.xyz.com. The only way to make it available to all three domains is deploying the Java Bean class in Tomcat/shared/lib or Tomcat/common/lib directories. 2. Problems with session sharing across the domain (xyz.com) and its sub-domains: For example, when a user performs a search on xyz.com, I store the search results in a Java Bean Object in the session. Lets say the user clicks on one of the search results and ends up on a page at documents.xyz.com. Here I won't have access to the Search Results Java Bean object, which I would love to have. These two problems should be pretty common, right? I am wondering how should I structure my application(s) to take care of the above two. Please advise! Thank you, Kristin /* server.xml */ Host name=xyz.com appBase=webapps Context path= docbase=xyz /Context /Host Host name=photos.xyz.com appBase=webapps Context path= docbase=photos /Context /Host Host name=documents.xyz.com appBase=webapps Context path= docbase=documents /Context /Host - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Class and Object sharing across domain and its sub-domains
Thanks for the reply, David. Are you saying that I need to get rid of the sub-domains? i.e. I should use xyz.com/photos rather than photos.xyz.com? Can you please elaborate? Thanks, Kristin On Mon, Feb 25, 2008 at 4:04 PM, david delbecq [EMAIL PROTECTED] wrote: Since your 3 webapps need to share classes code, object instances and session information, i don't see why you want to make 3 webapps instead of just one. So my advise would be to make a single webapp. Kristin Coles a écrit : I use Apache Tomcat (5.5.9) to host the website (xyz.com) along with a couple of sub-domains (photos.xyz.com and documents.xyz.com). You can find the relevant portion of server.xml file below. Hosting the websites in this way has lead to two main headaches. 1. I cannot share my Java code between xyz.com, photos.xyz.com and documents.xyz.com: For example, if I have written a simple Java Bean Class and its deployed in Tomcat/webapps/xyz/WEB-INF/classes, the Class is not available to photos.xyz.com and documents.xyz.com. The only way to make it available to all three domains is deploying the Java Bean class in Tomcat/shared/lib or Tomcat/common/lib directories. 2. Problems with session sharing across the domain (xyz.com) and its sub-domains: For example, when a user performs a search on xyz.com, I store the search results in a Java Bean Object in the session. Lets say the user clicks on one of the search results and ends up on a page at documents.xyz.com. Here I won't have access to the Search Results Java Bean object, which I would love to have. These two problems should be pretty common, right? I am wondering how should I structure my application(s) to take care of the above two. Please advise! Thank you, Kristin /* server.xml */ Host name=xyz.com appBase=webapps Context path= docbase=xyz /Context /Host Host name=photos.xyz.com appBase=webapps Context path= docbase=photos /Context /Host Host name=documents.xyz.com appBase=webapps Context path= docbase=documents /Context /Host - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Object sharing
Well, I think -Xnoclassgc is horrible. And singleton objects cannot be shared among different application contexts, because they use different classloaders. Shared objects is better held in somewhere else, e.g., JNDI, although I usually blame it =) 2006/5/22, Corobitsyn Roman [EMAIL PROTECTED]: Hi Sharing is possible with Tomcat You must put your objects in shared classloader For example: public class ObjectPool { private static ObjectPool objectPool = null; private ObjectPool { // initialize object } public synchronized static ObjectPool getInstance() { if (objectPool == null) { objectPool = new ObjectPool(); } return objectPool; } } And then put jar or compiled class into shared/lib or shared/classes But prevent garbage collection, you must use the -Xnoclassgc start-up parameter. (set JAVA_OPTS=-Xnoclassgc) Other solution is adding the following member to a class that is always loaded in an application: private ObjectPool objectPool = ObjectPool.getInstance(); I hope this helps BG Arvind BG By design I would use an EJB, this way you can also use BG proper security to comtrol access to your bean. You can access the BG EJB from any webapps, wether it runs or not on the same server. BG And you can also expose it as a web service. BG Using JBoss you will have tomcat out of the box as well as BG transaction, security, etc And no license cost. BG Hopes this helps. BG Bruno Georges BG Glencore International AG BG Tel. +41 41 709 3204 BG Fax +41 41 709 3000 BG - Original Message - BG From: Arvind S. [EMAIL PROTECTED] BG Sent: 19.05.2006 21:25 BG To: users@tomcat.apache.org BG Subject: Object sharing BG Hi, BG If a web application wants to access a object being used by another BG web-application(with a different context root) running on the same BG webserver, is that possible? BG If yes, how can it be achieved?Through sharing attributes of ServletContext? BG Will getting an attribute from the servletContext, return a copy of the BG object or the reference itself? BG Thanks Regards BG LEGAL DISCLAIMER. The contents of this e-mail and any attachments are strictly BG confidential and they may not be used or disclosed by someone who is not a BG named recipient. BG If you have received this email in error please notify the sender by replying BG to this email inserting the word misdirected as the message and delete this BG e-mail from your system. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Object sharing
Oh I'm terribly sorry I miss the line you said into shared/lib or shared/classes. Forget that =P 2006/5/22, Corobitsyn Roman [EMAIL PROTECTED]: Hi Sharing is possible with Tomcat You must put your objects in shared classloader For example: public class ObjectPool { private static ObjectPool objectPool = null; private ObjectPool { // initialize object } public synchronized static ObjectPool getInstance() { if (objectPool == null) { objectPool = new ObjectPool(); } return objectPool; } } And then put jar or compiled class into shared/lib or shared/classes But prevent garbage collection, you must use the -Xnoclassgc start-up parameter. (set JAVA_OPTS=-Xnoclassgc) Other solution is adding the following member to a class that is always loaded in an application: private ObjectPool objectPool = ObjectPool.getInstance(); I hope this helps BG Arvind BG By design I would use an EJB, this way you can also use BG proper security to comtrol access to your bean. You can access the BG EJB from any webapps, wether it runs or not on the same server. BG And you can also expose it as a web service. BG Using JBoss you will have tomcat out of the box as well as BG transaction, security, etc And no license cost. BG Hopes this helps. BG Bruno Georges BG Glencore International AG BG Tel. +41 41 709 3204 BG Fax +41 41 709 3000 BG - Original Message - BG From: Arvind S. [EMAIL PROTECTED] BG Sent: 19.05.2006 21:25 BG To: users@tomcat.apache.org BG Subject: Object sharing BG Hi, BG If a web application wants to access a object being used by another BG web-application(with a different context root) running on the same BG webserver, is that possible? BG If yes, how can it be achieved?Through sharing attributes of ServletContext? BG Will getting an attribute from the servletContext, return a copy of the BG object or the reference itself? BG Thanks Regards BG LEGAL DISCLAIMER. The contents of this e-mail and any attachments are strictly BG confidential and they may not be used or disclosed by someone who is not a BG named recipient. BG If you have received this email in error please notify the sender by replying BG to this email inserting the word misdirected as the message and delete this BG e-mail from your system. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Object sharing
Hi Sharing is possible with Tomcat You must put your objects in shared classloader For example: public class ObjectPool { private static ObjectPool objectPool = null; private ObjectPool { // initialize object } public synchronized static ObjectPool getInstance() { if (objectPool == null) { objectPool = new ObjectPool(); } return objectPool; } } And then put jar or compiled class into shared/lib or shared/classes But prevent garbage collection, you must use the -Xnoclassgc start-up parameter. (set JAVA_OPTS=-Xnoclassgc) Other solution is adding the following member to a class that is always loaded in an application: private ObjectPool objectPool = ObjectPool.getInstance(); I hope this helps BG Arvind BG By design I would use an EJB, this way you can also use BG proper security to comtrol access to your bean. You can access the BG EJB from any webapps, wether it runs or not on the same server. BG And you can also expose it as a web service. BG Using JBoss you will have tomcat out of the box as well as BG transaction, security, etc And no license cost. BG Hopes this helps. BG Bruno Georges BG Glencore International AG BG Tel. +41 41 709 3204 BG Fax +41 41 709 3000 BG - Original Message - BG From: Arvind S. [EMAIL PROTECTED] BG Sent: 19.05.2006 21:25 BG To: users@tomcat.apache.org BG Subject: Object sharing BG Hi, BG If a web application wants to access a object being used by another BG web-application(with a different context root) running on the same BG webserver, is that possible? BG If yes, how can it be achieved?Through sharing attributes of ServletContext? BG Will getting an attribute from the servletContext, return a copy of the BG object or the reference itself? BG Thanks Regards BG LEGAL DISCLAIMER. The contents of this e-mail and any attachments are strictly BG confidential and they may not be used or disclosed by someone who is not a BG named recipient. BG If you have received this email in error please notify the sender by replying BG to this email inserting the word misdirected as the message and delete this BG e-mail from your system. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Object sharing
Arvind By design I would use an EJB, this way you can also use proper security to comtrol access to your bean. You can access the EJB from any webapps, wether it runs or not on the same server. And you can also expose it as a web service. Using JBoss you will have tomcat out of the box as well as transaction, security, etc And no license cost. Hopes this helps. Bruno Georges Glencore International AG Tel. +41 41 709 3204 Fax +41 41 709 3000 - Original Message - From: Arvind S. [EMAIL PROTECTED] Sent: 19.05.2006 21:25 To: users@tomcat.apache.org Subject: Object sharing Hi, If a web application wants to access a object being used by another web-application(with a different context root) running on the same webserver, is that possible? If yes, how can it be achieved?Through sharing attributes of ServletContext? Will getting an attribute from the servletContext, return a copy of the object or the reference itself? Thanks Regards LEGAL DISCLAIMER. The contents of this e-mail and any attachments are strictly confidential and they may not be used or disclosed by someone who is not a named recipient. If you have received this email in error please notify the sender by replying to this email inserting the word misdirected as the message and delete this e-mail from your system.
Object sharing
Hi, If a web application wants to access a object being used by another web-application(with a different context root) running on the same webserver, is that possible? If yes, how can it be achieved?Through sharing attributes of ServletContext? Will getting an attribute from the servletContext, return a copy of the object or the reference itself? Thanks Regards