13 Replies Latest reply on Nov 21, 2018 9:37 AM by simkam

    How to configurate properly wildfly14.0.1 modules

    Crispin Quizo Newbie

      I have many projects that I configured as wildfly modules into path WILDFLY_HOME/modules/ because they are specifications, static implementations and so-on.

      In order to use those wildfly modules in a project, I want to set only a reference into file "jboss-deployment-structure.xml", so I grouped them as follows:

       

      Fist level: Into this group there are references to another modules(second level) that contains services into META-INF/services

      <?xml version="1.0" encoding="UTF-8"?>

      <module xmlns="urn:jboss:module:1.5" name="bo.dummy.module">

          <dependencies>

              <module name="javaee.api"/>

              <module name="bo.dummy.framework.api" services="import" export="true"/>

              <module ...

          </dependencies>

      </module>

       

      Second level: There are another modules(third level) that contains services into META-INF/services

      <?xml version="1.0" encoding="UTF-8"?>

      <module xmlns="urn:jboss:module:1.5" name="bo.dummy.framework.api">

          <properties>

              <property name="bo.dummy.build" value="BUILD_20181030_1006"/>

              <property name="bo.dummy.version" value="2.1.1-SNAPSHOT"/>

          </properties>

          <dependencies>

              <module name="org.picketbox"/>

              <module name="javaee.api"/>

              <module name="bo.dummy.framework.api.rest" services="import" export="true"/>

              <module ...

          </dependencies>

      </module>

       

      Third level: Here there is the module that includes a javax.ws.rs.container.ContainerResponseFilter as a service referenced into META-INF/services

      <?xml version="1.0" encoding="UTF-8"?>

      <module xmlns="urn:jboss:module:1.5" name="bo.dummy.framework.api.rest">

          <resources>

              <resource-root path="../../BUILD_20181030_1006/dummy-rest-1.0.4-SNAPSHOT.jar"/>

          </resources>

          <dependencies>

              <module name="javaee.api"/>

              <module name="javax.ws.rs.api"/>

              <module name="javax.xml.bind.api" />

              <module ...

          </dependencies>

      </module>

       

      At my project: Into my WAR project I added the file "jboss-deployment-structure.xml" into WEB-INF/ to refer only to the First level module

      <?xml version="1.0" encoding="UTF-8"?>

      <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.3">

      <deployment>

        <dependencies>

         <module name="bo.dummy.module" services="import"/>

        </dependencies>

      </deployment>

      </jboss-deployment-structure>

       

      This configuration was working well in Wildfly11.x but it does not work in the current version.

       

      Please help me to solve this issue, every suggestions are welcome.

        • 1. Re: How to configurate properly wildfly14.0.1 modules
          simkam Newbie

          Hi,

           

          do you see any exceptions in server log? What exactly does not work?

           

          Thanks

          • 2. Re: How to configurate properly wildfly14.0.1 modules
            Crispin Quizo Newbie

            Hi Martin thanks for answering,

             

            There is no any exception in server log.

             

            I implemented a filter in "bo.dummy.framework.api.rest" module, the implementations is of this interface "javax.ws.rs.container.ContainerResponseFilter", I did that to add headers, messages and behaviors to every Rest call, the filter reference is into META-INF/services with the next name "javax.ws.rs.ext.Providers", this file contains my class filter's name "bo.dummy.rest.DeliveryResponseFilter"

             

            I need my filter implementation work in another WAR projects, that is because I added the file "jboss-deployment-structure.xml" into those war projects to refer to my principal wildfly module "<module name="bo.dummy.module" services="import"/>", but with wildfly14 my filter is never executed so headers, messages and behaviors are not present in http response.

             

            Only my filter implementation is not executed.

            • 3. Re: How to configurate properly wildfly14.0.1 modules
              Marek Kopecký Newbie

              This configuration is not working at Wildfly11 for me (I used similar xml files and really simple ContainerResponseFilter implementation (that just print some message to console)). Same for WF14.0.1.

               

              But it works for me if I use ``services="export"`` in first and second level. Can you please try this? Can you also please double-check wf11 behaviour?

              • 4. Re: How to configurate properly wildfly14.0.1 modules
                Crispin Quizo Newbie

                Marek,

                It is correct, I also used services="export" in wildfly11 because it uses "urn:jboss:module:1.3" but wildfly14 uses "urn:jboss:module:1.5" and I saw that another modules use "urn:jboss:module:1.8". May be the trouble is in jboss module version, what version should I use?

                • 5. Re: How to configurate properly wildfly14.0.1 modules
                  simkam Newbie

                  schema version shouldn't make any difference. Probably the best would be to use latest (1.8). I'm confused what you consider troubles. If you use services="export" at first and second level, does it work with WildFly 14?

                  • 6. Re: How to configurate properly wildfly14.0.1 modules
                    Crispin Quizo Newbie

                    No, it does not work in wildfly14.

                    At this time, I tried adding the provider services at first level and it also does not work.

                    • 7. Re: How to configurate properly wildfly14.0.1 modules
                      Marek Kopecký Newbie

                      ``services="export"`` works for me in WF14 for simple ContainerResponseFilter implementation.

                       

                      • Can you please share more details about your ContainerResponseFilter? I tried this with simple implementation of ContainerResponseFilter that just print some message to console.
                      • Do you have access to classes from "BUILD_20181030_1006/dummy-rest-1.0.4-SNAPSHOT.jar" in your deployment? If no: I check this with absolute path in third level module.xml. Can you please try it as well? (just to be sure)
                      • 8. Re: How to configurate properly wildfly14.0.1 modules
                        Crispin Quizo Newbie

                        Hi Marek,

                        • My filter also has message and other things. But in runtime does never pass by filter
                        • I have access to my classes from dummy-rest...jar

                        Can you please send me your configuration?

                        • 9. Re: How to configurate properly wildfly14.0.1 modules
                          Marek Kopecký Newbie

                          I use these CLI commands:

                          • module add --name=bo.dummy.module --export-dependencies=bo.dummy.framework.api --allow-nonexistent-resources --resources=place-holder
                          • module add --name=bo.dummy.framework.api --resources=place-holder --dependencies=javaee.api --export-dependencies=bo.dummy.framework.api.rest --allow-nonexistent-resources
                          • module add --name=bo.dummy.framework.api.rest --resources=place-holder --dependencies=javaee.api,javax.ws.rs.api,javax.xml.bind.api --allow-nonexistent-resources

                           

                          I updated new module.xml files to looks like yours from your first comment. But I used absolute path for dummy-rest jar file.

                           

                          I uses this filter:

                          public class MyCustomContainerResponseFilter implements ContainerResponseFilter {

                             @Override

                             public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException {

                                System.out.println("testing");

                             }

                          }

                           

                          I use this end-point:

                          @Path("/a")

                          public class Resource {

                              @GET

                              @Path("b")

                              @Produces(MediaType.APPLICATION_JSON)

                              public List b() {

                                  return Stream.of("a", "b", "c").collect(Collectors.toList());

                              }

                          }

                           

                          If you still see this issue: can you please share minimal example of this issue (reproducer, zip with modules and deployment)?

                          • 10. Re: How to configurate properly wildfly14.0.1 modules
                            Crispin Quizo Newbie

                            Hi Marek,

                            I did what you suggest me but it does not work jet.

                             

                            I am attaching a complete example with only two levels:

                            bo.dummy.module

                                 -> bo.dummy.framework.api.rest

                                 -> bo.dummy.framework.api.sec

                             

                            • module_conf.zip has all wildfly modules created using CLI commands
                            • wf14test.zip has the complete example

                             

                            After deploying, I only see the next log:

                            20:06:51,065 INFO  [bo.dummy.module.test.DummyRest] (default task-1) Calling getInfo

                             

                            Thanks in advance for your help.

                            • 11. Re: How to configurate properly wildfly14.0.1 modules
                              Marek Kopecký Newbie

                              As I mentioned earlier,  services="export" is necessary. Try to use these changes in modules_conf.zip:

                               

                               

                              diff --git a/bo/dummy/framework/api/sec/main/module.xml b/bo/dummy/framework/api/sec/main/module.xml

                              --- a/bo/dummy/framework/api/sec/main/module.xml

                              +++ b/bo/dummy/framework/api/sec/main/module.xml

                              @@ -7,6 +7,9 @@

                                   </resources>

                               

                                   <dependencies>

                              -        <module name="bo.dummy.framework.api.rest" export="true"/>

                              +        <module name="bo.dummy.framework.api.rest" export="true" services="export"/>

                              +        <module name="javaee.api"/>

                              +        <module name="javax.ws.rs.api"/>

                              +        <module name="javax.xml.bind.api"/>

                                   </dependencies>

                              </module>

                              \ No newline at end of file

                               

                              diff --git a/bo/dummy/module/main/module.xml b/bo/dummy/module/main/module.xml

                              --- a/bo/dummy/module/main/module.xml

                              +++ b/bo/dummy/module/main/module.xml

                              @@ -7,7 +7,6 @@

                                   </resources>

                               

                                   <dependencies>

                              -        <module name="bo.dummy.framework.api.rest" export="true"/>

                              -        <module name="bo.dummy.framework.api.sec" export="true"/>

                              +        <module name="bo.dummy.framework.api.sec" export="true" services="export"/>

                                   </dependencies>

                              </module>

                              \ No newline at end of file

                               

                               

                               

                              My output on wf14.0.1:

                              11:00:32,460 WARNING [bo.dummy.framework.api.sec.DummyResponseSecFilter] (default task-1) + Response Filter for: http://localhost:8080/dummy/test/rest/dummy/info

                              11:00:32,460 WARNING [bo.dummy.framework.api.sec.DummyResponseSecFilter] (default task-1) + DummyClass state: DummyClass{id='123', name='Name one'}

                              11:00:32,589 INFO  [bo.dummy.module.test.DummyRest] (default task-1) Calling getInfo

                              11:00:32,596 SEVERE [bo.dummy.framework.api.sec.DummyResponseSecFilter] (default task-1) - Response Filter for: http://localhost:8080/dummy/test/rest/dummy/info

                              11:00:32,596 SEVERE [bo.dummy.framework.api.sec.DummyResponseSecFilter] (default task-1) - DummyClass state: DummyClass{id='456', name='Name two'}

                              11:00:32,597 INFO  [bo.dummy.framework.api.rest.DummyResponseRestFilter] (default task-1) * Response Filter for: http://localhost:8080/dummy/test/rest/dummy/info

                               

                              Both filters are used ...

                              • 12. Re: How to configurate properly wildfly14.0.1 modules
                                Crispin Quizo Newbie

                                Hi Marek,

                                How did you configured "jboss-deployment-structure.xml" descriptor?

                                Could you please send me all you test case?

                                • 13. Re: How to configurate properly wildfly14.0.1 modules
                                  simkam Newbie

                                  Hi Crispin,

                                   

                                  I believe that Marek just updated your reproducer. He updated two files (bo/dummy/framework/api/sec/main/module.xml and bo/dummy/module/main/module.xml), nothing else. See diffs in his last post. As already mentioned, it looks like the main issue is missing services="export" in modules (don't confuse it with export="true").

                                   

                                  Martin