Re: What is the cause of this NullPointer Exception? (Spring Data)

1,729 views
Skip to first unread message
Message has been deleted

Colin Vipurs

unread,
Aug 19, 2013, 4:37:52 AM8/19/13
to redi...@googlegroups.com
I don't know anything about Spring data - but we've hit issues before because Jedis doesn't like you trying to send nulls.

I can't see it from your code, but do you have a null field you're trying to persist?


On Sun, Aug 18, 2013 at 7:50 PM, <appren...@googlemail.com> wrote:
Hi,

Can somebody please take a glance at this Null Pointer Exception and comment why I'm getting the this Exception? (excerpts of referenced classes/xml included).

Thanks in advance.

Exception in thread "main" org.springframework.data.redis.RedisSystemException: Unknown jedis exception; nested exception is java.lang.NullPointerException
    at org.springframework.data.redis.connection.jedis.JedisConnection.convertJedisAccessException(JedisConnection.java:141)
    at org.springframework.data.redis.connection.jedis.JedisConnection.set(JedisConnection.java:897)
    at org.springframework.data.redis.connection.DefaultStringRedisConnection.set(DefaultStringRedisConnection.java:384)
    at org.springframework.data.redis.core.DefaultValueOperations$9.inRedis(DefaultValueOperations.java:178)
    at org.springframework.data.redis.core.AbstractOperations$ValueDeserializingRedisCallback.doInRedis(AbstractOperations.java:49)
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:169)
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:137)
    at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:84)
    at org.springframework.data.redis.core.DefaultValueOperations.set(DefaultValueOperations.java:175)
    at com.equitytwits.core.redis.repository.UserRepository.addAuth(UserRepository.java:63)
    at com.equitytwits.core.redis.repository.UserRepository.addUser(UserRepository.java:55)
    at com.equitytwits.core.redis.CreateNewUser.main(CreateNewUser.java:22)
Caused by: java.lang.NullPointerException
    at redis.clients.jedis.Protocol.sendCommand(Protocol.java:48)
    at redis.clients.jedis.Protocol.sendCommand(Protocol.java:33)
    at redis.clients.jedis.Connection.sendCommand(Connection.java:80)
    at redis.clients.jedis.BinaryClient.set(BinaryClient.java:86)
    at redis.clients.jedis.BinaryJedis.set(BinaryJedis.java:59)
    at org.springframework.data.redis.connection.jedis.JedisConnection.set(JedisConnection.java:895)
    ... 10 more

//Tester Class
public class CreateNewUser {
    private static Logger logger = Logger.getLogger(CreateUserTester.class);
    public static void main(String[] args) {
        GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
        ctx.load("redis-app-context.xml");
        ctx.refresh();
    UserRepository userRepo = ctx.getBean("redisUserRepository", UserRepository.class);
    User user = new User();
    ...
    userRepo.addUser(user);
   
    }
   

//Repository Class

@Named
public class UserRepository {
    private static Logger logger = LoggerFactory.getLogger(UserRepository.class);   
    private StringRedisTemplate redisTemplate;
    private ValueOperations<String, String> valueOps;
    private RedisList<String> users;
    private ListOperations<String, String> listOps;
    private RedisAtomicLong userIdCounter;
   
    @Autowired
    public UserRepository(StringRedisTemplate redisTemplate){
        this.redisTemplate = redisTemplate;
        this.valueOps = redisTemplate.opsForValue();
        users = new DefaultRedisList<String>(KeyUtils.users(), redisTemplate);
        userIdCounter = new RedisAtomicLong(KeyUtils.globalUid(), redisTemplate.getConnectionFactory());
    }

.....

}


//Context File
<bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
p:host-name="${redis.host}" p:port="${redis.port}" p:password="${redis.pass}"/>

<bean id="redisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate"
p:connection-factory-ref="jedisConnectionFactory"/>

Maven Dependency version
<spring-data-redis-version>1.0.6.RELEASE</spring-data-redis-version>









--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at http://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/groups/opt_out.



--
Maybe she awoke to see the roommate's boyfriend swinging from the chandelier wearing a boar's head.

Something which you, I, and everyone else would call "Tuesday", of course.
Reply all
Reply to author
Forward
0 new messages