简体   繁体   中英

Failed to start quarkus: java.lang.ArrayIndexOutOfBoundsException: 1

Quarkus application (0.19.1), created from QuarkEE artifact fails to start with:

[io.qua.dev.DevModeMain] Failed to start quarkus: java.lang.ExceptionInInitializerError ..
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
at io.quarkus.hibernate.validator.runtime.HibernateValidatorRecorder

EDIT I've opened a ticket for it: https://github.com/quarkusio/quarkus/issues/3284

Root cause was a bean validation constraint javax.validation.constraints.NotNull on the static factory method of the enum class. Simplified example:

public enum Gender {
    MALE,
    FEMALE;

    public static Gender fromCode(@NotNull String code) {
        return Gender.valueOf(code);
    }
}

and having this dependency in your pom:

    <dependency>
       <groupId>io.quarkus</groupId>
       <artifactId>quarkus-hibernate-validator</artifactId>
    </dependency>

Confusing thing is that static factory methods on simple POJO class works.

Note I'm aware that validation of static methods is not supported by the Bean Validation specification. It is just a hint for IDE.

Java EE 8 Validating Constructors and Methods: Bean Validation constraints may be placed on the parameters of nonstatic methods and constructors and on the return values of nonstatic methods. Static methods and constructors will not be validated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM