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

Native support for JCommander #340

Closed
jvalkeal opened this issue Dec 24, 2021 · 0 comments · Fixed by #386
Closed

Native support for JCommander #340

jvalkeal opened this issue Dec 24, 2021 · 0 comments · Fixed by #386
Milestone

Comments

@jvalkeal
Copy link
Contributor

While trying to get spring-shell-samples to work with spring-native there's an error with startup which seems to be around reflective dance happening in JCommanderParameterResolver.

We can remove this particular command from samples to give time to make things work while getting most parts of a sample to work with graal.

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'exampleApplicationRunnerConfiguration': Unsatisfied dependency expressed through field 'shell'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'shell': Invocation of init method failed; nested exception is org.springframework.shell.ParameterResolverMissingException: No parameter resolver found for parameter with index 0 (named 'args') of public java.lang.String org.springframework.shell.samples.jcommander.JCommanderCommands.jcommander(org.springframework.shell.samples.jcommander.Args) 
	at org.springframework.aot.beans.factory.InjectedFieldResolver.resolve(InjectedFieldResolver.java:50) ~[na:na]
	at org.springframework.aot.beans.factory.InjectedElementResolver.resolve(InjectedElementResolver.java:19) ~[na:na]
	at org.springframework.aot.beans.factory.InjectedElementResolver.invoke(InjectedElementResolver.java:37) ~[na:na]
	at org.springframework.shell.samples.ContextBootstrapInitializer.lambda$registerExampleApplicationRunnerConfiguration$1(ContextBootstrapInitializer.java:16) ~[na:na]
	at org.springframework.aot.beans.factory.ThrowableFunction.apply(ThrowableFunction.java:18) ~[na:na]
	at org.springframework.aot.beans.factory.BeanDefinitionRegistrar.lambda$instanceSupplier$0(BeanDefinitionRegistrar.java:97) ~[na:na]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1249) ~[na:na]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1191) ~[na:na]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[na:na]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[na:na]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[na:na]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[na:na]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[na:na]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[na:na]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953) ~[na:na]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[na:na]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[na:na]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[spring-shell-samples:2.6.2]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412) ~[spring-shell-samples:2.6.2]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) ~[spring-shell-samples:2.6.2]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) ~[spring-shell-samples:2.6.2]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290) ~[spring-shell-samples:2.6.2]
	at org.springframework.shell.samples.SpringShellSample.main(SpringShellSample.java:38) ~[spring-shell-samples:3.0.0-SNAPSHOT]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'shell': Invocation of init method failed; nested exception is org.springframework.shell.ParameterResolverMissingException: No parameter resolver found for parameter with index 0 (named 'args') of public java.lang.String org.springframework.shell.samples.jcommander.JCommanderCommands.jcommander(org.springframework.shell.samples.jcommander.Args) 
	at org.springframework.aot.context.annotation.InitDestroyBeanPostProcessor.invokeInitMethod(InitDestroyBeanPostProcessor.java:79) ~[na:na]
	at org.springframework.aot.context.annotation.InitDestroyBeanPostProcessor.postProcessBeforeInitialization(InitDestroyBeanPostProcessor.java:65) ~[na:na]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:440) ~[na:na]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796) ~[na:na]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[na:na]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[na:na]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[na:na]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[na:na]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[na:na]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[na:na]
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[na:na]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389) ~[na:na]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309) ~[na:na]
	at org.springframework.aot.beans.factory.InjectedFieldResolver.resolve(InjectedFieldResolver.java:43) ~[na:na]
	... 22 common frames omitted
Caused by: org.springframework.shell.ParameterResolverMissingException: No parameter resolver found for parameter with index 0 (named 'args') of public java.lang.String org.springframework.shell.samples.jcommander.JCommanderCommands.jcommander(org.springframework.shell.samples.jcommander.Args) 
	at org.springframework.shell.Shell.lambda$validateParameterResolvers$5(Shell.java:335) ~[spring-shell-samples:3.0.0-SNAPSHOT]
	at java.util.Optional.orElseThrow(Optional.java:408) ~[na:na]
	at org.springframework.shell.Shell.lambda$validateParameterResolvers$6(Shell.java:335) ~[spring-shell-samples:3.0.0-SNAPSHOT]
	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[na:na]
	at java.util.stream.IntPipeline$1$1.accept(IntPipeline.java:180) ~[na:na]
	at java.util.stream.Streams$RangeIntSpliterator.forEachRemaining(Streams.java:104) ~[na:na]
	at java.util.Spliterator$OfInt.forEachRemaining(Spliterator.java:699) ~[na:na]
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[na:na]
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[na:na]
	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[na:na]
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497) ~[na:na]
	at org.springframework.shell.Shell.validateParameterResolvers(Shell.java:325) ~[spring-shell-samples:3.0.0-SNAPSHOT]
	at java.lang.Iterable.forEach(Iterable.java:75) ~[na:na]
	at org.springframework.shell.Shell.gatherMethodTargets(Shell.java:102) ~[spring-shell-samples:3.0.0-SNAPSHOT]
	at java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
	at org.springframework.aot.context.annotation.InitDestroyBeanPostProcessor.invokeMethod(InitDestroyBeanPostProcessor.java:137) ~[na:na]
	at org.springframework.aot.context.annotation.InitDestroyBeanPostProcessor.invokeInitMethod(InitDestroyBeanPostProcessor.java:76) ~[na:na]
	... 35 common frames omitted

@jvalkeal jvalkeal added this to the 3.0.0-M1 milestone Dec 24, 2021
jvalkeal added a commit to jvalkeal/spring-shell that referenced this issue Dec 24, 2021
- While project uses jdk8, you can do native build with jdk11
  `./mvnw clean package -Pnative`
- You can then run these
  spring-shell-samples/target/spring-shell-samples
  java -jar spring-shell-samples/target/spring-shell-samples-3.0.0-SNAPSHOT-exec.jar
- Remove logback.xml in favour of spring config to workaround for
  spring-attic/spring-native#625
- For now remove jcommander command sample to get support for it spring-projects#340
- Relates spring-projects#323
jvalkeal added a commit that referenced this issue Dec 24, 2021
- While project uses jdk8, you can do native build with jdk11
  `./mvnw clean package -Pnative`
- You can then run these
  spring-shell-samples/target/spring-shell-samples
  java -jar spring-shell-samples/target/spring-shell-samples-3.0.0-SNAPSHOT-exec.jar
- Remove logback.xml in favour of spring config to workaround for
  spring-attic/spring-native#625
- For now remove jcommander command sample to get support for it #340
- Relates #323
@jvalkeal jvalkeal modified the milestones: 3.0.0-M1, 3.0.0-M2 Jan 7, 2022
@jvalkeal jvalkeal modified the milestones: 2.1.0-M2, 2.1.0-M3 Jan 28, 2022
@jvalkeal jvalkeal modified the milestones: 2.1.0-M3, 2.1.0-M4 Feb 22, 2022
jvalkeal added a commit to jvalkeal/spring-shell that referenced this issue Mar 5, 2022
jvalkeal added a commit that referenced this issue Mar 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant