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

NPE in SupportSwaggerProcessor when sources do not include a package statement #6423

Closed
apupier opened this issue Sep 4, 2024 · 2 comments · Fixed by #6424
Closed

NPE in SupportSwaggerProcessor when sources do not include a package statement #6423

apupier opened this issue Sep 4, 2024 · 2 comments · Fixed by #6424
Assignees
Labels
bug Something isn't working
Milestone

Comments

@apupier
Copy link
Contributor

apupier commented Sep 4, 2024

Bug description

  • Use Camel Jbang to create a Camel Quarkus project: jbang '-Dcamel.jbang.version=4.7.0' camel@apache/camel export --runtime=quarkus --gav=com.acme:myproject:1.0-SNAPSHOT
  • Use Camel JBang to create a Camel route: jbang '-Dcamel.jbang.version=4.7.0' camel@apache/camel init 'src/main/resources/camel/demo.camel.yaml'
  • Start it with mvn compile quarkus:dev '-Pcamel.debug'
    there is this exception:
2024-09-04 13:44:06,601 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step org.apache.camel.quarkus.support.swagger.deployment.SupportSwaggerProcessor#reflectiveClasses threw an exception: java.lang.NullPointerException: Cannot invoke "String.startsWith(String)" because the return value of "org.jboss.jandex.DotName.packagePrefix()" is null
        at org.apache.camel.quarkus.support.swagger.deployment.SupportSwaggerProcessor.lambda$reflectiveClasses$0(SupportSwaggerProcessor.java:32)
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178)
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
        at org.apache.camel.quarkus.support.swagger.deployment.SupportSwaggerProcessor.reflectiveClasses(SupportSwaggerProcessor.java:35)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:849)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
        at java.base/java.lang.Thread.run(Thread.java:1583)
        at org.jboss.threads.JBossThread.run(JBossThread.java:483)

        at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:331)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:252)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:58)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:113)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:435)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:56)
        at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:138)
        at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:93)
        at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:131)
        at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:62)
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step org.apache.camel.quarkus.support.swagger.deployment.SupportSwaggerProcessor#reflectiveClasses threw an exception: java.lang.NullPointerException: Cannot invoke "String.startsWith(String)" because the return value of "org.jboss.jandex.DotName.packagePrefix()" is null
        at org.apache.camel.quarkus.support.swagger.deployment.SupportSwaggerProcessor.lambda$reflectiveClasses$0(SupportSwaggerProcessor.java:32)
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178)
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
        at org.apache.camel.quarkus.support.swagger.deployment.SupportSwaggerProcessor.reflectiveClasses(SupportSwaggerProcessor.java:35)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:849)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
        at java.base/java.lang.Thread.run(Thread.java:1583)
        at org.jboss.threads.JBossThread.run(JBossThread.java:483)

        at io.quarkus.builder.Execution.run(Execution.java:123)
        at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:79)
        at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:160)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:327)
        ... 9 more
Caused by: java.lang.NullPointerException: Cannot invoke "String.startsWith(String)" because the return value of "org.jboss.jandex.DotName.packagePrefix()" is null
        at org.apache.camel.quarkus.support.swagger.deployment.SupportSwaggerProcessor.lambda$reflectiveClasses$0(SupportSwaggerProcessor.java:32)
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178)
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
        at org.apache.camel.quarkus.support.swagger.deployment.SupportSwaggerProcessor.reflectiveClasses(SupportSwaggerProcessor.java:35)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:849)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
        at java.base/java.lang.Thread.run(Thread.java:1583)
        at org.jboss.threads.JBossThread.run(JBossThread.java:483)
@apupier apupier added the bug Something isn't working label Sep 4, 2024
@apupier
Copy link
Contributor Author

apupier commented Sep 4, 2024

workaround: add the package to the created Java file

It would be nice to have a better error message

@apupier
Copy link
Contributor Author

apupier commented Sep 4, 2024

Note that if moved to the root, so no tusing package, there is the same error. Even if not recommended by Java practice, this is a valid configuration

@apupier apupier self-assigned this Sep 4, 2024
@apupier apupier added this to the 3.15.0 milestone Sep 4, 2024
apupier added a commit to apupier/camel-quarkus that referenced this issue Sep 4, 2024
apupier added a commit to apupier/camel-quarkus that referenced this issue Sep 4, 2024
apupier added a commit to apupier/camel-quarkus that referenced this issue Sep 4, 2024
jamesnetherton pushed a commit that referenced this issue Sep 4, 2024
@jamesnetherton jamesnetherton changed the title NPE in SupportSwaggerProcessor.lambda$reflectiveClasses$0(SupportSwaggerProcessor.java:32) NPE in SupportSwaggerProcessor when sources do not include a package statement Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant