Skip to content

[JAX-RS] Cannot run generated server with validation-api scope provided #5091

@jiekang

Description

@jiekang
Description

When using Codegen through Swagger UI Docker container for a JAX-RS server, the README.md
states that running mvn clean package jetty:run will start the server. Running this results in:

WARNING: The following warnings have been detected: WARNING: HK2 service reification failed for [org.glassfish.jersey.server.model.ResourceMethodInvoker$Builder] with an exception:
MultiException stack 1 of 1
java.lang.NoClassDefFoundError: javax/validation/Validator

and the content is unavailable.

The generated pom.xml has:

<!-- Bean Validation API support -->
<dependency>
    <groupId>javax.validation</groupId>
    <artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
<scope>provided</scope>
</dependency>

Removing the provided scope fixes the issue for me.

Swagger-codegen version

I am not sure. The Docker container seems to be accessing Codegen through the network.

docker.io/swaggerapi/swagger-editor with TAG latest

Swagger declaration file content or url

The default yaml file that begins with:

# this is an example of the Uber API
# as a demonstration of an API spec in YAML

can be used to reproduce the issue.

Steps to reproduce
  1. Open the default example in Swagger UI in Docker container

  2. Generate server JAX-RS

  3. Unzip tarball and enter jaxrs-server folder

  4. Run mvn clean package jetty:run

  5. See ClassNotFound exception

  6. Attempt to access via curl http://localhost:8080/v1/swagger.json and see 503 error

  7. Edit pom.xml and remove provided from validation-api dependency

  8. Run mvn clean package jetty:run and curl http://localhost:8080/v1/swagger.json successfully.

Suggest a Fix

If validation-api is meant to be provided then the documentation needs to be updated and should include how users can provide the dependency. Otherwise, it should not be <scope>provided</scope>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions