Quarkus: NullPointerException with HibernateValidator @Valid

Created on 17 Mar 2020  路  15Comments  路  Source: quarkusio/quarkus

Describe the bug

Validator annotations can be placed to various places. Example this is probably not effective:

public class StringBasedIdentity implements Serializable, Comparable {

private static final long serialVersionUID = 1L;

@NotNull
@NotEmpty
private final String name;

...

}

Expected behavior
Quarkus processor should be able to pinpoint the error with at least the location of the annotation should be provided as a hint.

Actual behavior
[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.2.1.Final:build (default) on project sched-schedule-app: Failed to build a runnable JAR: Failed to augment application classes: Build failure: Build failed due to errors
[ERROR] at io.quarkus.hibernate.validator.deployment.HibernateValidatorProcessor.build(HibernateValidatorProcessor.java:191)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:498)
[ERROR] at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:915)
[ERROR] at io.quarkus.builder.BuildContext.run(BuildContext.java:279)
[ERROR] at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
[ERROR] at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
[ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
[ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426)
[ERROR] at java.lang.Thread.run(Thread.java:748)
[ERROR] at org.jboss.threads.JBossThread.run(JBossThread.java:479)

To Reproduce
Steps to reproduce the behavior:

  1. Create file
  2. Run build

Environment (please complete the following information):

  • Quarkus version 1.2.1
kinbug

All 15 comments

Could you provide a reproducer? thanks.

Hi,

Would you be able to see if 1.3.0.Final (you'll have to switch to quarkus-bom instead of quarkus-universe-bom unless you test tomorrow when the latter should also be available) exhibits the same behavior?

Hi,

Strange it seems that I'm no longer able to reproduce it.
I'll reopen the ticket if comes back.

I'm having a multi project setup with jandex on all dependencies.
I had to remove some @Valid on method parameters.

Maybe I hit this remark:
// FIXME this won't work in the case of synthetic parameters
(Project is using lombok)

Cheers,

Tamas

I had to remove some @Valid on method parameters.

You shouldn't have to do that.

So, if you do, please open issues with reproducer and I'll have a look.

Thanks!

I think we really need a reproducer, because looking at the stacktrace, there should never be NPE at that point.
So perhaps there is some corner case we haven't accounted for and which your reproducer would uncover :)

I tried to create one, but I failed. Maybe if I'm hitting it again, I'll reopen this case.

Hello @smil2k , I have the same problem, project Quarkus parent A with Quarkus submodule B. If I run project B with @Valid there are no problems, but when added as a maven dependency the same error occurs.

image

If I remove all @_Valid_ everything works.

public Response save(@Valid UserDto dto)

@luis-martinez-herrera do you perhaps have a reproducer project we could look at?

Sorry for the delay: https://github.com/luis-martinez-herrera/quarkusio-7923-reproducer

The error occurs when using an abstract class, in the example it would be AbstractResource.

Thank you @luis-martinez-herrera, I'll look into it

This looks like some kind of bug in Jandex. I'm in the process of debugging Jandex to try and figure out exactly what the problem is.

Let's reopen the ticket then. Adding Jandex caused the issue at my side as well.

I have opened https://github.com/wildfly/jandex/pull/74 which fixes the issue

Closed via f9978cfc95e088e037f69e10ff32749808a50cb6

Reopening as f9978cf was reverted

Was this page helpful?
0 / 5 - 0 ratings