For all who care I finally figured out a way to get this to work (which also 
may point out a bug inside TreeCache).

First thing you have to do is create your JChannel before you create your 
PojoCache. My earlier attempts (in my first message) extended the PojoCache to 
expose the JChannel through a public method, this did not work and resulted in 
the error listed in my original message, this method of creating your JChannel 
before hand works but only after some tweaking.

The main problem is that the method below (in TreeCache.class), when you use 
your own JChannel, on line 3177 waits forever:

         
  |         synchronized (members)
  |          {
  |             while (members.size() == 0)
  |             {
  |                log.debug("waiting on viewAccepted()");
  |                try
  |                {
  |                   members.wait();
  |                }
  |                catch (InterruptedException iex)
  |                {
  |                }
  |             }
  |          }
  | 

To fix this we have to figure out why this works when we allow JBossCache to 
create the JChannel but doesn't work when we do it ourself. I believe the 
problem lies in _createService method. If you look at this method there's an if 
statement which checks to see if a JChannel exists and returns (prematurally) 
like such:


  |             log.info("cache mode is " + mode2String(cache_mode));
  |             if (channel != null)
  |             { // already started
  |                log.info("channel is already running");
  |                return;
  |             }
  | 

The probelm with returning is that after the if block there are several lines 
which attach a listener that I assume is required, the absence of this listener 
causes problems:


  |             channel.setOpt(Channel.AUTO_RECONNECT, Boolean.TRUE);
  |             channel.setOpt(Channel.AUTO_GETSTATE, Boolean.TRUE);
  | 
  |             // COMMENTED OUT CODE HERE
  | 
  |             disp = new RpcDispatcher(channel, ml, this, this);
  |             disp.setMarshaller(getMarshaller());
  |             break;
  | 

So because this code doesn't get executed we have to manually attach this 
listener ourselves. The whole process of creating the JChannel and setting up 
the listener looks like:


  |         JChannelFactory factory = new JChannelFactory( 
this.getClass().getClassLoader().getResource( _jgroupsConfiguration ) );
  | 
  |         _channel = (JChannel) factory.createChannel();
  |         _channel.setOpt(Channel.GET_STATE_EVENTS, Boolean.TRUE);
  |         _channel.setOpt(Channel.AUTO_RECONNECT, Boolean.TRUE);
  |         _channel.setOpt(Channel.AUTO_GETSTATE, Boolean.TRUE);        
  | 
  |         // creates our own dispatcher used to proxy method requests across 
the cluster
  |         _dispatcher = new RpcDispatcher( _channel, null, null, this );      
  
  |         _serviceCache = new PojoCache( _channel );
  | 
  |         PropertyConfigurator config = new PropertyConfigurator();
  |         config.configure( _serviceCache, _cacheConfiguration );
  | 
  |         // START HACK: STOP JBOSSCACHE FROM BLOCKING FOREVER
  |         RpcDispatcher dispatcher = new RpcDispatcher( _channel, 
_serviceCache.getMessageListener(), _serviceCache, _serviceCache );
  |         dispatcher.setMarshaller( _serviceCache.getMarshaller() );
  |         // END HACK
  |         
  |         _serviceCache.startService();
  | 

I belive this could all be avoided by removing the return  statement on line 
1352 so that the MessageListenerAdaptor gets properly attached.                 
                                  

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3956006#3956006

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3956006

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to