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

NullPointerException in some case #461

Closed
wallaroo opened this issue Aug 9, 2023 · 17 comments
Closed

NullPointerException in some case #461

wallaroo opened this issue Aug 9, 2023 · 17 comments
Labels
Milestone

Comments

@wallaroo
Copy link

wallaroo commented Aug 9, 2023

io.camunda.zeebe.spring.client.bean.MethodInfo#getParameters and io.camunda.zeebe.spring.client.bean.MethodInfo#getParametersFilteredByAnnotation methods can throw a NullPointerException when org.springframework.core.LocalVariableTableParameterNameDiscoverer#getParameterNames(java.lang.reflect.Method) returns null

wallaroo added a commit to wallaroo/spring-zeebe that referenced this issue Aug 9, 2023
@akeller akeller added the bug label Aug 16, 2023
@berndruecker
Copy link
Contributor

Hi @wallaroo - thanks for raising the issue. Do you know in which situations this can be null? Trying to understand the root cause.

@daniel-ewing
Copy link
Contributor

Hi @berndruecker, as mentioned by @wallaroo, the fix in #462 doesn't actually address why L71 returns a null array. We have now had two support tickets for this issue. Is it possible that it is not thread safe to use LocalVariableTableParameterNameDiscoverer#getParameterNames as a static class and their needs to be a synchronized block around L71?

@harrybraun
Copy link

Hi @daniel-ewing, maybe one of the support tickets is from us. We are now experiencing the same problem in the cluster. Locally there is no problem, in the AWS EKS cluster we get an incident with the following error message every time a worker is started:

java.lang.NullPointerException: Cannot load from object array because "parameterNames" is null
  at io.camunda.zeebe.spring.client.bean.MethodInfo.getParameters(MethodInfo.java:75)
  at io.camunda.zeebe.spring.client.jobhandling.JobHandlerInvokingSpringBeans.handle(JobHandlerInvokingSpringBeans.java:46)
  at io.camunda.zeebe.client.impl.worker.JobRunnableFactory.executeJob(JobRunnableFactory.java:44)
  at io.camunda.zeebe.client.impl.worker.JobRunnableFactory.lambda$create$0(JobRunnableFactory.java:39)
  at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
  at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
  at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
  at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
  at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
  at java.base/java.lang.Thread.run(Thread.java:833)

We are currently using SpringBoot 3.1.4, locally OpenJDK 20, in the cluster probably Correto, Camunda 8.2.13 and Spring-Zeebe 8.2.4.

@akeller
Copy link
Member

akeller commented Oct 2, 2023

@1nb0und can you have a look? I know you mentioned digging into SpringBoot version compatibility today.

@berndruecker berndruecker added this to the 8.3.0 milestone Oct 5, 2023
wallaroo added a commit to wallaroo/spring-zeebe that referenced this issue Oct 10, 2023
@1nb0und 1nb0und self-assigned this Oct 10, 2023
@1nb0und 1nb0und modified the milestones: 8.3.0, 8.3.x patch Oct 10, 2023
@1nb0und 1nb0und modified the milestones: 8.3.x patch, 8.4.0 Dec 14, 2023
@sam0r040
Copy link

Hi, we also encountered this issue while trying to upgrade from Spring Boot 3.1.5 to 3.2.0 and therefore from spring-boot-starter-camunda from 8.3.1 to 8.3.4. We can reproduce this issue in our process tests and it is currently preventing us from updating to Spring Boot 3.2.0.

@1nb0und
Copy link
Contributor

1nb0und commented Dec 15, 2023

@sam0r040 Can you put some stacktrace that you were getting?

@sam0r040
Copy link

sam0r040 commented Dec 15, 2023

Sure:

io.camunda.zeebe.client.job.worker       : Worker JobWorker#handle failed to handle job with key 2251799813685282 of type ****, sending fail command to broker
java.lang.NullPointerException: Cannot load from object array because "parameterNames" is null
	at io.camunda.zeebe.spring.client.bean.MethodInfo.getParameters(MethodInfo.java:72) ~[spring-client-zeebe-8.3.4.1.jar:8.3.4.1]
	at io.camunda.zeebe.spring.client.jobhandling.JobHandlerInvokingSpringBeans.handle(JobHandlerInvokingSpringBeans.java:48) ~[spring-client-zeebe-8.3.4.1.jar:8.3.4.1]
	at io.camunda.zeebe.client.impl.worker.JobRunnableFactoryImpl.executeJob(JobRunnableFactoryImpl.java:45) ~[zeebe-client-java-8.3.4.jar:8.3.4]
	at io.camunda.zeebe.client.impl.worker.JobRunnableFactoryImpl.lambda$create$0(JobRunnableFactoryImpl.java:40) ~[zeebe-client-java-8.3.4.jar:8.3.4]
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[na:na]
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[na:na]
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[na:na]
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na]
	at java.base/java.lang.Thread.run(Thread.java:840) ~[na:na]

@backslash47
Copy link

The error is happening because MethodInfo.getParameters.handle is depending on StandardReflectionParameterNameDiscoverer spring bean. And this bean requires the parameter names to be left alone during compilation.

Simple workaround is to use compileArgs -parameters for javac.

tasks.named('compileJava').configure {
    options.compilerArgs = ['-parameters']
}

@janmas
Copy link

janmas commented Dec 25, 2023

@backslash47 is correct. The issue can be solved by specifying of javac option "-parameters". In IntelliJ it can be done by by Settings > Build, Execution, Deployment > Compiler > Java Compiler > Additional command line parameters (as mentioned in https://stackoverflow.com/questions/39217830/how-to-use-parameters-javac-option-in-intellij).

@1nb0und
Copy link
Contributor

1nb0und commented Dec 25, 2023

@wallaroo

  1. Can you confirm if this solves your issue?
  2. What Spring Boot version were you using?

It appears we encountered this issue when Spring Boot in this project was baselined to 3.2 and here are the PRs associated with it

#512

and the corresponding docs for the new flag has been added

Thank you @backslash47 and @janmas

@hzpz
Copy link

hzpz commented Jan 3, 2024

I can confirm that enabling method parameters metadata via the -java-parameters flag for the Kotlin compiler fixes the issue @sam0r040 described. Thanks!

@MMusaTR
Copy link

MMusaTR commented Feb 22, 2024

The error is happening because MethodInfo.getParameters.handle is depending on StandardReflectionParameterNameDiscoverer spring bean. And this bean requires the parameter names to be left alone during compilation.

Simple workaround is to use compileArgs -parameters for javac.

tasks.named('compileJava').configure {
    options.compilerArgs = ['-parameters']
}

where do we specify this in eclipse? anyone?

Thanks

@msjo66
Copy link

msjo66 commented Feb 27, 2024

@MMusaTR
Copy link

MMusaTR commented Feb 27, 2024

@MMusaTR It can be put into pom.xml if using maven. see https://maven.apache.org/plugins/maven-compiler-plugin/examples/pass-compiler-arguments.html

I'm using gradle, I've specified following in build.gradle but still getting the NPE -
tasks.withType(JavaCompile) { options.compilerArgs << '-parameters' }

@msjo66
Copy link

msjo66 commented Feb 28, 2024

@MMusaTR did you try following?

tasks.withType(JavaCompile) { options.compilerArgs.add("-parameters") }

@benno-huber
Copy link

I've also seen that NPE thrown in my Java client (spring-client-root v 8.4.0). It would be helpfull to detect faulty java class code ahead before it comes to NPE. That way some meanigfull error message could be thrown instead of NPE.

@jonathanlukas
Copy link
Contributor

Fix provided in docs (add -parameters as compiler option) + error happens during init now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.