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)