简体   繁体   中英

AbstractMethodError from java.util.Hashtable while calling get method

We have an Object CollectedInfo , which contains a Hashtable . In our application, we populate this Hashtable , and then iterate it to perform insert operations. Different threads used simultaneously to perform this operation.

While retrieving the value from the Hashtable , we see the AbstractMethodError exception, showing the trace from get method of Hashtable . As soon as this exception comes the java application crashes.

We are not able to reproduce the exception, however we can see the same behavior in our application very consistently over a period of time.

Below is the trace :

SYS_ERR: Exception running task: java.lang.AbstractMethodError
SYS_ERR: java.lang.AbstractMethodError
SYS_ERR:     at java.util.Hashtable.get(Unknown Source)
SYS_ERR:     at poll.CollectedInfo.getValuesForColumn(CollectedInfo.java:1026)
SYS_ERR:     at poll.YYYMgr.saveData(YYYMgr.java:5346)
SYS_ERR:     at poll.YYYMgr.saveData(YYYMgr.java:2412)
SYS_ERR:     at poll.YYYMgr.saveData(YYYMgr.java:2250)
SYS_ERR:     at poll.CommonPollAPI.saveData(CommonPollAPI.java:579)
SYS_ERR:     at poll.XXXXData.run(XXXXData.java:76)
SYS_ERR:     at management.scheduler.WorkerThread.run(WorkerThread.java:70)

We are using the JRE 1.6.0, and the OS where this issue is reproduce is Linux Red Hat Enterprise Linux Server release 5.6 Beta (Tikanga).

Firstly, a Hashtable is basically a HashMap , so...

You have:

  • a HashMap
  • Multiple threads using the HashMap concurrently

What need is a HashMap that is coded for concurrent access.

Fortunately, one exists already: ConcurrentHashMap . The only change you'll need to you code is to use the special thread-safe method putIfAbsent(K, V)

Take an Iterator class object and then try to get hash values.

//Declaration

 Iterator itr = hashtable.keySet().iterator();

// Processing

 while(itr.hasNext())
 { 
    String key = (String)itr.next();  
        String value = (String)hashtable.get(key); 

           // write your desired code
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM