_00021 Nina Wipes A smile Iraq _ who's most bizarre anomaly second stage Jedis Pool.returnresource (Jedis)

Source: Internet
Author: User

Author Blog:You're the one with the smile
Blog Address:http://blog.csdn.net/u012185296
Post title:_00021 you that Yi Smile _ who unusual most bizarre the second period of Jedis Pool.returnresource (Jedis)
Personality Signature:The furthest distance in the world is not the horizon, nor the cape, but I stand in front of you. And you can't feel my presence
Technical Direction:Flume+kafka+storm+redis/hbase+hadoop+hive+mahout+spark ... Cloud Computing Technology
Reprint statement:can be reproduced, but must be in the form of hyperlinks to indicate the original source and author information and copyright statement, thank you for your cooperation!
QQ Exchange Group:214293307 (look forward to learning with you, common progress)


# Redis who's the weirdest problem the second issue

Commons-collections-3.2.jar

# 1Exception in thread "main" java.lang.noclassdeffounderror:org/apache/commons/collections/cursorablelinkedlist

Analysis: Redis javaapi Jedis error, see this you will certainly think this problem is a bit low-level, really low-level, do not see all know is less lead the jar package caused. But this is not the point, the focus is one method in Jedis:pool.returnresource (Jedis); This is the focus of the focus. Next we look at the descriptive narrative of this approach:voidredis.clients.util. PoolReturnresource (jedis Jedis) can see that there is no exception in this declaration subclass, then we will not go to Try-catch, The consequence of not going to Try-catch is that there will be inexplicable mistakes. No try-catch will appear a java.lang.NullPointerExceptio this null pointer exception, this information to us is useless. This is a problem caused by our lack of jar packages. Here is the hint java.lang.NullPointerException This null pointer exception, this is not the pit father? (Not what we wanted at all) 、、、 and then we started to hang out with dad. I started looking for mistakes, bad luck to find n long can not find out. There is a kind of anger hit the computer impulse, good luck to find out the error, please look at the following code. Don't use Try-catch to compare with Try-catch. I didn't use try-catch when I was hungry. Because of this method Pool.returnresource (Jedis); There is no declaration of exception thrown, so nature will not be used.

(Hang Dad.) )

Reason: Missing Commons-collections-3.2.jar this jar package

Workaround: Import Commons-collections-3.2.jar the jar package is ready

# no code that uses Try-catch has a corresponding exception message

# no code that uses Try-catch

Public void Hdel (String key, String field) {

Jedispoolpool =null;

Jedisjedis =null;

Try {

Pool= Getjedispool (key);

Jedis= Pool.getresource ();

Jedis.hdel (Key,field);

}catch (Exception e) {

log. Error ("Redis Hdel exception:" + key, E);

Pool.returnbrokenresource (Jedis);

}finally {

Pool.returnresource (Jedis);

}

# exception Information

Java.lang.NullPointerException

Atcn.adsit.iva.preroll.dp.synch.analysis.redis.util.ConsistentHashRedisUtils.hset ( consistenthashredisutils.java:164)

Atcn.adsit.iva.preroll.dp.synch.analysis.UserBehaviorStoreRedis.userBehavior2Redis (Userbehaviorstoreredis.java : 58)

Atcn.adsit.iva.preroll.dp.synch.analysis.UserBehaviorAnalysisMainClass.main (Userbehavioranalysismainclass.java : 33)

# using the Try-catch code

Public void Hdel (string key, String field) {

Jedispool pool =null;

Jedis Jedis =null;

Try {

Pool = Getjedispool (key);

Jedis = Pool.getresource ();

Jedis.hdel (key, field);

} catch (Exception e) {

log. Error ("Redis Hdel exception:" +key, E);

Pool.returnbrokenresource (Jedis);

} finally {

Try {

Pool.returnresource (Jedis);

}catch(Exception e) {

log. Error ("Jdisreturnresource exception:", E);

}

}

# exception Information

[2014-07-1016:39:17,659]. [ERROR]. [Cn.adsit.iva.preroll.dp.synch.analysis.redis.util.ConsistentHashRedisUtils]

Jdisreturnresource Exception:

Java.lang.NullPointerException

Atcn.adsit.iva.preroll.dp.synch.analysis.redis.util.ConsistentHashRedisUtils.hset ( consistenthashredisutils.java:164)

Atcn.adsit.iva.preroll.dp.synch.analysis.UserBehaviorStoreRedis.userBehavior2Redis (Userbehaviorstoreredis.java : 58)

Atcn.adsit.iva.preroll.dp.synch.analysis.UserBehaviorAnalysisMainClass.main (Userbehavioranalysismainclass.java : 33)

Exception in thread "main" java.lang.noclassdeffounderror:org/apache/commons/collections/cursorablelinkedlist

Atorg.apache.commons.pool.impl.genericobjectpool.<init> (genericobjectpool.java:392)

Atorg.apache.commons.pool.impl.genericobjectpool.<init> (genericobjectpool.java:275)

Atredis.clients.util.pool.<init> (POOL.JAVA:14)

Atredis.clients.jedis.jedispool.<init> (jedispool.java:24)

Atredis.clients.jedis.jedispool.<init> (jedispool.java:29)

Atcn.adsit.iva.preroll.dp.synch.analysis.redis.util.ConsistentHashRedisUtils.getJedisPool ( consistenthashredisutils.java:343)

Atcn.adsit.iva.preroll.dp.synch.analysis.redis.util.ConsistentHashRedisUtils.getJedisPool ( consistenthashredisutils.java:317)

Atcn.adsit.iva.preroll.dp.synch.analysis.redis.util.ConsistentHashRedisUtils.hset ( consistenthashredisutils.java:156)

Atcn.adsit.iva.preroll.dp.synch.analysis.UserBehaviorStoreRedis.userBehavior2Redis (Userbehaviorstoreredis.java : 58)

Atcn.adsit.iva.preroll.dp.synch.analysis.UserBehaviorAnalysisMainClass.main (Userbehavioranalysismainclass.java : 33)

caused by:java.lang.ClassNotFoundException:org.apache.commons.collections.CursorableLinkedList

Atjava.net.urlclassloader$1.run (urlclassloader.java:217)

Atjava.security.AccessController.doPrivileged (Native Method)

Atjava.net.URLClassLoader.findClass (urlclassloader.java:205)

Atjava.lang.ClassLoader.loadClass (classloader.java:319)

Atjava.lang.ClassLoader.loadClass (classloader.java:264)

Atjava.lang.ClassLoader.loadClassInternal (classloader.java:332)

... 10more

}

# Summary1

Control to know. Use Try-catch to see more important exception information that was not visible:caused by:java.lang.classnotfoundexception:o Rg.apache.commons.collections.CursorableLinkedList

。 Then we know that it was imported into the jar package of Commons-collections-3.2.jar. And then it's done, don't explain, a problem with the pit daddy. Lack of jar package, can also be said to be careless of it!

Hope to be able to help the people who have encountered such problems 、、、

# time:2014-07-10 17:35:21

Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.

_00021 Nina Wipes A smile Iraq _ who's most bizarre anomaly second stage Jedis Pool.returnresource (Jedis)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.