Uploaded image for project: 'Thorntail'
  1. Thorntail
  2. THORN-406

Wildfly Swarm plugin does not auto-detect the necessary fractions for javax.json and javax.xml.bind

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 1.0.0.Beta6
    • Fix Version/s: 1.0.0.Beta7
    • Component/s: plugins
    • Labels:
      None

      Description

      Having a project with a REST endpoint defined as:

      package org.demo.rest;
      
      import javax.json.Json;
      import javax.json.JsonObject;
      import javax.ws.rs.GET;
      import javax.ws.rs.Path;
      import javax.ws.rs.Produces;
      import javax.ws.rs.core.MediaType;
      import javax.ws.rs.core.Response;
      
      @Path("/hello")
      public class HelloEndpoint {
      
          @GET
          @Produces("text/plain")
          public Response doGet() {
              return Response.ok("method doGet invoked").build();
          }
      
          @GET
          @Path("/json")
          @Produces(MediaType.APPLICATION_JSON)
          public JsonObject getJSON() {
              return Json.createObjectBuilder().build();
          }
      
          @GET
          @Path("/xml")
          @Produces(MediaType.TEXT_XML)
          public AnEntity getJaxb() {
              AnEntity entity = new AnEntity();
              entity.setFoo("Bar");
              return entity;
          }
      }
      

      And an entity class defined as:

      package org.demo.rest;
      
      import javax.xml.bind.annotation.XmlAccessType;
      import javax.xml.bind.annotation.XmlAccessorType;
      import javax.xml.bind.annotation.XmlElement;
      import javax.xml.bind.annotation.XmlRootElement;
      
      @XmlRootElement
      @XmlAccessorType(XmlAccessType.FIELD)
      public class AnEntity {
          @XmlElement
          private String foo;
      
          public String getFoo() {
              return foo;
          }
      
          public void setFoo(String foo) {
              this.foo = foo;
          }
      }
      

      And no fractions set in the pom.xml (but the JavaEE API), the swarmed app fails to initialize with the following exception:

      java.lang.ClassNotFoundException: javax.json.JsonObject from [Module \"deployment.demo.war:main\" from Service Module Loader]"}}
      

      The workaround is to add the jaxrs-jaxb (to support correct serialization of the JAXB entity) and the jaxrs-jsonp in the pom.xml.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                gastaldi George Gastaldi
                Reporter:
                gastaldi George Gastaldi
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: