IBM Support

PI43122: ValidationException occurs when using JAX-RS and more than one v alidation.xml

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • The WebSphere Liberty profile beanValidation-1.1 feature
    allows users to package more than one validation.xml per
    application for Bean Validation, so long as those
    validation.xml files are packaged in Java EE modules (i.e.
    web archives, EJB JARs, RARs, etc.).  Then the
    validation.xml in the currently running module will be used
    to validate beans - the beans it validates can be packaged
    in the same module or in utility JAR files or shared
    libraries that are loadable from that module.
    
    A problem exists when using the jaxrs-2.0 feature and when
    more than one validation.xml is packaged in the same
    application classpath - the underlying Apache Bean
    Validation provider will throw a ValidationException that
    indicates that more than one validation.xml file was found
    on the classpath.  This exception is expected in Java SE
    environments, but in a Java EE environment like Liberty
    profile, it should allow more than one validation.xml so
    long as they are packaged in separate modules of the same
    application.  The errors in the log may look like this:
    
    [ERROR   ] Bean Validation provider can not be found, no
    validation will be performed
    [ERROR   ] SRVE0271E: Uncaught init() exception created by
    servlet [Everydaywords servlet] in application
    [SocialSphere]: javax.validation.ValidationException: More
    than one META-INF/validation.xml is found in the classpath
    at
    org.apache.bval.jsr.xml.ValidationParser.getInputStream(Vali
    dationParser.java:206)
        at [internal classes]
    
    [ERROR   ] SRVE0315E: An exception occurred:
    com.ibm.ws.webcontainer.webapp.WebAppErrorReport:
    javax.servlet.ServletException: SRVE0207E: Uncaught
    initialization exception created by servlet
    at
    com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletW
    rapper.java:399)
        at [internal classes]
    Caused by: javax.servlet.ServletException: SRVE0207E:
    Uncaught initialization exception created by servlet
        ... 3 more
    Caused by: javax.validation.ValidationException: More than
    one META-INF/validation.xml is found in the classpath
    at
    org.apache.bval.jsr.xml.ValidationParser.getInputStream(Vali
    dationParser.java:206)
        ... 1 more
    
    Note that this problem does not occur when the application
    only uses Bean Validation annotations - nor does it occur
    when only a single validation.xml is present in the
    application classpath.  If you see this error, switching to
    annotations-only or consolidating validation.xmls into a
    single file are both valid workarounds.
    

Local fix

Problem summary

  • ****************************************************************
    * USERS AFFECTED:  All users of IBM WebSphere Application      *
    *                  Server Liberty Profile                      *
    ****************************************************************
    * PROBLEM DESCRIPTION: ValidationException occurs when using   *
    *                      JAX-RS and more than one                *
    *                      validation.xml                          *
    ****************************************************************
    * RECOMMENDATION:                                              *
    ****************************************************************
    The WebSphere Liberty beanValidation-1.1 feature allows users to
    package more than one validation.xml per application for Bean
    Validation, so long as those validation.xml files are packaged
    in Java EE modules (i.e. web archives, EJB JARs, RARs, etc.).
    Then the validation.xml in the currently running module will be
    used to validate beans - the beans it validates can be packaged
    in the same module or in utility JAR files or shared libraries
    that are loadable from that module.
    
    A problem exists when using the jaxrs-2.0 feature and when more
    than one validation.xml is packaged in the same application
    classpath - the underlying Apache Bean Validation provider will
    throw a ValidationException that indicates that more than one
    validation.xml file was found on the classpath.  This exception
    is expected in Java SE environments, but in a Java EE
    environment like WebSphere Liberty, it should allow more than
    one validation.xml so long as they are packaged in separate
    modules of the same application.  The errors in the log may look
    like this:
    
    [ERROR   ] Bean Validation provider can not be found, no
    validation will be performed
    [ERROR   ] SRVE0271E: Uncaught init() exception created by
    servlet [Everydaywords servlet] in application [SocialSphere]:
    javax.validation.ValidationException: More than one META-
    INF/validation.xml is found in the classpath
        at
    org.apache.bval.jsr.xml.ValidationParser.getInputStream(Validati
    onParser.java:206)
        at [internal classes]
    
    [ERROR   ] SRVE0315E: An exception occurred:
    com.ibm.ws.webcontainer.webapp.WebAppErrorReport:
    javax.servlet.ServletException: SRVE0207E: Uncaught
    initialization exception created by servlet
        at
    com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapp
    er.java:399)
        at [internal classes]
    Caused by: javax.servlet.ServletException: SRVE0207E: Uncaught
    initialization exception created by servlet
        ... 3 more
    Caused by: javax.validation.ValidationException: More than one
    META-INF/validation.xml is found in the classpath
        at
    org.apache.bval.jsr.xml.ValidationParser.getInputStream(Validati
    onParser.java:206)
        ... 1 more
    
    Note that this problem does not occur when the application only
    uses Bean Validation annotations - nor does it occur when only a
    single validation.xml is present in the application classpath.
    If you see this error, switching to annotations-only or
    consolidating validation.xmls into a single file are both valid
    workarounds.
    

Problem conclusion

  • The fix for this APAR handles cases where multiple
    validation.xml files exist in the same application or the
    application's classpath (shared libraries, etc.) when the JAX-RS
    runtime initializes the bean validation provider.
    
    The fix for this APAR is currently targeted for inclusion in fix
    pack 8.5.5.7.  Please refer to the Recommended Updates page for
    delivery information:
    http://www.ibm.com/support/docview.wss?rs=180&uid=swg27004980
    

Temporary fix

Comments

APAR Information

  • APAR number

    PI43122

  • Reported component name

    WAS LIBERTY COR

  • Reported component ID

    5725L2900

  • Reported release

    855

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2015-06-16

  • Closed date

    2015-08-12

  • Last modified date

    2015-08-12

  • APAR is sysrouted FROM one or more of the following:

  • APAR is sysrouted TO one or more of the following:

Fix information

  • Fixed component name

    WAS LIBERTY COR

  • Fixed component ID

    5725L2900

Applicable component levels

  • R855 PSY

       UP

[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSD28V","label":"WebSphere Application Server Liberty Core"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"855","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
28 April 2022