Netflix / Hystrix

Hystrix is a latency and fault tolerance library designed to isolate points of access to remote systems, services and 3rd party libraries, stop cascading failure and enable resilience in complex distributed systems where failure is inevitable.
24.07k stars 4.7k forks source link

@HystrixCommand Class not found error #1800

Open codewithwind opened 6 years ago

codewithwind commented 6 years ago

when i use @HystrixCommand in my project, a problem occur

code: @HystrixCommand(groupKey= "defaultQueryProcess", commandKey = "queryProcess", fallbackMethod = "fallback", threadPoolProperties = { @HystrixProperty(name = "coreSize", value = "20"), @HystrixProperty(name = "maxQueueSize", value = "1000")}, commandProperties = { @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "100")}) public Future executeAsync(QueryProcessRequest request) { return new AsyncResult(){ @Override public QueryProcessResult invoke(){ return execute(request); } }; }

Caused by: java.io.IOException: Class not found at org.objectweb.asm.ClassReader.a(Unknown Source) at org.objectweb.asm.ClassReader.(Unknown Source) at org.objectweb.asm.ClassReader.(Unknown Source) at com.netflix.hystrix.contrib.javanica.utils.MethodProvider.unbride(MethodProvider.java:238) at com.netflix.hystrix.contrib.javanica.utils.AopUtils.getDeclaredMethod(AopUtils.java:94)

dmalch commented 6 years ago

I also experience the same issue, I found out that it happens for generic classes declared in nested jars of a Spring Boot application. The root cause was that the class ClassReader from ASM uses ClassLoader.getSystemResourceAsStream() method, which doesn't see the class file. A possible fix would be to load the class bytes independently and provide them to ClassReader.

dmalch commented 6 years ago

Created a PR https://github.com/Netflix/Hystrix/pull/1831