如何在jboss EAP 6.3上更改bean验证版本?

时间:2015-09-21 19:21:28

标签: java validation jboss jersey bean-validation

我正在使用球衣2.17,我需要添加一些验证规则。所以我决定包括泽西豆验证支持

<dependency>
    <groupId>org.glassfish.jersey.ext</groupId>
    <artifactId>jersey-bean-validation</artifactId>
    <version>2.17</version>
</dependency>

当我启动服务器时,结果是:

WSConfig threw load() exception: java.lang.NoSuchMethodError: javax.validation.Configuration.getBootstrapConfiguration()Ljavax/validation/BootstrapConfiguration;
    at org.glassfish.jersey.server.validation.internal.ValidationBinder$ConfiguredValidatorProvider.getTraversableResolver(ValidationBinder.java:300) [jersey-bean-validation-2.17.jar:]
    at org.glassfish.jersey.server.validation.internal.ValidationBinder$ConfiguredValidatorProvider.getDefaultValidatorContext(ValidationBinder.java:281) [jersey-bean-validation-2.17.jar:]

接下来,我决定在jboss-deployment-structure.xml中排除一些模块(特别是org.hibernate.validator和javax.validation.api):

<jboss-deployment-structure>
<deployment>

    <exclude-subsystems>
        <subsystem name="resteasy"/>
    </exclude-subsystems>

    <exclusions>
        <module name="javaee.api"/>
        <module name="javax.ws.rs.api"/>
        <module name="org.jboss.resteasy.resteasy-jaxrs"/>
        <module name="javax.validation.api"/>
        <module name="org.hibernate.validator"/>
    </exclusions>

    <local-last value="true"/>

</deployment>
</jboss-deployment-structure>

当我排除模块时,错误是:

WSConfig threw load() exception: java.lang.NoSuchMethodError: javax.validation.spi.ConfigurationState.getParameterNameProvider()Ljavax/validation/ParameterNameProvider;
at org.hibernate.validator.internal.engine.ValidatorFactoryImpl.<init>(ValidatorFactoryImpl.java:135) [hibernate-validator-5.1.2.Final.jar:5.1.2.Final]
    at org.hibernate.validator.HibernateValidator.buildValidatorFactory(HibernateValidator.java:45) [hibernate-validator-5.1.2.Final.jar:5.1.2.Final]
    at org.hibernate.validator.internal.engine.ConfigurationImpl.buildValidatorFactory(ConfigurationImpl.java:236) [hibernate-validator-5.1.2.Final.jar:5.1.2.Final]
    at org.glassfish.jersey.server.validation.internal.ValidationBinder$DefaultValidatorFactoryProvider.provide(ValidationBinder.java:154) [jersey-bean-validation-2.17.jar:]
    at org.glassfish.jersey.server.validation.internal.ValidationBinder$DefaultValidatorFactoryProvider.provide(ValidationBinder.java:147) [jersey-bean-validation-2.17.jar:]

我已经添加了依赖项:

<dependency>
    <groupId>javax.validation</groupId>
    <artifactId>validation-api</artifactId>
    <version>1.1.0.Final</version>
 </dependency>

仍然无效。

我的问题是:

  • 如何在不对服务器进行任何更改的情况下将bean验证api从1.0升级到1.1? (我没有权限编辑服务器配置)
  • 我必须排除哪些依赖项?

事先谢谢。

0 个答案:

没有答案