5

I'm attempting to deploy a Spring Boot (2.0.2) application on JBoss EAP 7.1 server.

The code that's causing the problem is:

import javax.validation.constraints.NotBlank;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

@Component
@Validated
public class AppProperties {

  @NotBlank
  private String name;

When the application is deployed on JBoss I get the following exception:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
16:44:25,861 ERROR [org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter] (ServerService Thread Pool -- 6 7)

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to bind properties under 'app' to com.example.security.config.AppProperties:

    Property: app.contextpath
    Value: /api
    Origin: class path resource [application.yml]:5:18
    Reason: HV000030: No validator could be found for constraint 'javax.validation.constraints.NotBlank' validating type 'java.lang.String'. Check configuration for 'name'

Action:

Update your application's configuration

I've tried adding the file jboss-deployment-structure.xml with the following contents to WEB-INF/classes:

<jboss-deployment-structure>
  <ear-subdeployments-isolated>true</ear-subdeployments-isolated>
  <deployment>
    <exclude-subsystems>
      <subsystem name="jaxrs"/>
    </exclude-subsystems>
    <exclusions>
      <module name="javaee.api"/>
      <module name="javax.validation.api"/>
      <module name="javax.faces.api"/>
      <module name="org.hibernate.validator"/>
    </exclusions>
  </deployment>
</jboss-deployment-structure>

But, no luck. What's the workaround? Thanks in advance.

James R. Perkins
  • 16,800
  • 44
  • 60
Tora Tora Tora
  • 973
  • 3
  • 18
  • 33

3 Answers3

9

Even though this question is a year old, I ran into the same issue and couldn't find a solution.

This, I know, will work for Spring Boot 2.1.x and JBoss 7.1, not sure about versions before that.

We obviously need to exclude org.hibernate.validator and javax.validation.api. What wasn't clear is that we also need to exclude the javax.faces.api (it has a transitive dependency on javax.validation.api). Excluding that javax.faces causes JBoss to fail on start up due to missing jsf libraries. We can then simply exclude the jsf subsystem.

<jboss-deployment-structure>
    <deployment>
        <exclude-subsystems>
            <subsystem name="jsf" />
        </exclude-subsystems>
        <exclusions>
            <module name="javax.validation.api" />
            <module name="javax.faces.api" />
            <module name="org.hibernate.validator" />
        </exclusions>
    </deployment>
</jboss-deployment-structure>

Assuming you don't need JSF from jboss, this should work.

John Vint
  • 39,695
  • 7
  • 78
  • 108
  • 2
    This worked for me on Spring Boot 2.2.3 and JBoss 7.0.0. Note also that having excluded the jsf subsystem I did not need to explicitly exclude javax.faces.api. – haggisandchips Feb 12 '20 at 15:58
  • 1
    Jboss 7.1 spring 2.17 above solution worked perfectly – GSK Jan 06 '21 at 12:15
0

According to this article the jboss-deployment-structure.xml shoudl be placed in 'the top level deployment, in META-INF (or WEB-INF for web deployments)'.

So with your current set-up the things configured in the xml are not applied, so if the xml is put in the right location it might work.

Sven Hakvoort
  • 3,543
  • 2
  • 17
  • 34
  • Thanks Sven. I've tried multiple combinations for the location of the file and none of them work. – Tora Tora Tora Jun 19 '18 at 19:51
  • Have you put the config file directly in the webinf folder? I saw you mentioned in the classes folder, but it might make a difference if it is directly in the webinf? – Sven Hakvoort Jun 19 '18 at 19:55
0

javax.validation.constraints.NotBlank is part of Bean Validation 2.0 and thus Java EE 8. I suspect EAP 7.1 does not support this feature yet.

M.F
  • 403
  • 2
  • 10
  • I'm unable to find any documentation that states which version of Bean Validation is supported in JBoss EAP 7.1. It's odd that it isn't easy to decipher. – Tora Tora Tora Jun 19 '18 at 19:52
  • 1
    Sorry about that. EAP 7.1 [is a certified implementation of the ... Java EE 7](https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.1/pdf/introduction_to_jboss_eap/Red_Hat_JBoss_Enterprise_Application_Platform-7.1-Introduction_to_JBoss_EAP-en-US.pdf) standard. And Bean Validation (JSR 380) is part of [Java EE 8](https://beanvalidation.org/2.0/). – M.F Jun 20 '18 at 06:40
  • Thanks Martin Freidank. – Tora Tora Tora Jun 21 '18 at 00:14