You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 23, 2023. It is now read-only.
We tried to use spring-native capabilities for our project but we failed to build it using Gradle: gradle clean assemble:
Caused by: java.lang.IllegalStateException: Multiple privileged packages: [demo.job.base, demo.job]
at org.springframework.aot.context.bootstrap.generator.infrastructure.ProtectedAccessAnalysis.getPrivilegedPackageName(ProtectedAccessAnalysis.java:57)
at org.springframework.aot.context.bootstrap.generator.bean.DefaultBeanRegistrationWriter.writeBeanRegistration(DefaultBeanRegistrationWriter.java:104)
at org.springframework.aot.context.bootstrap.generator.ApplicationContextAotProcessor.writeBeanDefinitions(ApplicationContextAotProcessor.java:128)
... 15 more
The error message doesn't actually explain what the error is and how to resolve it. Our investigation showed that this error occurs because of protected field being injected in Spring bean:
public abstract class BaseJob {
private final static Logger LOGGER = LoggerFactory.getLogger(BaseJob.class);
@Autowired
protected Service service;
If we change field access to public then our project is built successfully:
public abstract class BaseJob {
private final static Logger LOGGER = LoggerFactory.getLogger(BaseJob.class);
@Autowired
public Service service;
@sergey-morenets the fact that it works with private injection is just a corner case, really. The problem is injecting privileged components in a parent class that sits in another package. Spring AOT is turning your arrangement into a single programmatic equivalent that shows that your bean cannot be created "manually" (in a unit test, for instance).
Spring Native requires such a bean to be created manually so reviewing this arrangement is all that I can recommend at this time.
We're going to improve the error message in #1005. See also #1402.
Hi
We tried to use spring-native capabilities for our project but we failed to build it using Gradle: gradle clean assemble:
The error message doesn't actually explain what the error is and how to resolve it. Our investigation showed that this error occurs because of protected field being injected in Spring bean:
If we change field access to public then our project is built successfully:
So what is the error reason? Does spring-native not support field injection if field has private/protected access? Unfortunately I couldn't find any explanation in the documentation: https://docs.spring.io/spring-native/docs/current/reference/htmlsingle/
But if it's the case I would update the error message and make it more informative.
The text was updated successfully, but these errors were encountered: