Maven Plugin: where is extensions folder?

I’m trying to develop a custom extension with HiveMQ CE 2021.3 and Maven Plugin. I have managed to create a trivial hello world extension and deploy it, starting HiveMQ from Eclipse IDE.

I would still like to run “hivemq-allow-all-extension”, but as I start from Eclipse, I see the following in the console:

No security extension present, MQTT clients can not connect to this broker.

The instructions say:

The Maven plugin does not use the extensions folder of the HiveMQ instance. When you use the Maven plugin to start a HiveMQ instance, only the extensions folder in the Maven build directory is used. https://www.hivemq.com/docs/hivemq/4.7/extensions/maven.html

Where is this “extensions folder”? I already tried adding a folder called extensions (containing the extension folders) into Maven project root and into target. In these cases, the extensions folder gets copied into target or target/target but the extensions still do not seem to get deployed.

As a workaround, I tried setting the VM argument -Dhivemq.extensions.folder="/(my-custom-extensions-folder)", but this changed nothing. I set this in the debug configuration of Maven in Eclipse.

That is, where to put the extensions not developed by me?

So, Maven is a complex beast. I think I should write some explicit Maven command or task (or whatever you call it) to copy the extensions to another folder so that HiveMQ would discover these when debugging. However, it seems it would take days or even weeks to learn Maven. So, I decided to try Gradle but this seems to work badly and be unresponsive in Eclipse. As I am a researcher rather than some full-time Java developer, I think it’s useless to spend a huge amount of time fighting with the technologies.

The current plan is to simply develop most of the functionality of our extension outside of HiveMQ, which is good design anyway I believe. Then, once everything works in unit tests, the logic will be wrapped as an extension and tested with manual deployments.

Hi @peekoo ,

Glad to see your interest in MQTT and HiveMQ!

To have a quick start with developing HiveMQ extensions, you might find our open source example Hello-World-Extension useful:

It already has a Gradle project with all necessary build tasks under the hood. You can simply clone the project, open it in your IDE (we usually use IntelliJ IDEA), run the Gradle task hivemqExtensionZip to build the extension, copy the ZIP to the HIVEMQ_HOME/extensions directory and start your HiveMQ broker.
The broker will load (not disabled) extensions from the HIVEMQ_HOME/extensions directory.

For further development and testing purpose you might find useful HiveMQ Test Container..

Kind regards,
Dasha from HiveMQ team

Dear Dasha, thanks for your reply. Still it seems I failed to communicate the problem as I explained that I already managed to create a simple extension. Instead, the problem was with debugging.

The debugging tools seem unnecessarily complex and difficult for simple research tasks. If I were an actual developer, it would likely spend more time learning them, but now it seems I’ll test and debug with other tools. Thanks anyway.

Thank you for your feedback @peekoo !

[INFO] ###############################################################################
[INFO] # No security extension present, MQTT clients can not connect to this broker. #
[INFO] ###############################################################################

Hi, this might be a little late but I had this problem too and I’ve solve it doing this.

  1. Copy the hivemq-allow-all-extension directory to the root of the project.
  2. Append to the Profile configuration in the pom.xml:
    <includeResources>${project.basedir}\hivemq-allow-all-extension</includeResources>
  • The extension can be included directly from your hivemq installation extension folder, just use the absolute path location

This is the full profile block.

<profiles>
        <profile>
            <id>RunWithHiveMQ</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.hivemq</groupId>
                        <artifactId>hivemq-maven-plugin</artifactId>
                        <version>4.0.3</version>
                        <executions>
                            <execution>
                                <id>hivemq</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>hivemq</goal>
                                </goals>
                                <configuration>
                                    <hiveMQDir>C:\hivemq-ce-2022.2</hiveMQDir>
                                    <includeResources>${project.basedir}\hivemq-allow-all-extension</includeResources>
                                    <debugMode>SERVER</debugMode>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
  1. Finally run again mvn package and watch it finally work.
  2. Drink a lot of cups of coffee because you don’t have to lose your time trying to fix this.

Hope this helps someone to not lose their time anymore.

1 Like