question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`repeated interface: org.springframework.aop.SpringProxy` with spring-security annotations on `@RestController`

See original GitHub issue

I get following error as soon as I use both @RequiredArgsConstructor and @PreAuthorize in the same a @RestController :

[INFO]     [creator]     Error: Error parsing dynamic proxy configuration in file:/workspace/META-INF/native-image/org.springframework.aot/spring-aot/proxy-config.json:
[INFO]     [creator]     java.lang.IllegalArgumentException: repeated interface: org.springframework.aop.SpringProxy
[INFO]     [creator]     Verify that the configuration matches the schema described in the -H:PrintFlags=+ output for option DynamicProxyConfigurationResources.
[INFO]     [creator]     com.oracle.svm.core.util.UserError$UserException: Error parsing dynamic proxy configuration in file:/workspace/META-INF/native-image/org.springframework.aot/spring-aot/proxy-config.json:
[INFO]     [creator]     java.lang.IllegalArgumentException: repeated interface: org.springframework.aop.SpringProxy
[INFO]     [creator]     Verify that the configuration matches the schema described in the -H:PrintFlags=+ output for option DynamicProxyConfigurationResources.
[INFO]     [creator]            at com.oracle.svm.core.util.UserError.abort(UserError.java:68)
[INFO]     [creator]            at com.oracle.svm.hosted.config.ConfigurationParserUtils.doParseAndRegister(ConfigurationParserUtils.java:139)
[INFO]     [creator]            at com.oracle.svm.hosted.config.ConfigurationParserUtils.lambda$parseAndRegisterConfigurations$3(ConfigurationParserUtils.java:120)
[INFO]     [creator]            at java.base/java.util.stream.ReferencePipeline$4$1.accept(ReferencePipeline.java:212)
[INFO]     [creator]            at com.oracle.svm.hosted.config.ConfigurationParserUtils$1.tryAdvance(ConfigurationParserUtils.java:109)
[INFO]     [creator]            at java.base/java.util.Spliterator.forEachRemaining(Spliterator.java:326)
[INFO]     [creator]            at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658)
[INFO]     [creator]            at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:274)
[INFO]     [creator]            at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
[INFO]     [creator]            at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
[INFO]     [creator]            at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
[INFO]     [creator]            at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:312)
[INFO]     [creator]            at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734)
[INFO]     [creator]            at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
[INFO]     [creator]            at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
[INFO]     [creator]            at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
[INFO]     [creator]            at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
[INFO]     [creator]            at java.base/java.util.stream.IntPipeline.reduce(IntPipeline.java:491)
[INFO]     [creator]            at java.base/java.util.stream.IntPipeline.sum(IntPipeline.java:449)
[INFO]     [creator]            at com.oracle.svm.hosted.config.ConfigurationParserUtils.parseAndRegisterConfigurations(ConfigurationParserUtils.java:126)
[INFO]     [creator]            at com.oracle.svm.reflect.proxy.hosted.DynamicProxyFeature.duringSetup(DynamicProxyFeature.java:80)
[INFO]     [creator]            at com.oracle.svm.hosted.NativeImageGenerator.lambda$setupNativeImage$18(NativeImageGenerator.java:915)
[INFO]     [creator]            at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:71)
[INFO]     [creator]            at com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:915)
[INFO]     [creator]            at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:580)
[INFO]     [creator]            at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$2(NativeImageGenerator.java:495)
[INFO]     [creator]            at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
[INFO]     [creator]            at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
[INFO]     [creator]            at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
[INFO]     [creator]            at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
[INFO]     [creator]            at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
[INFO]     [creator]            at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
[INFO]     [creator]     Error: Image build request failed with exit status 1
[INFO]     [creator]     unable to invoke layer creator
[INFO]     [creator]     unable to contribute native-image layer
[INFO]     [creator]     error running build
[INFO]     [creator]     exit status 1
[INFO]     [creator]     ERROR: failed to build: exit status 1

This can be reproduced starting from security-method-webflux sample and running mvn spring-boot:build-image. A PR reproducing the error follows.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:34 (17 by maintainers)

github_iconTop GitHub Comments

2reactions
aclementcommented, Aug 28, 2021

The ordering of the interfaces being important is actually a Java thing, from https://docs.oracle.com/javase/7/docs/technotes/guides/reflection/proxy.html

Note that the order of the specified proxy interfaces is significant: two requests for a proxy class with the same
combination of interfaces but in a different order will result in two distinct proxy classes. Proxy classes are
distinguished by the order of their proxy interfaces in order to provide deterministic method invocation
encoding in cases where two or more of the proxy interfaces share a method with the same name and 
parameter signature.
1reaction
ch4mpycommented, Aug 28, 2021

@arielcarrera with your latest commit, my project builds valid docker native-images on Windows without any additional proxy-config.json file (as it was already doing on Linux).

Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Interface Driven Controllers in Spring - Baeldung
Learn how to create controllers using Spring MVC request annotation on Java interfaces.
Read more >
Spring Boot Reference Documentation
Spring Boot dependencies use the org.springframework.boot groupId . ... The @RestController and @RequestMapping annotations are Spring MVC annotations (they ...
Read more >
Spring boot RestController won't work with classes which ...
I tried this with a class which does not implement any interface and that works fine. Here is the code package com.my.service; import...
Read more >
Core Spring 4.2 Certification Mock Exam | Java & Moi
The method annotated with @PostConstruct is called after bean instantiation and before properties setting of the bean.
Read more >
Go Native with Spring Boot and GraalVM - InfoQ
For Spring Framework 5.x & Spring Boot 2.x, Spring Native is the way to go. ... Test; import org.springframework.beans.factory.annotation.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found