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

Add native runtime hints for weaver-messages #227

Closed
d-eder opened this issue Mar 18, 2023 · 8 comments
Closed

Add native runtime hints for weaver-messages #227

d-eder opened this issue Mar 18, 2023 · 8 comments
Assignees
Labels
enhancement New feature or request graal-vm

Comments

@d-eder
Copy link

d-eder commented Mar 18, 2023

When AOP is failing due to an exception on native applications, an exception is thrown that it cannot find the resources for org.aspectj.weaver.weaver-messages (see stacktrace).

According to my MR on spring boot, we should provide native hints directly on the library or on the GraalVM repo.

Testing environment

  • spring boot 3.0.4 (which uses org.aspectj:aspectjweaver:1.9.19)
  • graal vm 17.0.5
  • graal vm gradle plugin: org.graalvm.buildtools.native 0.9.20
2023-03-10T06:42:43.871Z ERROR 1 --- [           main] o.s.boot.SpringApplication               : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configurationPropertiesBeans': null
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:606) ~[com.deder.wol.WolApplicationKt:6.0.6]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[com.deder.wol.WolApplicationKt:6.0.6]
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[com.deder.wol.WolApplicationKt:6.0.6]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[com.deder.wol.WolApplicationKt:6.0.6]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[com.deder.wol.WolApplicationKt:6.0.6]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:205) ~[com.deder.wol.WolApplicationKt:6.0.6]
        at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:273) ~[na:na]
        at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:763) ~[com.deder.wol.WolApplicationKt:6.0.6]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:568) ~[com.deder.wol.WolApplicationKt:6.0.6]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[com.deder.wol.WolApplicationKt:3.0.4]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) ~[com.deder.wol.WolApplicationKt:3.0.4]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) ~[com.deder.wol.WolApplicationKt:3.0.4]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:310) ~[com.deder.wol.WolApplicationKt:3.0.4]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1304) ~[com.deder.wol.WolApplicationKt:3.0.4]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1293) ~[com.deder.wol.WolApplicationKt:3.0.4]
        at com.deder.wol.WolApplicationKt.main(WolApplication.kt:13) ~[com.deder.wol.WolApplicationKt:na]
Caused by: java.lang.ExceptionInInitializerError: null
        at org.aspectj.weaver.patterns.ExactAnnotationTypePattern.verifyIsAnnotationType(ExactAnnotationTypePattern.java:354) ~[com.deder.wol.WolApplicationKt:na]
        at org.aspectj.weaver.patterns.ExactAnnotationTypePattern.resolveBindings(ExactAnnotationTypePattern.java:318) ~[com.deder.wol.WolApplicationKt:na]
        at org.aspectj.weaver.patterns.AnnotationPointcut.resolveBindings(AnnotationPointcut.java:184) ~[na:na]
        at org.aspectj.weaver.patterns.Pointcut.resolve(Pointcut.java:189) ~[com.deder.wol.WolApplicationKt:na]
        at org.aspectj.weaver.tools.PointcutParser.resolvePointcutExpression(PointcutParser.java:331) ~[com.deder.wol.WolApplicationKt:na]
        at org.aspectj.weaver.reflect.InternalUseOnlyPointcutParser.resolvePointcutExpression(InternalUseOnlyPointcutParser.java:36) ~[na:na]
        at org.aspectj.weaver.reflect.Java15ReflectionBasedReferenceTypeDelegate.getDeclaredPointcuts(Java15ReflectionBasedReferenceTypeDelegate.java:307) ~[na:na]
        at org.aspectj.weaver.ReferenceType.getDeclaredPointcuts(ReferenceType.java:890) ~[com.deder.wol.WolApplicationKt:1.9.19]
        at org.aspectj.weaver.ResolvedType$PointcutGetter.get(ResolvedType.java:261) ~[na:na]
        at org.aspectj.weaver.ResolvedType$PointcutGetter.get(ResolvedType.java:258) ~[na:na]
        at org.aspectj.weaver.Iterators$4$1.hasNext(Iterators.java:213) ~[na:na]
        at org.aspectj.weaver.Iterators$4.hasNext(Iterators.java:230) ~[na:na]
        at org.aspectj.weaver.ResolvedType.findPointcut(ResolvedType.java:767) ~[com.deder.wol.WolApplicationKt:1.9.19]
        at org.aspectj.weaver.patterns.ReferencePointcut.resolveBindings(ReferencePointcut.java:148) ~[na:na]
        at org.aspectj.weaver.patterns.OrPointcut.resolveBindings(OrPointcut.java:88) ~[na:na]
        at org.aspectj.weaver.patterns.Pointcut.resolve(Pointcut.java:189) ~[com.deder.wol.WolApplicationKt:na]
        at org.aspectj.weaver.tools.PointcutParser.resolvePointcutExpression(PointcutParser.java:331) ~[com.deder.wol.WolApplicationKt:na]
        at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:312) ~[com.deder.wol.WolApplicationKt:na]
        at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:222) ~[na:na]
        at org.springframework.aop.aspectj.AspectJExpressionPointcut.obtainPointcutExpression(AspectJExpressionPointcut.java:193) ~[na:na]
        at org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter(AspectJExpressionPointcut.java:172) ~[na:na]
        at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:226) ~[na:na]
        at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:288) ~[na:na]
        at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:320) ~[na:na]
        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:128) ~[com.deder.wol.WolApplicationKt:6.0.6]
        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:97) ~[com.deder.wol.WolApplicationKt:6.0.6]
        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:78) ~[com.deder.wol.WolApplicationKt:6.0.6]
        at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:366) ~[com.deder.wol.WolApplicationKt:6.0.6]
        at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:318) ~[com.deder.wol.WolApplicationKt:6.0.6]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:435) ~[com.deder.wol.WolApplicationKt:6.0.6]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1765) ~[com.deder.wol.WolApplicationKt:6.0.6]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:599) ~[com.deder.wol.WolApplicationKt:6.0.6]
        ... 15 common frames omitted
Caused by: java.util.MissingResourceException: Can't find bundle for base name org.aspectj.weaver.weaver-messages, locale en_US
        at [email protected]/java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:2045) ~[com.deder.wol.WolApplicationKt:na]
        at [email protected]/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1683) ~[com.deder.wol.WolApplicationKt:na]
        at [email protected]/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1586) ~[com.deder.wol.WolApplicationKt:na]
        at [email protected]/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1549) ~[com.deder.wol.WolApplicationKt:na]
        at [email protected]/java.util.ResourceBundle.getBundle(ResourceBundle.java:858) ~[com.deder.wol.WolApplicationKt:na]
        at org.aspectj.weaver.WeaverMessages.<clinit>(WeaverMessages.java:19) ~[na:na]
        ... 47 common frames omitted
@kriegaex
Copy link
Contributor

@aclement, please take a look at this. I know that you are part of the Spring Native team, so you probably know what this is about. I have no idea about GraalVM, never used it before and do not even know what a "native hint" is supposed to be.

Pointers:

https://github.com/eclipse/org.aspectj/blob/a8a2f82fda825b36acade534f876f595b6566919/org.aspectj.matcher/src/main/java/org/aspectj/weaver/WeaverMessages.java#L17-L19

This is the corresponding properties file.

@kriegaex
Copy link
Contributor

According to my MR on spring boot, we should provide native hints directly on the library or on the GraalVM repo.

@d-eder, AspectJ does not provide any special builds for GraalVM. Can you please explain what a "native hint" is meant to be and how AspectJ could be enhanced to provide one? I cannot do anything, if I do not understand what you are even asking of me. The person I assigned this issue to is unresponsive, so I cannot ask him either. Please explain and/or provide a PR.

@kriegaex
Copy link
Contributor

@d-eder, CC @mp911de, @Ricard-Kollcaku: I have zero GraalVM experience, like I said before. I asked a question, which I got no response to:

Can you please explain what a "native hint" is meant to be and how AspectJ could be enhanced to provide one? I cannot do anything, if I do not understand what you are even asking of me.

This issue is not going to magically solve itself by throwing something over the fence. Please tell me what exactly you need AspectJ to provide or create a PR. I have no intention of ignoring issues, but if Spring refuses to do something about it, arguing that AspectJ should, nothing will happen if I do not know what is expected from us here. Probably @aclement would know, as he knows GraalVM, but he has not been active in the project for quite a while. Thanks in advance to anyone who can she light on this matter.

@Ricard-Kollcaku
Copy link

Hi @kriegaex regarding my ticket this is resolved by spring boot team.

Hints are declaration that u do to graalvm when your code uses some classes for reflection (proxy, resources) things that graalvm cant detect in compile time.

@kriegaex
Copy link
Contributor

Thanks, @Ricard-Kollcaku. That does not help me much with regard to what exactly, if anything, I am expected to add to AspectJ to make it work out of the box. Are you saying, this issue can be closed, or would it be better to solve this in AspectJ to get rid of any Spring workarounds? I really have no clue and also not enough time to study this topic in depth. For a little while, I am going to wait for more feedback from everyone involved here before closing the issue as "won't fix", so everybody can speak up.

@d-eder
Copy link
Author

d-eder commented Mar 12, 2024

Sorry for the very late reply. When I find more time, I'll give it another try with updated versions.

You can check Spring GraalVM Native - Image Support and/or the GraalVM Page itself to get more information and knowledge about that.

What we would need is to inlcude the resource metadata similar to here.

Afaik we can add this somehow to this project (probably we need to add it somewhere to the classpath) or we can use the graalvm-reachability-metadata repo.

But maybe let's first evaluate, if it's still necessary and try to make it reproduceable.

@kriegaex
Copy link
Contributor

kriegaex commented Mar 14, 2024

@d-eder, like I said, I neither have time not feel much inclined to dig into the GraalVM docs and learn everything from scratch there. So thanks, but I would really appreciate a PR in this case. At the very least, I need whatever config files need to be added to AspectJ and an exact descriptions in which artifacts they are expected to reside where. Then, I can help with any packaging or build integration issues.

@d-eder
Copy link
Author

d-eder commented Jun 20, 2024

I quickly retested it and it seems to work now:

  • org.springframework.boot 3.3.0
  • org.graalvm.buildtools.native 0.10.2

@d-eder d-eder closed this as completed Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request graal-vm
Projects
None yet
Development

No branches or pull requests

4 participants