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

Support for GraalVMs native-image #1243

Open
1 of 2 tasks
choubuzhaole opened this issue Dec 22, 2023 · 4 comments
Open
1 of 2 tasks

Support for GraalVMs native-image #1243

choubuzhaole opened this issue Dec 22, 2023 · 4 comments
Labels
core Core Modules help-wanted Help Wanted
Milestone

Comments

@choubuzhaole
Copy link

choubuzhaole commented Dec 22, 2023

Search before asking

  • I had searched in the issues and found no similar issues.

Feature Request

Hi!

Oracle has created the GraalVM and one of its features is the native-image tool, which allows compiling a JVM application into a native executable. This executable doesn't need a JVM to run, it starts faster and often consumes less memory. But this has downsides, as some dynamic features from Java are not supported without additional configuration. The biggest contenders are reflection, resources and proxies.

Luckily, a library can ship some JSON metadata in the META-INF/native-image/... directory which enables those features.

For libraries which don't (or can't) add the metadata in their JARs, Oracle has created the graalvm-reachability-repository, which contains this metadata outside of the libraries JAR file. In an ideal world, all of the metadata is moved into the JARs of the libraries, but until our world has reached its ideal state, this repository will be used.

We are hardly waiting for GrallVM native-image support in officially Shiro repository.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!
@lprimak
Copy link
Contributor

lprimak commented Dec 22, 2023

A PR would be welcome!

@lprimak lprimak added shiro-2.0.0 core Core Modules help-wanted Help Wanted labels Dec 22, 2023
@fpapon
Copy link
Member

fpapon commented Dec 23, 2023

@choubuzhaole I cannot see any reference to Apache Shiro in the graalvm-reachibility-metadata repository. Are sure that there is some Apache Shiro related content?

@choubuzhaole
Copy link
Author

Hello, my description is wrong, there is indeed no reference to apache shiro in graalvm-reachability-repository. That’s why it asks whether it supports graalvm

@choubuzhaole
Copy link
Author

Currently I'm trying to use graalvm to compile my project into an executable

version

graalvm: graalvm-community-jdk-21.0.1
spring-boot:3.2.0
shiro:1.11.0

It compiles fine and when I launch the executable I get the following problem

org.springframework.context.ApplicationContextException: Unable to start web server
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:165)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:610)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:753)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:455)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:323)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1342)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1331)
	at com.nis.AdminApplication.main(AdminApplication.java:32)
	at [email protected]/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:142)
	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:104)
	at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:501)
	at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:218)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:188)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:162)
	... 9 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'shiroFilter': FactoryBean threw exception on object creation
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:188)
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:124)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1810)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getObjectForBeanInstance(AbstractAutowireCapableBeanFactory.java:1277)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:258)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
	at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:210)
	at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:173)
	at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:168)
	at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAdaptableBeans(ServletContextInitializerBeans.java:153)
	at org.springframework.boot.web.servlet.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:86)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans(ServletWebServerApplicationContext.java:266)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:240)
	at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:52)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4850)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)
	at [email protected]/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
	at [email protected]/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866)
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:845)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)
	at [email protected]/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
	at [email protected]/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866)
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:240)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:433)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:917)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
	at org.apache.catalina.startup.Tomcat.start(Tomcat.java:488)
	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:123)
	... 14 common frames omitted
Caused by: org.apache.shiro.util.InstantiationException: Unable to instantiate class [org.apache.shiro.web.filter.authz.HttpMethodPermissionFilter]
	at org.apache.shiro.util.ClassUtils.newInstance(ClassUtils.java:208)
	at org.apache.shiro.web.filter.mgt.DefaultFilter.newInstance(DefaultFilter.java:62)
	at org.apache.shiro.web.filter.mgt.DefaultFilterChainManager.addDefaultFilters(DefaultFilterChainManager.java:382)
	at org.apache.shiro.web.filter.mgt.DefaultFilterChainManager.<init>(DefaultFilterChainManager.java:65)
	at org.apache.shiro.spring.web.ShiroFilterFactoryBean.createFilterChainManager(ShiroFilterFactoryBean.java:407)
	at org.apache.shiro.spring.web.ShiroFilterFactoryBean.createInstance(ShiroFilterFactoryBean.java:482)
	at org.apache.shiro.spring.web.ShiroFilterFactoryBean.getObject(ShiroFilterFactoryBean.java:382)
	at org.apache.shiro.spring.web.ShiroFilterFactoryBean.getObject(ShiroFilterFactoryBean.java:122)
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:182)
	... 51 common frames omitted
Caused by: java.lang.InstantiationException: org.apache.shiro.web.filter.authz.HttpMethodPermissionFilter
	at [email protected]/java.lang.Class.newInstance(DynamicHub.java:719)
	at org.apache.shiro.util.ClassUtils.newInstance(ClassUtils.java:206)
	... 59 common frames omitted
Caused by: java.lang.NoSuchMethodException: org.apache.shiro.web.filter.authz.HttpMethodPermissionFilter.<init>()
	at [email protected]/java.lang.Class.checkMethod(DynamicHub.java:1065)
	at [email protected]/java.lang.Class.getConstructor0(DynamicHub.java:1228)
	at [email protected]/java.lang.Class.newInstance(DynamicHub.java:706)
	... 60 common frames omitted

@github-actions github-actions bot added the Stale label Mar 25, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 1, 2024
@lprimak lprimak reopened this Apr 1, 2024
@github-actions github-actions bot removed the Stale label Apr 2, 2024
@lprimak lprimak added this to the Backlog milestone May 22, 2024
@github-actions github-actions bot added the Stale label Nov 7, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 14, 2024
@lprimak lprimak reopened this Nov 14, 2024
@lprimak lprimak removed the Stale label Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core Modules help-wanted Help Wanted
Projects
None yet
Development

No branches or pull requests

3 participants