androidpn(小强版)异常收集

今天记录一下自己使用androidpn出现的异常处理:

[pool-1-thread-1] ERROR: org.androidpn.server.xmpp.net.XmppIoHandlerexceptionCaught : java.lang.ExceptionInInitializerError

这个是第一个异常,这个异常发生之后,会接着很多个如下异常:

[pool-1-thread-10] ERROR: org.androidpn.server.xmpp.net.XmppIoHandlerexceptionCaught : java.lang.NoClassDefFoundError: Could not initialize class org.androidpn.server.xmpp.ssl.SSLConfig

上个礼拜要提交项目的时候才留意到这么一行异常(因为之前用了struts的token,所以后台很多token的警告,所以没有留意长长的一段异常文字),于是自己debug了一下,找到了引起异常的地方,就是一个空指针的异常,说出来还真是没有什么得意的地方:

 

private static URL classPath ;

 static {
    	
	storeType = Config.getString("xmpp.ssl.storeType", "JKS");
        keyStoreLocation = Config.getString("xmpp.ssl.keystore", "conf"
                + File.separator + "security" + File.separator + "keystore");
        keyStoreLocation = classPath.getPath() + File.separator
                + keyStoreLocation;
        keyPass = Config.getString("xmpp.ssl.keypass", "changeit");
        trustStoreLocation = Config.getString("xmpp.ssl.truststore", "conf"
                + File.separator + "security" + File.separator + "truststore");
        trustStoreLocation = classPath.getPath()
                + File.separator + trustStoreLocation;
        trustPass = Config.getString("xmpp.ssl.trustpass", "changeit");
        classPath = SSLConfig.class.getResource("/");


 

看到classPath,很明显,这个classPath会引起空指针异常,所以,只要把classPath = SSLConfig.class.getResource("/");往上提,提到static块里面的第一行,就ok了。

 

想来应该是写这个版本的人有点不小心所致,不过问题不大,仍然感谢他的奉献精神,各位有看到这种异常的,还希望对大家有帮助。

 

今天(20120801)又看到一个Bug,还是在SSLConfig上面:

[pool-1-thread-1] ERROR: org.androidpn.server.xmpp.ssl.SSLConfig<clinit> : SSLConfig startup problem.

这一个错误由路径错误引起,因为编码格式的问题,如果路径中存在空格,会变成%20这样的字符,所以只要确保路径正确,就ok了。Bug出现还是在classPath的初始化上面:


// Load keystore
        try {
            keyStore = KeyStore.getInstance(storeType);
            keyStore.load(new FileInputStream(URLDecoder.decode(keyStoreLocation)), keyPass
                    .toCharArray());
        } 


还是在静态初始化块这里,把keyStoreLocation换成这种初始方式就不会出现找不到路径这样的错误了。

 

如果有错,还希望指出。


转载请注明出处:http://blog.csdn.net/zranye/article/details/7802017

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值