Search code examples
jmswildflymaven-shade-plugin

Wildfly fails to retrieve TopicConnectionFactory in shaded JAR WFNAM00026: No provider for found for URI: null


I have a client app which connects to a Wildfly 27 instance. One of the requirements is that in the end the client is all in one easy to distribute executable. to be used by end users on windows systems. To achieve this i am using the maven shade plugin and launch4j.

When i then run the created exe the lookup TopicConnectionFactory tcf = (TopicConnectionFactory) initialContext.lookup("jms/RemoteConnectionFactory"); fails with the WFNAM00026: No provider for found for URI: null ## Error Message.

If I run it from Eclipse it retrieves tcf as ActiveMQJMSConnectionFactory.

My problem now is that the instance i can debug is working and i can not add prints for anything beyond the lookup because it goes into the wildfly classes.

If I run the shaded jar directly the error stays the same.

My conclusion is that something isnt being included in the shaded jar or i am missing some setting.

Except from the POM:

               <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>3.4.1</version>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>shade</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <filters>
                            <filter>
                                <artifact>*:*</artifact>
                                <excludes>
                                    <exclude>META-INF/*.SF</exclude>
                                    <exclude>META-INF/*.DSA</exclude>
                                    <exclude>META-INF/*.RSA</exclude>
                                </excludes>
                            </filter>
                        </filters>
                        <shadedArtifactAttached>true</shadedArtifactAttached>
                        <shadedClassifierName>shaded</shadedClassifierName>
                        <transformers>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <mainClass>[SNIP]/main/StartApplication</mainClass>
                            </transformer>
                        </transformers>
                    </configuration>
                </plugin>  

When running mvn package this line caught my attention, but i have not been able to figure out how to work around it, or if it even is relevant: [INFO] Skipping pom dependency org.wildfly:wildfly-jms-client-bom:pom:27.0.1.Final in the shaded jar.

I have been banging my head against this for days now and am desperate, so i would appreciate any straws to grasp onto.


Solution

  • I found the solution I was missing Resource transformers in the the configuration. I added:

     <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
    <transformer implementation="org.apache.maven.plugins.shade.resource.PluginXmlResourceTransformer"/>
    

    And i works now.