地址192.168.11.208

时间:2016-09-22 06:34:46

标签: mongodb concurrency nullpointerexception hazelcast hazelcast-imap

我正在尝试在缓存和mongoDB中同步存储数据。我得到了这个例外

Exception in thread "main" com.hazelcast.core.HazelcastException: CONCURRENT_MAP_PUT failed at Address[192.168.11.208]:5702 because of an exception thrown at Address[192.168.11.208]:5701
at com.hazelcast.impl.BaseManager.rethrowException(BaseManager.java:188)
at com.hazelcast.impl.ConcurrentMapManager$MPut.txnalPut(ConcurrentMapManager.java:1902)
at com.hazelcast.impl.ConcurrentMapManager$MPut.txnalPut(ConcurrentMapManager.java:1818)
at com.hazelcast.impl.ConcurrentMapManager$MPut.put(ConcurrentMapManager.java:1682)
at com.hazelcast.impl.MProxyImpl$MProxyReal.put(MProxyImpl.java:632)
at com.hazelcast.impl.MProxyImpl$MProxyReal.put(MProxyImpl.java:606)
at com.hazelcast.impl.MProxyImpl.put(MProxyImpl.java:173)
at com.hazelcast.impl.MProxyImpl.put(MProxyImpl.java:124)
at mypackage.dao.EmployeeDAO.createNewEmployee(EmployeeDAO.java:52)
at mypackage.services.EmployeeManager.createNewEmployee(EmployeeManager.java:25)
at mypackage.controllers.EmployeeController.createNewEmployee(EmployeeController.java:24)
at mypackage.hazelcastspring.App.main(App.java:29)
Caused by: java.lang.NullPointerException
at mypackage.services.EmployeeMapstore.store(EmployeeMapstore.java:61)
at mypackage.services.EmployeeMapstore.store(EmployeeMapstore.java:1)
at com.hazelcast.impl.concurrentmap.MapStoreWrapper.store(MapStoreWrapper.java:114)
at com.hazelcast.impl.ConcurrentMapManager$PutOperationHandler$PutStorer.doMapStoreOperation(ConcurrentMapManager.java:3091)
at com.hazelcast.impl.ConcurrentMapManager$AbstractMapStoreOperation.run(ConcurrentMapManager.java:3795)
at com.hazelcast.impl.executor.ParallelExecutorService$ParallelExecutorImpl$ExecutionSegment.run(ParallelExecutorService.java:212)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at com.hazelcast.impl.ExecutorThreadFactory$1.run(ExecutorThreadFactory.java:38

我有POJO类包含两个String,我正在使用com.hazlecast.core.Mapstore库

Mainclass

public static void main(String[] args) {
CacheTesting testObj = new CacheTesting();
    ApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
    EmployeeController obj = (EmployeeController) context.getBean("employeeController");

     obj.createNewEmployee();
    testObj.cacheMembers();
    testObj.clearCacheMembers();
    testObj.cacheSize();
    testObj.deleteCache(2);
    testObj.getCacheMember(1);}

///// Dao class

public EmployeeDTO createNewEmployee() {
    System.out.println("----Create new employee of DAO class called----");
    getEmployeeDTO.setFirstName("Name");
    getEmployeeDTO.setLastName("lastName");

    System.out.println("DAO object: "+getEmployeeDTO);
    getEmployeeMap().put(3,getEmployeeDTO);

    return getEmployeeDTO;
}

//// MapStore类

public class EmployeeMapstore implements MapStore<Integer, EmployeeDTO> {


@Autowired 
EmployeeDTO getEmployeeDTO;
@Autowired
MongoOperations mongoOperations;
public synchronized void store(Integer key, EmployeeDTO geEmployeeDTO) {
    System.out.println("----Store method of mapstore called----");
    System.out.println("Before put method/Store method object: "+getEmployeeDTO);
    mongoOperations.save(getEmployeeDTO);

0 个答案:

没有答案