Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
    Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

NPE while caching using coherence in java

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi Ranchers,

I am trying to build a simple caching application using coherence. I am able to bring up the service by running cache-server.cmd from the directory where coherence was installed (C:\Oracle\Middleware\Oracle_Home\coherence\bin) and push or pop value from the cache via command line (cmd). But when I try to do the same using Java code, I am getting the following error:
Value of the NamedCache variable cache after calling getCache(): null
Exception in thread "main" java.lang.NullPointerException
at com.learn.coherence.main.TestCacheMainOne.main(TestCacheMainOne.java:9)

The code is fairly simple and small. I am marking the line causing this exception in bold.
import com.tangosol.net.CacheFactory;
import com.tangosol.net.NamedCache;
public class TestCacheMainOne {
public static void main(String[] args) {
NamedCache cache = CacheFactory.getCache("VirtualCache");
System.out.println("Value of the NamedCache variable cache after calling getCache(): " + cache);
String key = "key1";
String value = "value1";
cache.put(key, value);
String receivedValue = (String) cache.get(key);
System.out.println(receivedValue);
}
}

Please help me in getting over this obstacle.
 
Sheriff
Posts: 4870
317
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
  • Report post to moderator
This is near enough the exact same problem you started to tell us about over in this other thread of yours. Why don't you continue the discussion over there rather than creating near duplicate threads.
 
    Bookmark Topic Watch Topic
  • New Topic