Spring batch Gemfire 9.6 connection error - Caused by: java.io.IOException: Unable to write to deploy directory - spring-batch

I am using Spring batch to load data into gemfire using
#Bean
public GemfireTemplate gemFireTemplate(ClientRegionFactory<Object,
Object> factory) {
GemfireTemplate template = new GemfireTemplate();
template.setRegion("regionName");
return template;
}
POM:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-gemfire</artifactId>
<version>1.5.16.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-geode</artifactId>
<version>2.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>io.pivotal.gemfire</groupId>
<artifactId>geode-core</artifactId>
<version>9.3.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.pivotal.gemfire</groupId>
<artifactId>geode-common</artifactId>
<version>9.3.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.pivotal.gemfire</groupId>
<artifactId>geode-cq</artifactId>
<version>9.3.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.pivotal.gemfire</groupId>
<artifactId>geode-wan</artifactId>
<version>9.3.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.pivotal.gemfire</groupId>
<artifactId>geode-json</artifactId>
<version>9.3.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.pivotal.gemfire</groupId>
<artifactId>geode-lucene</artifactId>
<version>9.3.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>4.2.12.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>4.2.12.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-core</artifactId>
<version>4.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.0.3.RELEASE</version>
</dependency>
Logs :
[info 2019/09/11 22:29:22.836 CDT <main> tid=0x1] GemFireCache[id = 892555958; isClosing = true; isShutDownAll = false; created = Wed Sep 11 22:29:20 CDT 2019; server = false; copyOnRead = false; lockLease = 120; lockTimeout = 60]: Now closing.
[error 2019/09/11 22:29:22.913 CDT <main> tid=0x1] java.lang.RuntimeException: java.io.IOException: Unable to write to deploy directory: /data/khan/vaquar/dataloader
java.lang.RuntimeException: java.io.IOException: Unable to write to deploy directory: /data/khan/vaquar/dataloader
at org.apache.geode.internal.JarDeployer.loadPreviouslyDeployedJarsFromDisk(JarDeployer.java:410)
at org.apache.geode.internal.cache.GemFireCacheImpl.initialize(GemFireCacheImpl.java:1191)
at org.apache.geode.internal.cache.GemFireCacheImpl.basicCreate(GemFireCacheImpl.java:758)
at org.apache.geode.internal.cache.GemFireCacheImpl.createClient(GemFireCacheImpl.java:731)
at org.apache.geode.cache.client.ClientCacheFactory.basicCreate(ClientCacheFactory.java:262)
at org.apache.geode.cache.client.ClientCacheFactory.create(ClientCacheFactory.java:212)
at com.syf.gemfire.jdbc.dataloader.config.FullBatchConf.clientCache(FullBatchConf.java:205)
at com.syf.gemfire.jdbc.dataloader.config.FullBatchConf$$EnhancerBySpringCGLIB$$749d49c1.CGLIB$clientCache$5(<generated>)
at com.syf.gemfire.jdbc.dataloader.config.FullBatchConf$$EnhancerBySpringCGLIB$$749d49c1$$Fast
Caused by: java.io.IOException: Unable to write to deploy directory: /data/khan/vaquar/dataloader
at org.apache.geode.internal.JarDeployer.verifyWritableDeployDirectory(JarDeployer.java:333)
at org.apache.geode.internal.JarDeployer.loadPreviouslyDeployedJarsFromDisk(JarDeployer.java:389)
and
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.geode.cache.client.ClientCache]: Factory method 'clientCache' threw exception; nested exception is java.lang.RuntimeException: java.io.IOException: Unable to write to deploy directory:/data/khan/vaquar/dataloader
Analysis:
Pivotal jars required write permissions when start geode connection with gemfire cluster .
Pivotal code :
https://github.com/ashishtadose/gemfire-xd/blob/master/gemfire-core/src/main/java/com/gemstone/gemfire/internal/JarDeployer.java
Pivotal Doc:
- https://gemfire.docs.pivotal.io/98/geode/configuring/cluster_config/deploying_application_jars.html
If gemfire.properties is specified then Geode locator fails to start
https://www.mail-archive.com/issues#geode.apache.org/msg17105.html
https://issues.apache.org/jira/browse/GEODE-5000?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel
Pivotal doc says if we can remove "deploy-working-dir"inside "gefire.properties" will resolve issue else use "-Dgemfire.deploy-working-dir=/temp/
Problem :
inside Spring batch we are not configuring any gemfire properties , how to fix it in GemfireTemplate code ?

The issue is clearly the same as the one described by the Geode Ticket you attached to the question, GEODE-5000. This particular ticket is fixed in Geode 1.6.0 and, according to the Pivotal GemFire User Guide, specifically the Release Notes, GemFire 9.5 is based on Geode 1.6.0, so you should be using that version instead of 9.3.0 to get rid of the problem.
As a side note, you shouldn't be arbitrarily mixing and matching spring-data-gemfire and gemfire versions as several issues might rise, please follow the Spring Data for Pivotal GemFire Version Compatibility Matrix to avoid issues.
Hope this helps. Cheers.

Related

Spring boot embedded kafka throws error BeanCreationException

I have a test case with following configured kafka properties:
#ExtendWith(SpringExtension.class)
#SpringBootTest(classes = {Application.class})
#ActiveProfiles("test")
#EnableConfigurationProperties
#EmbeddedKafka(controlledShutdown = true, topics = {"topic1", "topic2", "topic3"})
class Name {}
Here is the build error i get when running the test case above:
Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'embeddedKafka': Invocation of init method failed; nested exception is java.lang.NoSuchFieldError: DEFAULT_SASL_ENABLED_MECHANISMS
Caused by: java.lang.NoSuchFieldError: DEFAULT_SASL_ENABLED_MECHANISMS
at kafka.server.Defaults$.<clinit>(KafkaConfig.scala:242)
at kafka.server.KafkaConfig$.<clinit>(KafkaConfig.scala:961)
at kafka.server.KafkaConfig.LogDirProp(KafkaConfig.scala)
at org.springframework.kafka.test.EmbeddedKafkaBroker.afterPropertiesSet(EmbeddedKafkaBroker.java:322)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1853)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1790)
... 72 common frames omitted
Here is the POM file with spring kafka & kafka-client dependency which is likely causing the error:
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
<version>2.7.7</version>
<exclusions>
<exclusion>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka-test</artifactId>
<version>2.7.7</version>
<scope>test</scope>
</dependency>
Solution:
Please refer to this link:
https://docs.spring.io/spring-kafka/docs/current/reference/html/#update-deps
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
<version>2.7.7</version>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka-test</artifactId>
<version>2.7.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>2.8.1</version>
<classifier>test</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.13</artifactId>
<version>2.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.13</artifactId>
<version>2.8.1</version>
<classifier>test</classifier>
<scope>test</scope>
</dependency>
```
That spring-Kafka version is not compatible with Apache Kafka client 3.0. You need still coming 2.8 and Spring Boot 2.6.
On the other hand you don’t need newer client even if you use newer broker . Although the story is about embedded testing, so I fully doubt you need to worry about any client, unless it is something transitive from Spring for Apache Kafka…

Mongo Java Driver version mismatch with spring framework

I have springboot (2.0.4) application with Mongo Java driver version 3.11.2. When upgrading the application for mongo java driver to version 4.1.0 to use IAM authentication feature of new mongo java driver, the changes are breaking with overall spring framework.
MongoTemplate Bean code:
#Bean
public MongoClient mongoClient() {
ConnectionString connectionString = new ConnectionString(
("mongodb://connectionString:goesHere"));
MongoClient mongoClient = MongoClients.create(connectionString);
return mongoClient;
}
#Bean
public MongoTemplate mongoTemplate(MongoClient mongoClient) {
return new MongoTemplate(mongoClient, mongoDB);
}
Dependencies:
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>bson</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-core</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</exclusion>
<exclusion>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
</exclusion>
<exclusion>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver</artifactId>
</exclusion>
</exclusions>
</dependecy>
Deployment error with Mongo Java Driver 4.1.0:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.core.MongoTemplate]: Factory method 'mongoTemplate' threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.util.Assert.noNullElements(Ljava/util/Collection;Ljava/lang/String;)V
When looking into this issue, found that I need to add sping-core (5.2.5 or later) for this, that in turn is asking for other spring dependencies to be on same version.
This whole defeats the goal of having spring boot for ease of dependency management.
It feels like spring ecosystem has become so complex, that upgrading mongo-java-driver would need the un-necessary work of upgrading the whole application to newer version of springboot which are not backward compatible and will break the application build. Any suggestions to get rid of this issue.
i'm using these pom you can give it a try for mongo-3.8.2 and spring-data :1.10.0
. Make sure you are not missing "spring-data-commons-core jar"
<properties>
<mongo.java.driver.version>3.8.2</mongo.java.driver.version>
<spring.data.version>1.10.0.RELEASE</spring.data.version>
</properties>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>${mongo.java.driver.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons-core</artifactId>
<version>1.4.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>${spring.data.version}</version>
</dependency>

Spring Kafka (2.2.7.RELEASE) with. kafka-clients:2.2.1 IOException during embedded broker startup

Driven by a dependency-check warning we tried to bump the version of org.apache.kafka:kafka-clients to version 2.2.1 in our setup, using spring-kafka:2.2.7.
As a result the tests using EmbeddedKafkaRule fail during broker startup with an IOException claiming "Failed to load /some/path.."
java.io.IOException: Failed to load /Users/[..]/target/embedded-kafka during broker startup
at kafka.log.LogManager$$anonfun$createAndValidateLogDirs$1.apply(LogManager.scala:152)
at kafka.log.LogManager$$anonfun$createAndValidateLogDirs$1.apply(LogManager.scala:149)
at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
at kafka.log.LogManager.createAndValidateLogDirs(LogManager.scala:149)
at kafka.log.LogManager.<init>(LogManager.scala:80)
at kafka.log.LogManager$.apply(LogManager.scala:953)
at kafka.server.KafkaServer.startup(KafkaServer.scala:237)
at kafka.utils.TestUtils$.createServer(TestUtils.scala:132)
at kafka.utils.TestUtils.createServer(TestUtils.scala)
at org.springframework.kafka.test.EmbeddedKafkaBroker.afterPropertiesSet(EmbeddedKafkaBroker.java:223)
at org.springframework.kafka.test.rule.EmbeddedKafkaRule.before(EmbeddedKafkaRule.java:109)
at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:46)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
We made sure, to have no conflicting version of kafka-clients on the classpath and also tried to specify the logs.dir of the EmbeddedKafkaRule to some folder under maven's target folder, "target/embedded-kafka" in the above example.
Both with no success.
Did anybody have the same issue and resolve it?
I just tested it without any problems.
Did you follow the instructions in the documentation about overriding kafka client versions?.
When you use spring-kafka-test (version 2.2.x) with the 2.1.x kafka-clients jar, you need to override certain transitive dependencies, as follows:
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
<version>${spring.kafka.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka-test</artifactId>
<version>${spring.kafka.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.11</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>2.1.1</version>
<classifier>test</classifier>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.12</artifactId>
<version>2.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.12</artifactId>
<version>2.1.1</version>
<classifier>test</classifier>
<scope>test</scope>
</dependency>
Note that when switching to scala 2.12 (recommended for 2.1.x and higher), the 2.11 version must be excluded from spring-kafka-test.

Cannot get connection for redisTemplate for Spring data redis

I'm trying to publish a message to a channel using Spring data Redis using Jedis. Here is a very simple Java config:
#Bean(name="jedisConnectionFactory")
JedisConnectionFactory jedisConnectionFactory() {
JedisConnectionFactory factory = new JedisConnectionFactory();
factory.setHostName(redisHostName);
factory.setPort(redisPort);
factory.setUsePool(true);
return factory;
}
#Bean(name="redisTemplate")
RedisTemplate<Object, Object> redisTemplate() {
RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<Object, Object>();
redisTemplate.setConnectionFactory(jedisConnectionFactory());
return redisTemplate;
}
where redisPort=6379 and redisHostName="localhost".
When I run the following test:
#Test
public void testRedis(){
ApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
RedisTemplate<Object,Object> redisTemplate = (RedisTemplate<Object, Object>) context.getBean("redisTemplate");
redisTemplate.convertAndSend("test", "123");
}
I get the following stacktrace:
java.lang.ExceptionInInitializerError
at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:252)
at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:58)
at org.springframework.data.redis.core.RedisConnectionUtils.doGetConnection(RedisConnectionUtils.java:128)
at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:91)
at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:78)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:178)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:153)
at org.springframework.data.redis.core.RedisTemplate.convertAndSend(RedisTemplate.java:676)
at com.jobvite.realtimeanalytics.redis.RedisTest.testRedis(RedisTest.java:22)
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 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:73)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:73)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:224)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:83)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:68)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:163)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
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 org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.lang.NullPointerException
at org.springframework.util.ReflectionUtils.makeAccessible(ReflectionUtils.java:443)
at org.springframework.data.redis.connection.jedis.JedisConnection.<clinit>(JedisConnection.java:108)
... 44 more
This issue is caused by the Jedis version (2.7.2) not compatible with Spring Data Redis (1.5.0.RELEASE). I used 3 days facing the same issue before I get inspired by this post and comment. Jedis version (2.6.2) is working fine (although I hit other errors in my program, but at least it have some progress than the same error message)!
Thanks.
Turns out I was using Jedis 2.7.2 but Spring Data Redis 1.5.0 seems to be compatible with Jedis 2.6.2. I wish this were a little clearer in the documentation somehow.
I have also faced a similar kind of issue. I did some research and found out that it is due to a jar conflict.
Compatible version i am using in my application is :
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>1.8.10.RELEASE</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.0</version>
</dependency>
Or if you are using spring boot simply add the following dependency. Spring boot is smart enough to auto resolve such issues.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
I hope it helps !!
Compatible version:
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>1.5.0.RELEASE</version>
</dependency>
Version, I encountered the same problem,this spring-data-redis 1.5.0 pom
<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>1.5.0.RELEASE</version>
<name>Spring Data Redis</name>
<description>Spring Data Redis</description>
<url>http://github.com/spring-projects/spring-data-redis</url>
<organization>
<name>Pivotal Software, Inc.</name>
<url>http://projects.spring.io/spring-data-redis</url>
</organization>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>costin</id>
<name>Costin Leau</name>
<email>cleau#vmware.com</email>
<properties>
<twitter>costinl</twitter>
</properties>
</developer>
<developer>
<id>jencompgeek</id>
<name>Jennifer Hickey</name>
<properties>
<twitter>jencompgeek</twitter>
</properties>
</developer>
<developer>
<id>christophstrobl</id>
<name>Christoph Strobl</name>
<properties>
<twitter>stroblchristoph</twitter>
</properties>
</developer>
<developer>
<id>thomasdarimont</id>
<name>Thomas Darimont</name>
<properties>
<twitter>thomasdarimont</twitter>
</properties>
</developer>
</developers>
<scm>
<connection>scm:git:git://github.com/spring-projects/spring-data-redis</connection>
<developerConnection>scm:git:git://github.com/spring-projects/spring-data-redis</developerConnection>
<url>http://github.com/spring-projects/spring-data-redis</url>
</scm>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>4.0.9.RELEASE</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.0.9.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.8.8</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>4.0.9.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>4.0.9.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jredis</groupId>
<artifactId>jredis-core-ri</artifactId>
<version>06052013</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.6.2</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>4.0.9.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.0.9.RELEASE</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils-core</artifactId>
<version>1.8.3</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.2</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.github.spullara.redis</groupId>
<artifactId>client</artifactId>
<version>0.7</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.5.1</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.10</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.lambdaworks</groupId>
<artifactId>lettuce</artifactId>
<version>2.3.3</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jredis</groupId>
<artifactId>jredis-core-api</artifactId>
<version>06052013</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.5.1</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
</dependencies>
</project>
Navin Viswanath, thank you for the solution! How did you find it, using docs or debugging?
For those who use Gradle, here is my combination:
Versions:
Redis 3.0.2
Jedis 2.7.2
Spring Data Redis 1.6.0 M1 (not available in maven central, because it's milestone release - add http://repo.spring.io/milestone/ repo)
build.gradle:
repositories {
mavenCentral()
maven { url 'http://repo.spring.io/release/' }
maven { url 'http://repo.spring.io/milestone/' }
}
dependencies {
compile group: 'redis.clients', name: 'jedis', version: '2.7.2'
compile group: 'org.springframework.data', name: 'spring-data-redis', version: '1.6.0.M1'
}
Please note that Spring Data Redis 1.6.0.M1 will be removed once it becomes release, you need to change it to 1.6.0.RELEASE when it is available as release.
So, I checked for version compatibility here: https://github.com/spring-projects/spring-data-redis/blob/master/gradle.properties and found related JIRA ticket here: https://jira.spring.io/browse/DATAREDIS-396
had a similar problem with spring-boot-starter-data-redis 2.0.4
when i implicitly put the dependency to jedis in the app pom.xml it somehow worked
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.0</version>
</dependency>
eclipse complains about "Duplicating managed version", but everything else works
Compatible version:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>2.0.4.RELEASE</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.0</version>
</dependency>
Since July 2019, Spring Boot 2.X was compatible with Jedis 3.X (See Upgrade to Jedis 3.1.0 for more info).
For those who use Gradle, an example is as follows:
build.gradle
plugins {
id 'org.springframework.boot' version '2.3.2.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'redis.clients:jedis:3.1.0'
}
For those using Spring-boot-starter-data-redis
A permanent fix can be entered as follows:
Determine the version of spring-boot-starter-data-redis. In
eclipse, you can mouse over the dependency entry in your pom.xml
file. It will tell you the version you are using.
Navigate to that version directory in your maven repository.
Edit the pom file and add the version number of redis client that is needed. In this case version 2.6.2.RELEASE to go with version
1.50 of spring-boot-starter-data-redis. In this case I had to add <version>2.6.2.RELEASE</version.
In your IDE, refresh your entire project. To do this in eclipse or STS, click once on the project name->right click select maven->Update Project
Check your maven dependencies list and the jedis version should now be 2.6.2.
Compile your project.
Open the .war archive with jar or 7-zip etc. Find the lib directory under WEB-INF and verify the presence of jedis-2.6.2.
That should resolve the issue.
You can find spring data maven version compatible with jedis maven version from bellow link: https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-redis/1.5.9.RELEASE

Spring annotation configuration java.lang.NoClassDefFoundError: org/objectweb/asm/util/TraceClassVisitor

i am trying to run a very simple Spring application with java configuration. i am getting the following exception and i dont understand why. as far as i can tell i have all the required dependencies
public static void main(String[] args)
{
System.out.println( "Hello World from main!" );
ApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfig.class);
HelloWorld helloWorld = ctx.getBean(HelloWorld.class);
System.out.println( helloWorld.getMessage() );
}
The exception occures at - AnnotationConfigApplicationContext function call
worth mentioning:
I have the following dependency in my POM.XML file.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-asm</artifactId>
<version>${org.springframework.version}</version>
</dependency>
And the exception:
Exception in thread "main" java.lang.IllegalStateException: Cannot load configuration class: spring.play.springStart.AppConfig
at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:313)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:197)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:681)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:620)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:446)
at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:73)
at spring.play.springStart.App.main(App.java:14)
Caused by: java.lang.NoClassDefFoundError: org/objectweb/asm/util/TraceClassVisitor
at net.sf.cglib.core.DebuggingClassWriter.toByteArray(DebuggingClassWriter.java:73)
at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:26)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:144)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:116)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
at org.springframework.context.annotation.ConfigurationClassEnhancer.newEnhancer(ConfigurationClassEnhancer.java:136)
at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:109)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:303)
... 6 more
Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.util.TraceClassVisitor
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 17 more
I actually don't really know what solved the problem, but I did go to some tutorial website that does the same thing and just copied their pom file dependencies.
I still don't understand what was missing.
In any case Balint Bako might be right with his answer but i am not sure, i got it solved by the time I got back to StackOverflow.
Here is the pom file
<!-- Spring 3 dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- JavaConfig need this library -->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2.2</version>
</dependency>
Good luck
As per exception it seems that ASM related jar is missing. You can add asm-all
<dependency>
<groupId>asm</groupId>
<artifactId>asm-all</artifactId>
<version>2.1</version>
</dependency>
It worked with me with following dependencies. Thanks Rubens Mariuzzo. You cracked with cglib version problem. It never worked with 3.0 but worked with 2.2.2
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>3.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>3.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2.2</version>
</dependency>
</dependencies>
You need spring-core too.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework.version}</version>
</dependency>
I had same issue when using Spock unit test framework, and using Spy test.
I overcome this issue by add this into my Maven dependencies.
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>3.3.0</version>
</dependency>