JNDI object not shared among TC instances

JNDI object not shared among TC instances

Post by Albretc » Tue, 14 Dec 2004 00:16:17



Hi,

as, I understand things, the JNDI can be used to share an object among different JVMs even from J2SE applications running on different machines. Right?

I need a relatively light object (that is why I am avoiding EJBs altogether) which would simply:
1._ poll a backend database at configurable periods, and if some data has changed
2._ update its internal state, which is then
3._ administered to and updated in a number of independent tomcat instances

Well, I did the following exp. and repeated it even compiling TC 5.5.5 from source in case I had to check it, but before I start diving deeper into what I think might be the reason for this anomaly, I want to check that I don't have a silly conf problem I haven't seen or there is something I am not quite understanding here.

Here is the method to my madness:

1._ I first downloaded TC's source code, 'built it' with ant, ran and tested it.
2._ Then I set up a number (3) of separate instances running from independent JVMs using the same files as in the original, plain installation, as describe in 1; by:
2.1_ setting up three independent directories, <...> /tc00/, /tc02/, and /tc04/ off the original installation
2.2_ just copying /conf/ and /bin/ from the original installation and dumping similar files on each dir described in 2.1
2.3_ changing then in each of the /conf/server.xml
2.3.1_ the Server port="8005"
2.3.2_ the non-SSL HTTP/1.1 Connector port="8080"
2.3.3_ the AJP 1.3 Connector port="8009" (<- will need it for later tinkering with Apache)
for all three independent instances, and
2.4_ making sure that the same absolute directory was used in the appBase attribute of the <Host name="localhost" . . . context
2.5_ then, making sure that the same;
2.5.1_ JAVA_HOME
2.5.2_ CATALINA_HOME
but different
2.5.3_ CATALINA_BASE
was set in the respective .../tcXX/bin/catalina.bat files (client wants me to 'try' windows 'too'), pointing to the respective .../tcXX
3._ I then ran all three instances and tested every thing was OK and scanned log
files for any errors, warnings, . . .

Everything seemed to be working just fine!

// - - - - - - - - - - - - - - - - - - - - -

Then I used the following slimmed down classes from example code sections in the jakarta JNDI howto, in order to illustrate my point.

Both classes were placed in the original installation's /common/classes/JNDITest/ directory

// - - - - - - - - - - - - - - - - - - - - -
package JNDITest;

public class JNDI00{
private int bar = 0;
private long lCreatTime = System.currentTimeMillis();
private String foo = "Default Foo, created at " + lCreatTime + "";
// __
public String getFoo() { return (this.foo); }
public void setFoo(String foo) { this.foo = foo; }
// __
public int getBar() { return (this.bar); }
public void setBar(int bar) { this.bar = bar; }
// __
public long getCreatTime() { return (lCreatTime); }
public void setCreatTime(long l){}
// __
}

// - - - - - - - - - - - - - - - - - - - - -
package JNDITest;

import java.util.*;
import javax.naming.*;
import javax.naming.spi.*;

public class JNDI00Factory implements ObjectFactory {

public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws NamingException {

JNDI00 JNDI_Obj = new JNDI00();

Reference ref = (Reference) obj;
Enumeration addrs = ref.getAll();
while (addrs.hasMoreElements
 
 
 

1. "Singleton" type object instance does not mean single object instance - very subtle

2. How to share data source instance among several windows forms

I have a typed DataSet which holds my application data. I use it for data
binding in several forms. When setting the DataSet as a data source in my
form the UI designer generates code which creates a new instance of my
DataSet. So each form is referring to an own instance which's not my
intention. I want to share the single instance of my DataSet among all of the
forms but I don't know how to do this without loosing the comfort of the UI
designer. How can this be done? (and if not why)

Thanks in advance
Thomas Probst

3. Shared variables among multiple instances of FSMs

4. Can SSRS and AS be shared amongst multiple AX 2009 instances?

5. Sharing common data among multiple instances of a DLL( C++.NET class library)

6. sharing dictionaries amongst class instances

7. Active Directory Objects - Object reference not set to an instance of an object.

8. Which DB instance(among 2 running instances) is preferred with Oracle TAF feature?

9. sharing an STA object among many threads...

10. true singleton among shared objects

11. Sharing Array of Objects Among Forms

12. true singleton among shared objects

13. Sharing a Class Object (Created in DLL) among DLL Loading Processes ...

14. Share thread among objects

15. how to limit access to common objects shared among multiple threads