用eclipse 写java项目,运行时出现了下面这个错误,不知道是怎么回事。

2015-09-27 09:35:07,058 [ThreadSafeServer]-[ERROR] INIT ThreadSafeServer :
java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:514)
at com.wifino1.server.email.EmailSender2.setParams(EmailSender2.java:84)
at com.wifino1.server.email.ThreadSafeServer.service(ThreadSafeServer.java:29)
at com.wifino1.utils.AppServerUtils.serverInit(AppServerUtils.java:173)
at com.wifino1.server.AppServer.startServer(AppServer.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.wifino1.bootstrap.Bootstrap.startAPP(Bootstrap.java:141)
at com.wifino1.bootstrap.Bootstrap.main(Bootstrap.java:81)
2015-09-27 09:35:07,074 [class com.wifino1.bootstrap.Bootstrap { APPServer} ]-[ERROR] Exception in thread "Timer-2"
2015-09-27 09:35:07,074 [class com.wifino1.bootstrap.Bootstrap { APPServer} ]-[ERROR] java.lang.NoSuchMethodError: java.util.concurrent.ConcurrentHashMap.keySet()Ljava/util/concurrent/ConcurrentHashMap$KeySetView;
2015-09-27 09:35:07,074 [class com.wifino1.bootstrap.Bootstrap { APPServer} ]-[ERROR] at com.wifino1.server.ShowMemoryServer.run(ShowMemoryServer.java:32)
2015-09-27 09:35:07,074 [class com.wifino1.bootstrap.Bootstrap { APPServer} ]-[ERROR] at java.util.TimerThread.mainLoop(Timer.java:555)
2015-09-27 09:35:07,076 [class com.wifino1.bootstrap.Bootstrap { APPServer} ]-[ERROR] at java.util.TimerThread.run(Timer.java:505)
2015-09-27 09:35:07,295 [class com.wifino1.bootstrap.Bootstrap { APPServer} ]-[ERROR] Start app APPServer fail!
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.wifino1.bootstrap.Bootstrap.startAPP(Bootstrap.java:141)
at com.wifino1.bootstrap.Bootstrap.main(Bootstrap.java:81)
Caused by: java.lang.NullPointerException
at com.cdy.connPool.MConnPool.<init>(MConnPool.java:49)
at com.wifino1.MServer.client.RecClient.start(RecClient.java:185)
at com.wifino1.Mserver.RecClientImpl.start(RecClientImpl.java:135)
at com.wifino1.server.AppServer.startServer(AppServer.java:97)
... 6 more

第1个回答  2015-09-28
java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:514)

应该是往Hashtable中put参数时抛出的,应该是key为空对象导致的。
Hashtable的键值不能为null,否则会抛出:java.lang.NullPointerException。
出错代码是com.wifino1.server.email.EmailSender2第84行。
setParams方法中某一行代码。追问

props.put("mail.smtp.host", HOST);//HOST的值是"smtp.163.com"

追答

应该是HOST为空,HOST这个变量是如何获取的?从properties中读出来的吗?是否classpath不对?
以下是hashtable的put方法源码,看抛出的行数应该是value为空。

public synchronized V put(K key, V value) {
// Make sure the value is not null
if (value == null) {
throw new NullPointerException();
}

本回答被提问者采纳
第2个回答  2015-09-28
EmailSender2.java:84行;贴出来追问

props.put("mail.smtp.host", HOST);//HOST的值是"smtp.163.com"

相似回答