0

I want to get a list of all the servers on infinispan on a Wildfly 10. I get null pointer exception, so I guess I am not connecting to my cache

This is my code

@Resource(lookup="java:jboss/infinispan/container/server/default")
    private CacheContainer container;
public Collection<String> getClusterMembersJGroups() {       
        List<org.infinispan.remoting.transport.Address> members = container.getCache().getCacheManager().getMembers();
        List< String> addresses = new ArrayList< String>();

        for (org.infinispan.remoting.transport.Address member: members) {
            System.out.println("Found Member:" +member.toString());
            String ipAddr = member.toString();
            addresses.add(ipAddr);
        }
        return addresses;
    }

This on my wildfly 10 on the cache container

<subsystem xmlns="urn:jboss:domain:infinispan:4.0">
            <cache-container name="server" aliases="singleton cluster" default-cache="default" module="org.wildfly.clustering.server">
                <transport lock-timeout="60000"/>
                <replicated-cache name="default" mode="SYNC">
                    <transaction mode="BATCH"/>
                </replicated-cache>
            </cache-container>
            <cache-container name="web" default-cache="dist" module="org.wildfly.clustering.web.infinispan">
                <transport lock-timeout="60000"/>
                <distributed-cache name="dist" mode="ASYNC" l1-lifespan="0" owners="2">
                    <locking isolation="REPEATABLE_READ"/>
                    <transaction mode="BATCH"/>
                    <file-store/>
                </distributed-cache>
            </cache-container>

Should I create my own cache container? Can use "server" or "web" to get the list of servers conected to my cluster?

I also tried @Resource(lookup="java:jboss/infinispan/container/server")

I am getting null pointer exception java.lang.NullPointerException Application.getClusterMembersJGroups(Application.java:59)

Juan Diego
  • 1,396
  • 4
  • 19
  • 52
  • What exactly is null? `container` variable? `container.getCache()`? `container.getCache().getCacheManager()`? – Galder Zamarreño Sep 21 '16 at 08:13
  • sorry, the container variable – Juan Diego Sep 21 '16 at 15:30
  • Right, then there's probably problem with the injection. I think `java:jboss/infinispan/container/server` is the correct one. You can check the console to see if the cache container is deployed fine. Check the console's JNDI view to see if what resources are available. You can also try to cast to EmbeddedCacheManager? I don't think it should make a difference. – Galder Zamarreño Oct 10 '16 at 11:38

0 Answers0