Hi Wolfgang,

if you are speaking about a project of yours where you are using the shade 
plugin, then you need to add a transformer to your plugin configuration.
Every driver has a META-INF/services/org.apache.plc4x.java.api.PlcDriver file, 
which lists that particular driver.
If you run the shade plugin without any transformer only one of these are 
packaged in the jar the others are omitted. 
That's why you have only one driver availale.

In order to fix this please update your plugin configuration like we did in the 
examples:

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <executions>
          <execution>
            <id>generate-uber-jar</id>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <transformers>
                <transformer 
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                <transformer 
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                  <mainClass>${app.main.class}</mainClass>
                </transformer>
              </transformers>
        <filters>
              <filter>
                <!--
                  These files contain signatures for classes, omit them as in
                  shaded archives this has cause quite some problems in the 
past.
                -->
                <artifact>*:*</artifact>
                <excludes>
                  <exclude>META-INF/*.SF</exclude>
                  <exclude>META-INF/*.DSA</exclude>
                  <exclude>META-INF/*.RSA</exclude>
                </excludes>
              </filter>
            </filters>
            </configuration>
          </execution>
        </executions>
      </plugin>

Hope that helps.


Chris



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

Am 14.05.20, 10:31 schrieb "Wolfgang Huse" <[email protected]>:

    Hi,
    i am builing a fat jar with maven shade plugin but if I run the application 
an error occurs:

    17:32.651 [main] INFO  o.apache.plc4x.java.PlcDriverManager - Instantiating 
new PLC Driver Manager with class loader 
jdk.internal.loader.ClassLoaders$AppClassLoader@55054057
    10:17:32.653 [main] INFO  o.apache.plc4x.java.PlcDriverManager - 
Registering available drivers...
    10:17:32.658 [main] INFO  o.apache.plc4x.java.PlcDriverManager - 
Registering driver for Protocol modbus (Modbus)
    Exception in thread "main" 
org.apache.plc4x.java.api.exceptions.PlcConnectionException: Unable to find 
driver for protocol 'opcua'

    Any hint how to include the needed classes for the drivers ?

    Mit freundlichen Grüßen – With kind regards

    Wolfgang Huse


Reply via email to