I am using ignite within a spring application using JCache API.  Application
is throwing NPE when starting up.  

--  exception ----
Caused by: java.lang.NullPointerException: null
        at
io.micrometer.core.instrument.binder.cache.JCacheMetrics.<init>(JCacheMetrics.java:80)

Spring is loading ignite correctly as you can see from below log:
-------------------

[15:08:08] Ignite node started OK (id=66e75cae)
[15:08:08] Topology snapshot [ver=9, servers=2, clients=1, CPUs=4,
offheap=6.4GB, heap=2.8GB]
[15:08:08]   ^-- Node [id=66E75CAE-FB54-401F-9330-CEBDA3A7EB84,
clusterState=ACTIVE]

-------------
Adding an entry into the cache as part of a service bean's postconstruct
method is working. So the CacheManager is correctly autowired. I am able to
successfully add an entry into a cache.
-------------- Service bean ---
        @Autowired
        private CacheManager cacheManager;
        
        @PostConstruct
        public void setup() {
        
        Cache cache = cacheManager.getCache("users");  
        cache.put("user","daya");
        logger.info("****** added user to cache ***********");

        }

----  application.properties -------------
spring.cache.jcache.config=classpath:example-cache.xml

---- example-cache.xml -------------------
    <bean id="ignite.cfg"
class="org.apache.ignite.configuration.IgniteConfiguration">
        <property name="clientMode" value="true"/>
        <property name="cacheConfiguration">
            <list>
                
                <bean
class="org.apache.ignite.configuration.CacheConfiguration">
                    <property name="name" value="default"/>
                    <property name="atomicityMode" value="ATOMIC"/>
                    <property name="backups" value="1"/>
                </bean>
            </list>
        </property>

        
        <property name="discoverySpi">
            <bean
class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
                <property name="ipFinder">

                    <bean
class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
                        <property name="addresses">
                            <list>
                                
                                <value>127.0.0.1:47500..47509</value>
                            </list>
                        </property>
                    </bean>
                </property>
            </bean>
        </property>
    </bean>

---  JCacheMetrics code where NPE is getting thrown --------------
   public JCacheMetrics(Cache<?, ?> cache, Iterable<Tag> tags) {
        super(cache, cache.getName(), tags);
        try {
            String cacheManagerUri =
cache.getCacheManager().getURI().toString()
                    .replace(':', '.'); // ehcache's uri is prefixed with
'urn:'

            this.objectName = new
ObjectName("javax.cache:type=CacheStatistics"
                    + ",CacheManager=" + cacheManagerUri
                    + ",Cache=" + cache.getName());
        } catch (MalformedObjectNameException ignored) {
            throw new InvalidConfigurationException("Cache name '" +
cache.getName() + "' results in an invalid JMX name");
        }
    }
---
 cache.getCacheManager() is returning null.

Please help as we are not able to use ignite. JCache integration is failing
for us because of this.
This is strange as I was able to use the autowired cacheManager to retrieve
a Cache and add an entry.





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Reply via email to