org.springframework.data.redis.RedisSystemException: Unknown jedis exception; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute statement

Spring JIRA | Andrey Borisov | 2 years ago
  1. 0

    I have 2 beans defined in Application Context: {code:java} @Bean public HibernateExceptionTranslator hibernateExceptionTranslator() { return new HibernateExceptionTranslator(); } @Bean public RedisConnectionFactory redisConnectionFactory() { Properties devProps = localDevProps(); JedisConnectionFactory cf = new JedisConnectionFactory(); return cf; } {code} Both implement {{PersistenceExceptionTranslator}} and both {{TransactionalRepositoryFactoryBeanSupport}} and {{PersistenceExceptionTranslationRepositoryProxyPostProcessor}} creates default {{PersistenceExceptionTranslationInterceptor}} which auto-discover all implementation of this interface. Finally at runtime I get {{JedisException}} when a JPA/Hibernate Exception expected. {noformat} org.springframework.data.redis.RedisSystemException: Unknown jedis exception; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute statement at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:57) at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:36) at org.springframework.data.redis.connection.jedis.JedisConverters.toDataAccessException(JedisConverters.java:138) at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.translateExceptionIfPossible(JedisConnectionFactory.java:151) at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:58) at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:163) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) {noformat}

    Spring JIRA | 2 years ago | Andrey Borisov
    org.springframework.data.redis.RedisSystemException: Unknown jedis exception; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute statement
  2. 0

    I have 2 beans defined in Application Context: {code:java} @Bean public HibernateExceptionTranslator hibernateExceptionTranslator() { return new HibernateExceptionTranslator(); } @Bean public RedisConnectionFactory redisConnectionFactory() { Properties devProps = localDevProps(); JedisConnectionFactory cf = new JedisConnectionFactory(); return cf; } {code} Both implement {{PersistenceExceptionTranslator}} and both {{TransactionalRepositoryFactoryBeanSupport}} and {{PersistenceExceptionTranslationRepositoryProxyPostProcessor}} creates default {{PersistenceExceptionTranslationInterceptor}} which auto-discover all implementation of this interface. Finally at runtime I get {{JedisException}} when a JPA/Hibernate Exception expected. {noformat} org.springframework.data.redis.RedisSystemException: Unknown jedis exception; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute statement at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:57) at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:36) at org.springframework.data.redis.connection.jedis.JedisConverters.toDataAccessException(JedisConverters.java:138) at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.translateExceptionIfPossible(JedisConnectionFactory.java:151) at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:58) at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:163) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) {noformat}

    Spring JIRA | 2 years ago | Andrey Borisov
    org.springframework.data.redis.RedisSystemException: Unknown jedis exception; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute statement
  3. 0

    Spring: JPA not working within @PreDestroy call stacks

    Stack Overflow | 12 months ago | Mike Fairhurst
    org.springframework.data.redis.RedisSystemException: Unknown jedis exception; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [javax.sql.DataSource] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Link to Jedis issue reported- https://github.com/xetorthio/jedis/issues/918#issuecomment-78409511 I am using redis in a heavily multi-threaded java application and getting intermittent ClassCastExceptions I am using Jedis pool, and have verified that spring ensures the resources are returned to the pool, by calling returnResource() and returnBrokenResource in case of exceptions. Still facing this issue. I have a heavily multi-threaded environment I am using multiple spring RedisTemplates for serializing/deserializing different models. I have configured different spring RedisTemplates with their own JedisConnectionFactory so that the jedis pool is created per factory, but this didn't solve the issue. I was always using a pool, and added testOnBorrow as well as testOnReturn true, but didn't help Exception stack trace- stack - Thread 1: [ERROR] [03/01/2015 07:05:32.044] [events-system-akka.actor.default-dispatcher-2281] [akka://events-system/user/$YN/$b/$b/$b] java.lang.Long cannot be cast to java.util.List java.lang.ClassCastException: java.lang.Long cannot be cast to java.util.List at redis.clients.jedis.Connection.getRawObjectMultiBulkReply(Connection.java:230) at redis.clients.jedis.Connection.getObjectMultiBulkReply(Connection.java:236) at redis.clients.jedis.BinaryJedis.zscan(BinaryJedis.java:3608) at org.springframework.data.redis.connection.jedis.JedisConnection$3.doScan(JedisConnection.java:2998) at org.springframework.data.redis.core.KeyBoundCursor.doScan(KeyBoundCursor.java:39) at org.springframework.data.redis.core.ScanCursor.scan(ScanCursor.java:85) at org.springframework.data.redis.core.ScanCursor.hasNext(ScanCursor.java:168) at org.springframework.data.redis.core.ConvertingCursor.hasNext(ConvertingCursor.java:56) ... application specific stack trace ... Thread 2: [ERROR] [03/01/2015 07:03:07.295] [events-system-akka.actor.default-dispatcher-2273] [akka://events-system/user/$VN/$b/$b/$b] Unknown redis exception; nested exception is java.lang.ClassCastException: [B cannot be cast to java.lang.Long org.springframework.data.redis.RedisSystemException: Unknown redis exception; nested exception is java.lang.ClassCastException: [B cannot be cast to java.lang.Long at org.springframework.data.redis.FallbackExceptionTranslationStrategy.getFallback(FallbackExceptionTranslationStrategy.java:48) at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:38) at org.springframework.data.redis.connection.jedis.JedisConnection.convertJedisAccessException(JedisConnection.java:195) at org.springframework.data.redis.connection.jedis.JedisConnection.zRem(JedisConnection.java:2321) at org.springframework.data.redis.core.DefaultZSetOperations$19.doInRedis(DefaultZSetOperations.java:283) at org.springframework.data.redis.core.DefaultZSetOperations$19.doInRedis(DefaultZSetOperations.java:280) at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:190) at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:152) at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:85) at org.springframework.data.redis.core.DefaultZSetOperations.remove(DefaultZSetOperations.java:280) ... application specific stack trace ... Caused by: java.lang.ClassCastException: [B cannot be cast to java.lang.Long at redis.clients.jedis.Connection.getIntegerReply(Connection.java:210) at redis.clients.jedis.BinaryJedis.zrem(BinaryJedis.java:1624) at org.springframework.data.redis.connection.jedis.JedisConnection.zRem(JedisConnection.java:2319) ... 21 more Spring redis configuration - <bean id="jedisConnFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory" redis:usePool="true" redis:poolConfig-ref="jedisPoolConfig" redis:hostName="${redis.datasource.hostName}" redis:database="${redis.database.index}" redis:port="${redis.datastore.port}"/> <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig"> <property name="maxIdle" value="${redis.conn.maxIdle}"/> <property name="maxTotal" value="${redis.conn.maxTotal}"/> <property name="minIdle" value="${redis.conn.minIdle}"/> <property name="testOnBorrow" value="true"/> </bean> <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate" redis:connectionFactory-ref="jedisConnFactory" redis:keySerializer-ref="redisStringSerializer" redis:valueSerializer-ref="redisStringSerializer" redis:defaultSerializer-ref="redisStringSerializer"/> <bean id="redisTemplate2" class="org.springframework.data.redis.core.RedisTemplate" redis:connectionFactory-ref="jedisConnFactory2" redis:keySerializer-ref="redisStringSerializer" redis:valueSerializer-ref="redisCustomDomainObjectSerializer" redis:defaultSerializer-ref="redisStringSerializer"/>

    Spring JIRA | 2 years ago | Deepak Pol
    org.springframework.data.redis.RedisSystemException: Unknown redis exception; nested exception is java.lang.ClassCastException: [B cannot be cast to java.lang.Long
  6. 0

    Link to Jedis issue reported- https://github.com/xetorthio/jedis/issues/918#issuecomment-78409511 I am using redis in a heavily multi-threaded java application and getting intermittent ClassCastExceptions I am using Jedis pool, and have verified that spring ensures the resources are returned to the pool, by calling returnResource() and returnBrokenResource in case of exceptions. Still facing this issue. I have a heavily multi-threaded environment I am using multiple spring RedisTemplates for serializing/deserializing different models. I have configured different spring RedisTemplates with their own JedisConnectionFactory so that the jedis pool is created per factory, but this didn't solve the issue. I was always using a pool, and added testOnBorrow as well as testOnReturn true, but didn't help Exception stack trace- stack - Thread 1: [ERROR] [03/01/2015 07:05:32.044] [events-system-akka.actor.default-dispatcher-2281] [akka://events-system/user/$YN/$b/$b/$b] java.lang.Long cannot be cast to java.util.List java.lang.ClassCastException: java.lang.Long cannot be cast to java.util.List at redis.clients.jedis.Connection.getRawObjectMultiBulkReply(Connection.java:230) at redis.clients.jedis.Connection.getObjectMultiBulkReply(Connection.java:236) at redis.clients.jedis.BinaryJedis.zscan(BinaryJedis.java:3608) at org.springframework.data.redis.connection.jedis.JedisConnection$3.doScan(JedisConnection.java:2998) at org.springframework.data.redis.core.KeyBoundCursor.doScan(KeyBoundCursor.java:39) at org.springframework.data.redis.core.ScanCursor.scan(ScanCursor.java:85) at org.springframework.data.redis.core.ScanCursor.hasNext(ScanCursor.java:168) at org.springframework.data.redis.core.ConvertingCursor.hasNext(ConvertingCursor.java:56) ... application specific stack trace ... Thread 2: [ERROR] [03/01/2015 07:03:07.295] [events-system-akka.actor.default-dispatcher-2273] [akka://events-system/user/$VN/$b/$b/$b] Unknown redis exception; nested exception is java.lang.ClassCastException: [B cannot be cast to java.lang.Long org.springframework.data.redis.RedisSystemException: Unknown redis exception; nested exception is java.lang.ClassCastException: [B cannot be cast to java.lang.Long at org.springframework.data.redis.FallbackExceptionTranslationStrategy.getFallback(FallbackExceptionTranslationStrategy.java:48) at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:38) at org.springframework.data.redis.connection.jedis.JedisConnection.convertJedisAccessException(JedisConnection.java:195) at org.springframework.data.redis.connection.jedis.JedisConnection.zRem(JedisConnection.java:2321) at org.springframework.data.redis.core.DefaultZSetOperations$19.doInRedis(DefaultZSetOperations.java:283) at org.springframework.data.redis.core.DefaultZSetOperations$19.doInRedis(DefaultZSetOperations.java:280) at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:190) at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:152) at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:85) at org.springframework.data.redis.core.DefaultZSetOperations.remove(DefaultZSetOperations.java:280) ... application specific stack trace ... Caused by: java.lang.ClassCastException: [B cannot be cast to java.lang.Long at redis.clients.jedis.Connection.getIntegerReply(Connection.java:210) at redis.clients.jedis.BinaryJedis.zrem(BinaryJedis.java:1624) at org.springframework.data.redis.connection.jedis.JedisConnection.zRem(JedisConnection.java:2319) ... 21 more Spring redis configuration - <bean id="jedisConnFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory" redis:usePool="true" redis:poolConfig-ref="jedisPoolConfig" redis:hostName="${redis.datasource.hostName}" redis:database="${redis.database.index}" redis:port="${redis.datastore.port}"/> <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig"> <property name="maxIdle" value="${redis.conn.maxIdle}"/> <property name="maxTotal" value="${redis.conn.maxTotal}"/> <property name="minIdle" value="${redis.conn.minIdle}"/> <property name="testOnBorrow" value="true"/> </bean> <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate" redis:connectionFactory-ref="jedisConnFactory" redis:keySerializer-ref="redisStringSerializer" redis:valueSerializer-ref="redisStringSerializer" redis:defaultSerializer-ref="redisStringSerializer"/> <bean id="redisTemplate2" class="org.springframework.data.redis.core.RedisTemplate" redis:connectionFactory-ref="jedisConnFactory2" redis:keySerializer-ref="redisStringSerializer" redis:valueSerializer-ref="redisCustomDomainObjectSerializer" redis:defaultSerializer-ref="redisStringSerializer"/>

    Spring JIRA | 2 years ago | Deepak Pol
    org.springframework.data.redis.RedisSystemException: Unknown redis exception; nested exception is java.lang.ClassCastException: [B cannot be cast to java.lang.Long

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.springframework.data.redis.RedisSystemException

      Unknown jedis exception; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute statement

      at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert()
    2. Spring Data Redis
      JedisConnectionFactory.translateExceptionIfPossible
      1. org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:57)
      2. org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:36)
      3. org.springframework.data.redis.connection.jedis.JedisConverters.toDataAccessException(JedisConverters.java:138)
      4. org.springframework.data.redis.connection.jedis.JedisConnectionFactory.translateExceptionIfPossible(JedisConnectionFactory.java:151)
      4 frames
    3. Spring Tx
      PersistenceExceptionTranslationInterceptor.invoke
      1. org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:58)
      2. org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
      3. org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:163)
      3 frames
    4. Spring AOP
      ReflectiveMethodInvocation.proceed
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      1 frame