Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-13308

NPE when trying to setup jgroups transport throught xml config file

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not a Bug
    • Icon: Critical Critical
    • None
    • 12.0.2.Final, 12.1.7.Final
    • Configuration
    • None

      I am trying to setup a replicated Infinispan embedded cache.
      When using the demo code for programmatically setup the cache, everything works, as expected (https://github.com/infinispan/infinispan-simple-tutorials/tree/main/infinispan-embedded/cache-replicated)

      Now, I want to configure it to use a defined list of initial hosts.

      So, I changed slightly the code to be :

      public class TestGenerate
      {
          public static void main(String[] args) throws InterruptedException
          {
              // Setup up a clustered cache manager
              GlobalConfigurationBuilder global = GlobalConfigurationBuilder.defaultClusteredBuilder();
              GlobalConfiguration globalConfiguration = global.transport().defaultTransport().addProperty("configurationFile", "jgroups.xml").build();
              // Initialize the cache manager
              DefaultCacheManager cacheManager = new DefaultCacheManager(globalConfiguration);
              // Create a replicated synchronous configuration
              ConfigurationBuilder builder = new ConfigurationBuilder();
              builder.clustering().cacheMode(CacheMode.REPL_SYNC);
              Configuration cacheConfig = builder.build();
              // Create a cache
              Cache<String, String> cache = cacheManager.administration()
                      .withFlags(CacheContainerAdmin.AdminFlag.VOLATILE)
                      .getOrCreateCache("cache", cacheConfig);
      
              // Store the current node address in some random keys
              for(int i=0; i < 10; i++) {
                  cache.put(UUID.randomUUID().toString(), cacheManager.getNodeAddress());
              }
              // Display the current cache contents for the whole cluster
              System.out.println("--------------- whole cluster");
              cache.entrySet().forEach(entry -> System.out.printf("%s = %s\n", entry.getKey(), entry.getValue()));
              // Display the current cache contents for this node
              System.out.println("--------------- this node");
              cache.getAdvancedCache().withFlags(Flag.SKIP_REMOTE_LOOKUP)
                      .entrySet().forEach(entry -> System.out.printf("%s = %s\n", entry.getKey(), entry.getValue()));
      
      
              Thread.currentThread().join();
          }
      }
      

      My JGroups configuration file is very minimal :

      <config xmlns="urn:org:jgroups"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/jgroups.xsd">
      
         <TCP bind_port="7950" />
         <TCPPING initial_hosts="192.168.42.100[7950],192.165.10.52[7950]"/>
      </config>
      

      The problem is that the cache doesn't start :

      sept. 21, 2021 1:49:01 PM org.infinispan.factories.GlobalComponentRegistry preStart
      INFO: ISPN000128: Infinispan version: Infinispan 'Taedonggang' 12.1.7.Final
      sept. 21, 2021 1:49:01 PM org.infinispan.marshall.core.impl.DelegatingUserMarshaller start
      INFO: ISPN000556: Starting user marshaller 'org.infinispan.commons.marshall.ImmutableProtoStreamMarshaller'
      sept. 21, 2021 1:49:01 PM org.infinispan.remoting.transport.jgroups.JGroupsTransport start
      INFO: ISPN000078: Starting JGroups channel ISPN
      sept. 21, 2021 1:49:02 PM org.infinispan.remoting.transport.jgroups.JGroupsTransport startJGroupsChannelIfNeeded
      INFO: ISPN000079: Channel ISPN local address is null, physical addresses are [192.168.42.100:7950]
      sept. 21, 2021 1:49:02 PM org.infinispan.remoting.transport.jgroups.JGroupsTransport stop
      INFO: ISPN000080: Disconnecting JGroups channel ISPN
      Exception in thread "main" org.infinispan.manager.EmbeddedCacheManagerStartupException: org.infinispan.commons.CacheConfigurationException: Error starting component org.infinispan.topology.ClusterTopologyManager
          at org.infinispan.manager.DefaultCacheManager.internalStart(DefaultCacheManager.java:755)
          at org.infinispan.manager.DefaultCacheManager.start(DefaultCacheManager.java:718)
          at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:296)
          at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:219)
          at TestGenerate.main(TestGenerate.java:43)
      Caused by: org.infinispan.commons.CacheConfigurationException: Error starting component org.infinispan.topology.ClusterTopologyManager
          at org.infinispan.factories.impl.BasicComponentRegistryImpl.startWrapper(BasicComponentRegistryImpl.java:572)
          at org.infinispan.factories.impl.BasicComponentRegistryImpl.access$700(BasicComponentRegistryImpl.java:30)
          at org.infinispan.factories.impl.BasicComponentRegistryImpl$ComponentWrapper.running(BasicComponentRegistryImpl.java:787)
          at org.infinispan.factories.impl.BasicComponentRegistryImpl.startDependencies(BasicComponentRegistryImpl.java:622)
          at org.infinispan.factories.impl.BasicComponentRegistryImpl.doStartWrapper(BasicComponentRegistryImpl.java:586)
          at org.infinispan.factories.impl.BasicComponentRegistryImpl.startWrapper(BasicComponentRegistryImpl.java:564)
          at org.infinispan.factories.impl.BasicComponentRegistryImpl.access$700(BasicComponentRegistryImpl.java:30)
          at org.infinispan.factories.impl.BasicComponentRegistryImpl$ComponentWrapper.running(BasicComponentRegistryImpl.java:787)
          at org.infinispan.factories.impl.BasicComponentRegistryImpl.startDependencies(BasicComponentRegistryImpl.java:622)
          at org.infinispan.factories.impl.BasicComponentRegistryImpl.doStartWrapper(BasicComponentRegistryImpl.java:586)
          at org.infinispan.factories.impl.BasicComponentRegistryImpl.startWrapper(BasicComponentRegistryImpl.java:564)
          at org.infinispan.factories.impl.BasicComponentRegistryImpl.access$700(BasicComponentRegistryImpl.java:30)
          at org.infinispan.factories.impl.BasicComponentRegistryImpl$ComponentWrapper.running(BasicComponentRegistryImpl.java:787)
          at org.infinispan.factories.AbstractComponentRegistry.internalStart(AbstractComponentRegistry.java:354)
          at org.infinispan.factories.AbstractComponentRegistry.start(AbstractComponentRegistry.java:250)
          at org.infinispan.manager.DefaultCacheManager.internalStart(DefaultCacheManager.java:750)
          ... 4 more
      Caused by: java.lang.NullPointerException: Cannot invoke "Object.equals(Object)" because the return value of "org.infinispan.remoting.transport.Transport.getAddress()" is null
          at org.infinispan.topology.TopologyManagementHelper.executeOnCoordinator(TopologyManagementHelper.java:83)
          at org.infinispan.topology.ClusterTopologyManagerImpl.fetchRebalancingStatusFromCoordinator(ClusterTopologyManagerImpl.java:162)
          at org.infinispan.topology.ClusterTopologyManagerImpl.start(ClusterTopologyManagerImpl.java:153)
          at org.infinispan.topology.CorePackageImpl$3.start(CorePackageImpl.java:74)
          at org.infinispan.topology.CorePackageImpl$3.start(CorePackageImpl.java:58)
          at org.infinispan.factories.impl.BasicComponentRegistryImpl.invokeStart(BasicComponentRegistryImpl.java:604)
          at org.infinispan.factories.impl.BasicComponentRegistryImpl.doStartWrapper(BasicComponentRegistryImpl.java:595)
          at org.infinispan.factories.impl.BasicComponentRegistryImpl.startWrapper(BasicComponentRegistryImpl.java:564)
          ... 19 more

      If I use the demo code, the getAddress() method will indeed return something (my hostname and a number), but with the modification, the address is indeed null.

      After some search, when I use the demo code, the receiveClusterView(View) method from JGroupsTransport class is called before the executeOnCoordinator(...) method in TopologyManagementHelper class, this set the address.When using my xml configuration file, the receiveClusterView(view) is not called before the executeOnCoordinator() method, and as such the getAddress() fails.

            pruivo@redhat.com Pedro Ruivo
            bakaonigiri Nicolas V. (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: