tkaczmarzyk / specification-arg-resolver

An alternative API for filtering data with Spring MVC & Spring Data JPA
Apache License 2.0
658 stars 149 forks source link

Interface extending Specification referenced from a method is not visible from class loader #255

Closed azlekov closed 1 year ago

azlekov commented 1 year ago

On Spring Boot 3.1.0 using Java 17 cannot use interfaces extending Specification. If I put @Spec annotations right next to a Specification parameter in the controller - works fine.

java.lang.IllegalArgumentException: com.example.domain.AccountSpec referenced from a method is not visible from class loader
    at java.base/java.lang.reflect.Proxy$ProxyBuilder.ensureVisible(Proxy.java:883) ~[na:na]
    at java.base/java.lang.reflect.Proxy$ProxyBuilder.validateProxyInterfaces(Proxy.java:721) ~[na:na]
    at java.base/java.lang.reflect.Proxy$ProxyBuilder.<init>(Proxy.java:648) ~[na:na]
    at java.base/java.lang.reflect.Proxy$ProxyBuilder.<init>(Proxy.java:656) ~[na:na]
    at java.base/java.lang.reflect.Proxy.lambda$getProxyConstructor$0(Proxy.java:429) ~[na:na]
    at java.base/jdk.internal.loader.AbstractClassLoaderValue$Memoizer.get(AbstractClassLoaderValue.java:329) ~[na:na]
    at java.base/jdk.internal.loader.AbstractClassLoaderValue.computeIfAbsent(AbstractClassLoaderValue.java:205) ~[na:na]
    at java.base/java.lang.reflect.Proxy.getProxyConstructor(Proxy.java:427) ~[na:na]
    at java.base/java.lang.reflect.Proxy.newProxyInstance(Proxy.java:1037) ~[na:na]
    at net.kaczmarzyk.spring.data.jpa.web.EnhancerUtil.wrapWithIfaceImplementation(EnhancerUtil.java:34) ~[specification-arg-resolver-3.0.0.jar:na]
    at net.kaczmarzyk.spring.data.jpa.web.SpecificationFactory.createSpecificationDependingOn(SpecificationFactory.java:73) ~[specification-arg-resolver-3.0.0.jar:na]
    at net.kaczmarzyk.spring.data.jpa.web.SpecificationArgumentResolver.resolveArgument(SpecificationArgumentResolver.java:85) ~[specification-arg-resolver-3.0.0.jar:na]
    at 

Any clues or ideas?

azlekov commented 1 year ago

Removing dev tools did the job, disabling it should also be fine I guess. Reference: https://stackoverflow.com/a/71355838/1274974