Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BoundHashOperations referenced from a method is not visible from class loader #2772

Closed
sthakore-atlassian opened this issue Nov 16, 2023 · 9 comments

Comments

@sthakore-atlassian
Copy link

sthakore-atlassian commented Nov 16, 2023

Hello,

We moved from spring-boot 2 to spring boot 3 and upgraded the spring-data-redis. We are facing an issue with spring-data-redis 3.1.2 version with below error stack trace at runtime.

java.lang.IllegalArgumentException: org.springframework.data.redis.core.BoundHashOperations referenced from a method is not visible from class loader
	at java.base/java.lang.reflect.Proxy$ProxyBuilder.ensureVisible(Unknown Source)
	at java.base/java.lang.reflect.Proxy$ProxyBuilder.validateProxyInterfaces(Unknown Source)
	at java.base/java.lang.reflect.Proxy$ProxyBuilder.<init>(Unknown Source)
	at java.base/java.lang.reflect.Proxy.lambda$getProxyConstructor$1(Unknown Source)
	at java.base/jdk.internal.loader.AbstractClassLoaderValue$Memoizer.get(Unknown Source)
	at java.base/jdk.internal.loader.AbstractClassLoaderValue.computeIfAbsent(Unknown Source)
	at java.base/java.lang.reflect.Proxy.getProxyConstructor(Unknown Source)
	at java.base/java.lang.reflect.Proxy.newProxyInstance(Unknown Source)
	at org.springframework.aop.framework.JdkDynamicAopProxy.getProxy(JdkDynamicAopProxy.java:123)
	at org.springframework.aop.framework.JdkDynamicAopProxy.getProxy(JdkDynamicAopProxy.java:115)
	at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:97)
	at org.springframework.data.redis.core.BoundOperationsProxyFactory.createProxy(BoundOperationsProxyFactory.java:73)
	at org.springframework.data.redis.core.RedisTemplate.boundHashOps(RedisTemplate.java:985)

Below is the function we are trying to call

var hashOperations = redisTemplate.<Integer, String>boundHashOps(getEtagKey(referenceId));

Any clue what is happening here at run-time ?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 16, 2023
@mp911de
Copy link
Member

mp911de commented Nov 16, 2023

Can you provide a reproducer? Attempting to reproduce failed with a Spring Boot 3 app:

@Bean
CommandLineRunner clr(RedisTemplate<String, String> template) {
	return args -> {
		template.boundHashOps("my-key").entries();
	};
}

Please provide also the version number of Spring Boot and Spring Data Redis.

@mp911de mp911de added the status: waiting-for-feedback We need additional information before we can continue label Nov 16, 2023
@sthakore-atlassian
Copy link
Author

Hey @mp911de Thanks for your quick response.

Spring Boot : 3.1.2
Spring Data Redis : 3.1.2

It's failing here in first line where we call boundHashOps

var hashOperations = redisTemplate.<Integer, String>boundHashOps("abc");

hashOperations.put(8463,"xyz");
hashOperations.expire(Duration.ofHours(6));

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Nov 16, 2023
@mp911de
Copy link
Member

mp911de commented Nov 16, 2023

Still cannot reproduce. Can you provide please a minimal reproducer? Using https://start.spring.io will get you started.

@mp911de mp911de added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Nov 16, 2023
@jxblum
Copy link
Contributor

jxblum commented Nov 16, 2023

Is this the full Stack Trace? I suspect not.

Also, in what context is your Spring application running? Is this a Web application inside Apache Tomcat, Eclipse Jetty, or some other container environment?

Are you using a custom ClassLoader, perhaps?

What dependencies are on your Spring application classpath?

NOTE: I only ask this last question because some users have experienced anomalies when other libraries, such as Redisson (for example), are also on their Spring application classpath. I am not saying Redisson is the issue or that this is your issue in particular, but having a snapshot of your dependencies might help shed more light on the problem.

Are you by chance using Java's module system and modulepath?

The jump from Spring Boot 2 to Spring Boot 3 also suggests that you moved from (possibly, as early as) Java 8 to minimally Java 17.

Since this is not readily reproducible, it is unlikely to be a specific problem with Spring Data Redis, therefore a small, self-contained reproducer will help us help you.

Thanks.

@jxblum
Copy link
Contributor

jxblum commented Nov 16, 2023

NOTE: Upon closer inspection, given the "ETag" reference from your snippet of code above, I gather this is a Spring Web application. As such, you are at the mercy of your Servlet container's ClassLoader(s), most likely.

@jxblum
Copy link
Contributor

jxblum commented Nov 16, 2023

As @mp911de did above, I also wrote a quick test class based on this issue for a sanity check.

You can see the dependencies of my (test) classpath here along with the parent.

This test passes as expected and I am using Spring Boot 3.1.5 (which pulls in Spring Data Redis 3.1.5); see here.

I also thought of 1 last thing... what Java Runtime Environment are you using?

Hopefully you can reproduce this issue in a small, self-contained example/test. Here is a link from start.spring.io to get you started.

@spring-projects-issues
Copy link

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Nov 23, 2023
@spring-projects-issues
Copy link

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

@spring-projects-issues spring-projects-issues closed this as not planned Won't fix, can't repro, duplicate, stale Nov 30, 2023
@spring-projects-issues spring-projects-issues removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged labels Nov 30, 2023
@jianxia612
Copy link

jianxia612 commented Dec 17, 2024

This Exception Because CompletableFuture,Executor Paramters,Use ForkJoinPool

https://stackoverflow.com/questions/49113207/completablefuture-forkjoinpool-set-class-loader

I Use Custom Executor ThreadPool solve this exception

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants