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

Support maven war overlays in maven plugin run goal

    Details

    • Type: Enhancement
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Done
    • Affects Version/s: 2017.2.0
    • Fix Version/s: 2017.3.2
    • Component/s: plugins
    • Labels:
      None

      Description

      I am packaging web content in a separate maven assembly project and I would like to overlay that content into a swarm web app.

      <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-war-plugin</artifactId>
      <version>2.1.1</version>
      <configuration>
      <overlays>
      <overlay>
      <groupId>myapp</groupId>
      <artifactId>assets</artifactId>
      <classifier>md</classifier>
      <type>zip</type>
      </overlay>
      </overlays>
      </configuration>
      </plugin>

      I can successfully build the project and also run the uberjar successfully but when I try to run mvn wildfly-swarm:run I receive an NPE:

      [INFO] Starting .war
      Exception in thread "main" java.lang.RuntimeException: Failed to load cp info
      at org.wildfly.swarm.bootstrap.env.ApplicationEnvironment.loadDependencyTree(ApplicationEnvironment.java:108)
      at org.wildfly.swarm.bootstrap.env.ApplicationEnvironment.<init>(ApplicationEnvironment.java:73)
      at org.wildfly.swarm.bootstrap.env.ApplicationEnvironment.lambda$get$0(ApplicationEnvironment.java:57)
      at java.util.concurrent.atomic.AtomicReference.updateAndGet(AtomicReference.java:179)
      at org.wildfly.swarm.bootstrap.env.ApplicationEnvironment.get(ApplicationEnvironment.java:52)
      at org.wildfly.swarm.bootstrap.modules.ClasspathModuleFinder.findModule(ClasspathModuleFinder.java:52)
      at org.jboss.modules.ModuleLoader.findModule(ModuleLoader.java:439)
      at org.jboss.modules.ModuleLoader.loadModuleLocal(ModuleLoader.java:342)
      at org.jboss.modules.ModuleLoader.preloadModule(ModuleLoader.java:289)
      at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:221)
      at org.wildfly.swarm.bootstrap.MainInvoker.getMainClass(MainInvoker.java:76)
      at org.wildfly.swarm.bootstrap.MainInvoker.main(MainInvoker.java:65)
      Caused by: java.lang.NullPointerException
      at org.wildfly.swarm.bootstrap.env.ApplicationEnvironment.loadDependencyTree(ApplicationEnvironment.java:94)
      ... 11 more

      I forked a copy of swarm and then updated ApplicationEnvironment to do a null check but after that I received a different exception:

      2017-02-20 02:28:11,103 ERROR [stderr] (main) Caused by: java.lang.RuntimeException: Failed to resolve archive dependencies
      2017-02-20 02:28:11,104 ERROR [stderr] (main) at org.wildfly.swarm.container.runtime.RuntimeDeployer.deploy(RuntimeDeployer.java:209)
      2017-02-20 02:28:11,104 ERROR [stderr] (main) ... 9 more
      2017-02-20 02:28:11,104 ERROR [stderr] (main) Caused by: java.lang.IllegalArgumentException: Given file is not a directory /home/dev/.m2/repository/myapp/assets/0.0.1-SNAPSHOT/assets-0.0.1-SNAPSHOT-md.zip
      2017-02-20 02:28:11,104 ERROR [stderr] (main) at org.jboss.shrinkwrap.impl.base.importer.ExplodedImporterImpl.importDirectory(ExplodedImporterImpl.java:108)
      2017-02-20 02:28:11,104 ERROR [stderr] (main) at org.jboss.shrinkwrap.impl.base.importer.ExplodedImporterImpl.importDirectory(ExplodedImporterImpl.java:85)
      2017-02-20 02:28:11,104 ERROR [stderr] (main) at org.jboss.shrinkwrap.impl.base.importer.ExplodedImporterImpl.importDirectory(ExplodedImporterImpl.java:74)
      2017-02-20 02:28:11,105 ERROR [stderr] (main) at org.wildfly.swarm.container.runtime.RuntimeDeployer.deploy(RuntimeDeployer.java:199)
      2017-02-20 02:28:11,105 ERROR [stderr] (main) ... 9 more

      This appears to be due to RuntimeDeployer checking if the dependency is a jar otherwise defaulting to a directory import. I was thinking that I could just include the war/zip dependency in the shrinkwrapped war but I was concerned about having duplicate content as both a maven dependency and in the web app build directory via the maven overlay plugin.

      Is it possible to exclude the overlay dependency from the uberjar but still reference it via the maven plugin? I would like to continue to use the maven run plugin and it's immediate refresh capability to boost productivity.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  famod Falko Modler
                  Reporter:
                  aanderson1776 Aaron Anderson
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: