ActiveMQ
  1. ActiveMQ
  2. AMQ-2293

ActiveMQ Maven plugin fails to spin up broker in multi module project

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 5.2.0
    • Fix Version/s: 5.8.0
    • Component/s: None
    • Labels:
      None
    • Environment:

      Windows ONLY

    • Patch Info:
      Patch Available

      Description

      If one attampts to specify an absolute path the the activemq configuration file in a maven project using the maven parameters:

      <plugin>
          <groupId>org.apache.activemq.tooling</groupId>
          <artifactId>maven-activemq-plugin</artifactId>
          <version>${activemq.version}</version>
          <configuration>
              <configUri>xbean:file:///${basedir}/src/test/activemq/conf/activemq.xml</configUri>
          </configuration>
      </plugin>
      

      the broker will fail because $

      {basedir}

      in maven does not expand to a valid URI string.

      Tried as well:
      2) Using the xbeam:conf/activemq.xml does not work either as the mojo does not contain the directory on the classpath.

      3) Using the base dir and setting the configURI to xbean:file:///./src/test/qctivemq/conf/activemq.xml does work when executing the test phase within a single maven project but as soon as the activemq plugin is run from a module that is part of a project (see attachment example) then the . refers to the path of the parent project and the broker fails to find the file again.

      As far as I can see there is not really a sufficient workaround using the activemq.base activemq.home system properties and hence I propose to add another configuration alternative to the maven-activemq-plugin called configFile. This can then be set with the according absolute reference and the URI is properly constructred using the underlying JVM java.io.File.toURI(). Patch attached.

      The logic implemented by the patch is, if a configFile is set on the activemq plugin then it will construct a xbean:file:[uri] else it will use configUri (as usual).

      1. pom.xml
        5 kB
        Christian Posta
      2. example.zip
        3 kB
        Damian Hudson
      3. test-project.zip
        37 kB
        Niels Bertram
      4. AMQ-2293.patch
        2 kB
        Niels Bertram

        Issue Links

          Activity

          Hide
          Niels Bertram added a comment -

          Patch to fix the issue.

          Show
          Niels Bertram added a comment - Patch to fix the issue.
          Hide
          Niels Bertram added a comment -

          An example project that works after applying the patch.

          Show
          Niels Bertram added a comment - An example project that works after applying the patch.
          Hide
          Damian Hudson added a comment -

          I'm seeing similar behaviour with the maven-activemq-plugin (version 5.6.0). When I try and use the $

          {basedir} when setting <configUri>xbean:file:${basedir}

          /config/activemq.xml</configUri>, it spits out the following error "Failed to start ActiveMQ Broker: Illegal character in opaque part at index 16" when I run mvn activemq:run. Seems to get upset with the backslashes in $

          {basedir} (eg. xbean:file:c:\dev\workspace\example/config/activemq.xml) this isn't an issue in Linux, only Windows machines.

          I can get around the issue by using a relative path, as Niels did, but also run into problems with Multimoduled projects. To get around the issue I've had to use GMaven plugin to change the slashes in ${basedir}

          to forward slashes and feed the modified property into <configUri>, the workaround works, but it's ugly. If a change could be made to the plugin to cater for the Windows backslashes that would resolve the issue.

          DOESN'T WORK.....
          <configUri>xbean:file:$

          {basedir}

          /config/activemq.xml</configUri>
          <configUri>xbean:file:C:\workspace\activemqMavenIssue\example\config\activemq.xml</configUri>
          <configUri>xbean:file:C:\\workspace\\activemqMavenIssue\\example\\config\\activemq.xml</configUri>

          WORKS.....
          <configUri>xbean:file:C:/workspace/activemqMavenIssue/example/config/activemq.xml</configUri>

          Show
          Damian Hudson added a comment - I'm seeing similar behaviour with the maven-activemq-plugin (version 5.6.0). When I try and use the $ {basedir} when setting <configUri>xbean: file:$ {basedir} /config/activemq.xml</configUri>, it spits out the following error "Failed to start ActiveMQ Broker: Illegal character in opaque part at index 16" when I run mvn activemq:run. Seems to get upset with the backslashes in $ {basedir} (eg. xbean: file:c:\dev\workspace\example/config/activemq.xml ) this isn't an issue in Linux, only Windows machines. I can get around the issue by using a relative path, as Niels did, but also run into problems with Multimoduled projects. To get around the issue I've had to use GMaven plugin to change the slashes in ${basedir} to forward slashes and feed the modified property into <configUri>, the workaround works, but it's ugly. If a change could be made to the plugin to cater for the Windows backslashes that would resolve the issue. DOESN'T WORK..... <configUri>xbean: file:$ {basedir} /config/activemq.xml</configUri> <configUri>xbean: file:C:\workspace\activemqMavenIssue\example\config\activemq.xml </configUri> <configUri>xbean: file:C:\\workspace\\activemqMavenIssue\\example\\config\\activemq.xml </configUri> WORKS..... <configUri>xbean: file:C:/workspace/activemqMavenIssue/example/config/activemq.xml </configUri>
          Hide
          Christian Posta added a comment -
          Show
          Christian Posta added a comment - Looks like Tim fixed this in https://issues.apache.org/jira/browse/AMQ-4140
          Hide
          Christian Posta added a comment -

          So I tried with the latest snapshot on windows and verified that it works. See the pom.xml i attached for how to point to the latest snapshot.

          If someone else can confirm, so we can close this ticket....

          Show
          Christian Posta added a comment - So I tried with the latest snapshot on windows and verified that it works. See the pom.xml i attached for how to point to the latest snapshot. If someone else can confirm, so we can close this ticket....

            People

            • Assignee:
              Claus Ibsen
              Reporter:
              Niels Bertram
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development