Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

ExecuteGroovyScript: The following classes appear as argument class and as parameter class, but are defined by different class loader

avatar
New Contributor

Just trying to use a simple Groovy Script for setting TTL on redis keys with a given pattern.

 

 

@Grab(group='org.springframework.data', module='spring-data-redis', version='2.6.2')
import org.springframework.data.redis.connection.RedisConnection
import org.springframework.data.redis.core.ScanOptions


def pool = CTL.redis.getConnection()
pool.withCloseable {conn->
  def keyPattern = 'raw:extra:*'
  def scanOptions = ScanOptions.scanOptions().match(keyPattern).build()
  def cursor = conn.keyCommands().scan(scanOptions)
  while(cursor.hasNext()) {
    def key = cursor.next()
    // Check if the key has a TTL
    if(conn.keyCommands().pTtl(key) == -1) {
      // Set a 15 days TTL for the key
      conn.keyCommands().expire(key, 15 * 24 * 60 * 60)
    }
  }
}

 

 

However this is giving this specific error. I tried using KeyScanOptions, without grabbing the spring-data-redis and a builder. Still getting the same error. 

 

 

ExecuteGroovyScript[id=6f743677-05b0-1622-bb0b-cbb0e5127a50] groovy.lang.MissingMethodException: No signature of method: com.sun.proxy.$Proxy6940493.scan() is applicable for argument types: (org.springframework.data.redis.core.ScanOptions) values: [org.springframework.data.redis.core.ScanOptions@558a5d9a]
Possible solutions: scan(org.springframework.data.redis.core.KeyScanOptions), scan(org.springframework.data.redis.core.ScanOptions), any(), each(groovy.lang.Closure), tap(groovy.lang.Closure), any(groovy.lang.Closure)
The following classes appear as argument class and as parameter class, but are defined by different class loader:
org.springframework.data.redis.core.ScanOptions (defined by 'groovy.lang.GroovyClassLoader@2ddbb9b9' and 'org.apache.nifi.nar.NarClassLoader[./work/nar/extensions/nifi-redis-service-api-nar-1.16.0.nar-unpacked]')
If one of the method suggestions matches the method you wanted to call, 
then check your class loader setup.: groovy.lang.MissingMethodException: No signature of method: com.sun.proxy.$Proxy6940493.scan() is applicable for argument types: (org.springframework.data.redis.core.ScanOptions) values: [org.springframework.data.redis.core.ScanOptions@558a5d9a]
Possible solutions: scan(org.springframework.data.redis.core.KeyScanOptions), scan(org.springframework.data.redis.core.ScanOptions), any(), each(groovy.lang.Closure), tap(groovy.lang.Closure), any(groovy.lang.Closure)
The following classes appear as argument class and as parameter class, but are defined by different class loader:
org.springframework.data.redis.core.ScanOptions (defined by 'groovy.lang.GroovyClassLoader@2ddbb9b9' and 'org.apache.nifi.nar.NarClassLoader[./work/nar/extensions/nifi-redis-service-api-nar-1.16.0.nar-unpacked]')
If one of the method suggestions matches the method you wanted to call, 
then check your class loader setup.

 

 

I checked the folder and it has spring-data-redis:2.6.2 under this one. I also tried using keys for key lookup and it works but I don't want to use keys for performance reasons. Other functions are working fine but just ScanOptions is giving this specific error. 

2 REPLIES 2

avatar
Super Collaborator

Did you try what the error says?

Possible solutions: scan(org.springframework.data.redis.core.KeyScanOptions)

avatar
New Contributor

yea I tried using KeyScanOptions as well but the same error