I use ZooKeeper in my web Application and found a very odd issue: if I deploy two applications (both use zookeeper) to same tomcat, ZooKeeper in one app will inexplicable disconnect when tomcat starts.
Following is my code, which is very simple:
public class ZKTester implements InitializingBean, Watcher {
private ZooKeeper hZooKeeper;
public void afterPropertiesSet() throws Exception {
hZooKeeper = new ZooKeeper("localhost:2181", 300000, this);
}
public void process(WatchedEvent event) {
System.out.println("**************" + event);
}
and the spring config file:
<bean id="zooTester" class="com.abc.framework.cluster.ZKTester"/>
And here is tomcat's startup log:
...
**************WatchedEvent state:Disconnected type:None path:null
**************WatchedEvent state:Expired type:None path:null
...
Are there any mistakes in my usage?
Thanks
L.J.W