You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2026/10/13 14:10:42 UTC

(plc4x) 02/02: fix(plc4j): make the generated Karaf driver features installable

This is an automated email from the ASF dual-hosted git repository.

sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit 2596101817433ed78e356a262432a29b8f9bc9c6
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Tue Oct 13 16:08:25 2026 +0200

    fix(plc4j): make the generated Karaf driver features installable
    
    The features generated for the plc4j drivers could not work on their own.
    They held only the driver's dependencies, not the driver bundle itself.
    They lacked plc4j-osgi, which holds every driver's and transport's
    Bundle-Activator. And they pulled in two bundles that don't resolve on a
    plain Karaf: transports-api required an SCR implementation, and the plain
    slf4j-api 2.x bundle required SPI Fly plus a separate SLF4J provider.
    The karaf-maven-plugin verify goal ran in every driver module, but with
    no descriptors configured it checked nothing and passed regardless.
    
    - karaf-maven-plugin defaults now live in the root pluginManagement: the
      feature includes the project artifact, and slf4j-api is left out
      because Karaf's pax-logging exports org.slf4j. The verify goal resolves
      the module's own feature against Karaf's framework and standard
      features. It runs at verify, once the jar exists, instead of at compile.
    - plc4j-osgi is a compile dependency of every driver (via plc4j-drivers)
      and transport, since the feature generator only collects compile
      scope. Its osgi.core is now provided, so plain Java users only gain
      the plc4j-osgi jar itself. The dependency analyzer can't see a manifest
      header, so plc4j-osgi is ignored for unused-declared checks.
    - OsgiTransportManager is gone. The DS component never had transports to
      bind, and the registry-backed lookup in plc4j-osgi replaces it.
      Removing it also removes the SCR requirement and the DS annotation
      bundles from every feature.
    
    The duplicated Service-Component entries seen in local jars only happened
    when building without clean, and only for that DS component.
    
    All 21 driver features now verify. Without the plc4j-drivers dependency,
    CANopen fails verification with the missing
    org.apache.plc4x.java.osgi import, so the check catches this kind of
    break. In a fresh Karaf 4.4.11, `feature:install plc4j-driver-s7
    plc4j-driver-modbus plc4j-driver-ctrlx` starts all 22 bundles with
    nothing installed by hand. S7 and Modbus connections then reach "Connection
    refused" on a closed port.
---
 RELEASE_NOTES                                      |  16 +++
 plc4j/drivers/ab-eth/pom.xml                       |   2 -
 plc4j/drivers/ads/pom.xml                          |   2 -
 plc4j/drivers/bacnet/pom.xml                       |   2 -
 plc4j/drivers/c-bus/pom.xml                        |   2 -
 plc4j/drivers/can/pom.xml                          |   2 -
 plc4j/drivers/canopen/pom.xml                      |   2 -
 plc4j/drivers/ctrlx/pom.xml                        |   2 -
 plc4j/drivers/eip/pom.xml                          |   2 -
 plc4j/drivers/firmata/pom.xml                      |   2 -
 plc4j/drivers/iec-60870/pom.xml                    |   2 -
 plc4j/drivers/knxnetip/pom.xml                     |   2 -
 plc4j/drivers/modbus/pom.xml                       |   2 -
 plc4j/drivers/opcua/pom.xml                        |   2 -
 plc4j/drivers/open-protocol/pom.xml                |   2 -
 plc4j/drivers/plc4x/pom.xml                        |   2 -
 plc4j/drivers/pom.xml                              |  12 +++
 plc4j/drivers/profinet-ng/pom.xml                  |   2 -
 plc4j/drivers/profinet/pom.xml                     |   2 -
 plc4j/drivers/s7/pom.xml                           |   2 -
 plc4j/drivers/simulated/pom.xml                    |   2 -
 plc4j/drivers/slmp/pom.xml                         |   1 -
 plc4j/drivers/umas/pom.xml                         |   1 -
 plc4j/osgi/pom.xml                                 |   2 +
 plc4j/pom.xml                                      |   4 +
 plc4j/transports/api/pom.xml                       |   6 --
 .../spi/transports/api/OsgiTransportManager.java   |  65 ------------
 .../transports/api/OsgiTransportManagerTest.java   | 111 ---------------------
 plc4j/transports/can-socketcan/pom.xml             |   7 ++
 plc4j/transports/can-virtualcan/pom.xml            |   7 ++
 plc4j/transports/cotp/pom.xml                      |   7 ++
 plc4j/transports/pcap-replay/pom.xml               |   7 ++
 plc4j/transports/raw-socket/pom.xml                |   7 ++
 plc4j/transports/serial/pom.xml                    |   7 ++
 plc4j/transports/tcp/pom.xml                       |   7 ++
 plc4j/transports/test/pom.xml                      |   7 ++
 plc4j/transports/tls/pom.xml                       |   7 ++
 plc4j/transports/udp/pom.xml                       |   7 ++
 pom.xml                                            |  48 +++++++--
 39 files changed, 146 insertions(+), 228 deletions(-)

diff --git a/RELEASE_NOTES b/RELEASE_NOTES
index 5aa006b3fa..75f10983f1 100644
--- a/RELEASE_NOTES
+++ b/RELEASE_NOTES
@@ -8,9 +8,25 @@ New Features
 Incompatible changes
 --------------------
 
+- Removed OsgiTransportManager from plc4j-transports-api. The
+  declarative-services component never had any transports to
+  bind; drivers in OSGi now resolve transports through the
+  service registry (see Bug Fixes). This also drops the
+  transports-api bundle's requirement on an SCR implementation.
+
 Bug Fixes
 ---------
 
+- plc4j drivers in OSGi (e.g. Apache Karaf) could not find any
+  transport and failed every connection with "Unsupported
+  transport". The transport bundles register their transports
+  as OSGi services again, and the drivers look them up there.
+- The generated Karaf features for the plc4j drivers now contain
+  the driver bundle itself and plc4j-osgi, and no longer need an
+  SCR implementation, SPI Fly or a separate SLF4J provider.
+  `feature:install plc4j-driver-<name>` is all a Karaf 4.4
+  container needs. The build verifies each feature resolves.
+
 ==============================================================
 Apache PLC4X 1.0.0
 ==============================================================
diff --git a/plc4j/drivers/ab-eth/pom.xml b/plc4j/drivers/ab-eth/pom.xml
index 3be078b8b7..2b82b35aba 100644
--- a/plc4j/drivers/ab-eth/pom.xml
+++ b/plc4j/drivers/ab-eth/pom.xml
@@ -46,8 +46,6 @@
             <goals>
               <!-- Generate the feature.xml -->
               <goal>features-generate-descriptor</goal>
-              <!-- Check the feature.xml -->
-              <goal>verify</goal>
             </goals>
             <configuration>
               <enableGeneration>true</enableGeneration>
diff --git a/plc4j/drivers/ads/pom.xml b/plc4j/drivers/ads/pom.xml
index ef50bbaa2e..0d2e020b55 100644
--- a/plc4j/drivers/ads/pom.xml
+++ b/plc4j/drivers/ads/pom.xml
@@ -45,8 +45,6 @@
             <goals>
               <!-- Generate the feature.xml -->
               <goal>features-generate-descriptor</goal>
-              <!-- Check the feature.xml -->
-              <goal>verify</goal>
             </goals>
             <configuration>
               <enableGeneration>true</enableGeneration>
diff --git a/plc4j/drivers/bacnet/pom.xml b/plc4j/drivers/bacnet/pom.xml
index 8b3948c0b2..7650be45bf 100644
--- a/plc4j/drivers/bacnet/pom.xml
+++ b/plc4j/drivers/bacnet/pom.xml
@@ -52,8 +52,6 @@
             <goals>
               <!-- Generate the feature.xml -->
               <goal>features-generate-descriptor</goal>
-              <!-- Check the feature.xml -->
-              <goal>verify</goal>
             </goals>
             <configuration>
               <enableGeneration>true</enableGeneration>
diff --git a/plc4j/drivers/c-bus/pom.xml b/plc4j/drivers/c-bus/pom.xml
index 232dade4ff..98acb0bdd9 100644
--- a/plc4j/drivers/c-bus/pom.xml
+++ b/plc4j/drivers/c-bus/pom.xml
@@ -54,8 +54,6 @@
             <goals>
               <!-- Generate the feature.xml -->
               <goal>features-generate-descriptor</goal>
-              <!-- Check the feature.xml -->
-              <goal>verify</goal>
             </goals>
             <configuration>
               <enableGeneration>true</enableGeneration>
diff --git a/plc4j/drivers/can/pom.xml b/plc4j/drivers/can/pom.xml
index 2353f4e48d..5d8d9ebcb9 100644
--- a/plc4j/drivers/can/pom.xml
+++ b/plc4j/drivers/can/pom.xml
@@ -47,8 +47,6 @@
             <goals>
               <!-- Generate the feature.xml -->
               <goal>features-generate-descriptor</goal>
-              <!-- Check the feature.xml -->
-              <goal>verify</goal>
             </goals>
             <configuration>
               <enableGeneration>true</enableGeneration>
diff --git a/plc4j/drivers/canopen/pom.xml b/plc4j/drivers/canopen/pom.xml
index 9c5eb542d3..75fd747599 100644
--- a/plc4j/drivers/canopen/pom.xml
+++ b/plc4j/drivers/canopen/pom.xml
@@ -47,8 +47,6 @@
             <goals>
               <!-- Generate the feature.xml -->
               <goal>features-generate-descriptor</goal>
-              <!-- Check the feature.xml -->
-              <goal>verify</goal>
             </goals>
             <configuration>
               <enableGeneration>true</enableGeneration>
diff --git a/plc4j/drivers/ctrlx/pom.xml b/plc4j/drivers/ctrlx/pom.xml
index 9184eb0101..e7a8ae14ee 100644
--- a/plc4j/drivers/ctrlx/pom.xml
+++ b/plc4j/drivers/ctrlx/pom.xml
@@ -84,8 +84,6 @@
             <goals>
               <!-- Generate the feature.xml -->
               <goal>features-generate-descriptor</goal>
-              <!-- Check the feature.xml -->
-              <goal>verify</goal>
             </goals>
             <configuration>
               <enableGeneration>true</enableGeneration>
diff --git a/plc4j/drivers/eip/pom.xml b/plc4j/drivers/eip/pom.xml
index ddace4de60..b9296757c2 100644
--- a/plc4j/drivers/eip/pom.xml
+++ b/plc4j/drivers/eip/pom.xml
@@ -47,8 +47,6 @@
             <goals>
               <!-- Generate the feature.xml -->
               <goal>features-generate-descriptor</goal>
-              <!-- Check the feature.xml -->
-              <goal>verify</goal>
             </goals>
             <configuration>
               <enableGeneration>true</enableGeneration>
diff --git a/plc4j/drivers/firmata/pom.xml b/plc4j/drivers/firmata/pom.xml
index f098e7628a..e6021152c2 100644
--- a/plc4j/drivers/firmata/pom.xml
+++ b/plc4j/drivers/firmata/pom.xml
@@ -45,8 +45,6 @@
             <goals>
               <!-- Generate the feature.xml -->
               <goal>features-generate-descriptor</goal>
-              <!-- Check the feature.xml -->
-              <goal>verify</goal>
             </goals>
             <configuration>
               <enableGeneration>true</enableGeneration>
diff --git a/plc4j/drivers/iec-60870/pom.xml b/plc4j/drivers/iec-60870/pom.xml
index aa9037c27d..ee01ad96f7 100644
--- a/plc4j/drivers/iec-60870/pom.xml
+++ b/plc4j/drivers/iec-60870/pom.xml
@@ -46,8 +46,6 @@
             <goals>
               <!-- Generate the feature.xml -->
               <goal>features-generate-descriptor</goal>
-              <!-- Check the feature.xml -->
-              <goal>verify</goal>
             </goals>
             <configuration>
               <enableGeneration>true</enableGeneration>
diff --git a/plc4j/drivers/knxnetip/pom.xml b/plc4j/drivers/knxnetip/pom.xml
index 21bb6dec5b..8f02eb0f5b 100644
--- a/plc4j/drivers/knxnetip/pom.xml
+++ b/plc4j/drivers/knxnetip/pom.xml
@@ -45,8 +45,6 @@
             <goals>
               <!-- Generate the feature.xml -->
               <goal>features-generate-descriptor</goal>
-              <!-- Check the feature.xml -->
-              <goal>verify</goal>
             </goals>
             <configuration>
               <enableGeneration>true</enableGeneration>
diff --git a/plc4j/drivers/modbus/pom.xml b/plc4j/drivers/modbus/pom.xml
index aa446633ba..c982d09b15 100644
--- a/plc4j/drivers/modbus/pom.xml
+++ b/plc4j/drivers/modbus/pom.xml
@@ -46,8 +46,6 @@
             <goals>
               <!-- Generate the feature.xml -->
               <goal>features-generate-descriptor</goal>
-              <!-- Check the feature.xml -->
-              <goal>verify</goal>
             </goals>
             <configuration>
               <enableGeneration>true</enableGeneration>
diff --git a/plc4j/drivers/opcua/pom.xml b/plc4j/drivers/opcua/pom.xml
index 87c0ecf8a7..ec461de42d 100644
--- a/plc4j/drivers/opcua/pom.xml
+++ b/plc4j/drivers/opcua/pom.xml
@@ -48,8 +48,6 @@
             <goals>
               <!-- Generate the feature.xml -->
               <goal>features-generate-descriptor</goal>
-              <!-- Check the feature.xml -->
-              <goal>verify</goal>
             </goals>
             <configuration>
               <enableGeneration>true</enableGeneration>
diff --git a/plc4j/drivers/open-protocol/pom.xml b/plc4j/drivers/open-protocol/pom.xml
index 4e844c1bfe..37176c130a 100644
--- a/plc4j/drivers/open-protocol/pom.xml
+++ b/plc4j/drivers/open-protocol/pom.xml
@@ -53,8 +53,6 @@
             <goals>
               <!-- Generate the feature.xml -->
               <goal>features-generate-descriptor</goal>
-              <!-- Check the feature.xml -->
-              <goal>verify</goal>
             </goals>
             <configuration>
               <enableGeneration>true</enableGeneration>
diff --git a/plc4j/drivers/plc4x/pom.xml b/plc4j/drivers/plc4x/pom.xml
index 976f386eeb..5250c6d45e 100644
--- a/plc4j/drivers/plc4x/pom.xml
+++ b/plc4j/drivers/plc4x/pom.xml
@@ -47,8 +47,6 @@
             <goals>
               <!-- Generate the feature.xml -->
               <goal>features-generate-descriptor</goal>
-              <!-- Check the feature.xml -->
-              <goal>verify</goal>
             </goals>
             <configuration>
               <enableGeneration>true</enableGeneration>
diff --git a/plc4j/drivers/pom.xml b/plc4j/drivers/pom.xml
index 8614d2f429..8b3b7edb79 100644
--- a/plc4j/drivers/pom.xml
+++ b/plc4j/drivers/pom.xml
@@ -35,4 +35,16 @@
     <project.build.outputTimestamp>2026-09-03T20:46:19Z</project.build.outputTimestamp>
   </properties>
 
+  <!--
+    Every driver bundle declares Bundle-Activator: org.apache.plc4x.java.osgi.DriverActivator. Compile
+    scope, as the Karaf feature generator only picks up those.
+  -->
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.plc4x</groupId>
+      <artifactId>plc4j-osgi</artifactId>
+      <version>1.1.0-SNAPSHOT</version>
+    </dependency>
+  </dependencies>
+
 </project>
diff --git a/plc4j/drivers/profinet-ng/pom.xml b/plc4j/drivers/profinet-ng/pom.xml
index 798f79a9ab..d8f5c742a9 100644
--- a/plc4j/drivers/profinet-ng/pom.xml
+++ b/plc4j/drivers/profinet-ng/pom.xml
@@ -53,8 +53,6 @@
             <goals>
               <!-- Generate the feature.xml -->
               <goal>features-generate-descriptor</goal>
-              <!-- Check the feature.xml -->
-              <goal>verify</goal>
             </goals>
             <configuration>
               <enableGeneration>true</enableGeneration>
diff --git a/plc4j/drivers/profinet/pom.xml b/plc4j/drivers/profinet/pom.xml
index 2f5677311c..4f6a124949 100644
--- a/plc4j/drivers/profinet/pom.xml
+++ b/plc4j/drivers/profinet/pom.xml
@@ -53,8 +53,6 @@
             <goals>
               <!-- Generate the feature.xml -->
               <goal>features-generate-descriptor</goal>
-              <!-- Check the feature.xml -->
-              <goal>verify</goal>
             </goals>
             <configuration>
               <enableGeneration>true</enableGeneration>
diff --git a/plc4j/drivers/s7/pom.xml b/plc4j/drivers/s7/pom.xml
index 496239933a..b09a7ae539 100644
--- a/plc4j/drivers/s7/pom.xml
+++ b/plc4j/drivers/s7/pom.xml
@@ -97,8 +97,6 @@
             <goals>
               <!-- Generate the feature.xml -->
               <goal>features-generate-descriptor</goal>
-              <!-- Check the feature.xml -->
-              <goal>verify</goal>
             </goals>
             <configuration>
               <enableGeneration>true</enableGeneration>
diff --git a/plc4j/drivers/simulated/pom.xml b/plc4j/drivers/simulated/pom.xml
index db850f754d..c576919163 100644
--- a/plc4j/drivers/simulated/pom.xml
+++ b/plc4j/drivers/simulated/pom.xml
@@ -46,8 +46,6 @@
             <goals>
               <!-- Generate the feature.xml -->
               <goal>features-generate-descriptor</goal>
-              <!-- Check the feature.xml -->
-              <goal>verify</goal>
             </goals>
             <configuration>
               <enableGeneration>true</enableGeneration>
diff --git a/plc4j/drivers/slmp/pom.xml b/plc4j/drivers/slmp/pom.xml
index 001a125e5c..249479df55 100644
--- a/plc4j/drivers/slmp/pom.xml
+++ b/plc4j/drivers/slmp/pom.xml
@@ -45,7 +45,6 @@
             <phase>compile</phase>
             <goals>
               <goal>features-generate-descriptor</goal>
-              <goal>verify</goal>
             </goals>
             <configuration>
               <enableGeneration>true</enableGeneration>
diff --git a/plc4j/drivers/umas/pom.xml b/plc4j/drivers/umas/pom.xml
index c8c11bada9..6b51bc124e 100644
--- a/plc4j/drivers/umas/pom.xml
+++ b/plc4j/drivers/umas/pom.xml
@@ -45,7 +45,6 @@
             <phase>compile</phase>
             <goals>
               <goal>features-generate-descriptor</goal>
-              <goal>verify</goal>
             </goals>
             <configuration>
               <enableGeneration>true</enableGeneration>
diff --git a/plc4j/osgi/pom.xml b/plc4j/osgi/pom.xml
index 75bf8b1cbb..ea81b23b1f 100644
--- a/plc4j/osgi/pom.xml
+++ b/plc4j/osgi/pom.xml
@@ -35,9 +35,11 @@
   </properties>
 
   <dependencies>
+    <!-- Provided by the framework: don't drag it onto the class path of every driver user -->
     <dependency>
       <groupId>org.osgi</groupId>
       <artifactId>osgi.core</artifactId>
+      <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.plc4x</groupId>
diff --git a/plc4j/pom.xml b/plc4j/pom.xml
index 9cadf93b37..a4236a82ae 100644
--- a/plc4j/pom.xml
+++ b/plc4j/pom.xml
@@ -75,6 +75,10 @@
                 <ignoredDependency>org.apache.groovy:groovy-test-junit5</ignoredDependency>
                 <ignoredDependency>com.athaydes:spock-reports</ignoredDependency>
               </ignoredDependencies>
+              <ignoredUnusedDeclaredDependencies>
+                <!-- Only referenced from the Bundle-Activator manifest header, which the analyzer can't see -->
+                <ignoredUnusedDeclaredDependency>org.apache.plc4x:plc4j-osgi</ignoredUnusedDeclaredDependency>
+              </ignoredUnusedDeclaredDependencies>
             </configuration>
           </execution>
         </executions>
diff --git a/plc4j/transports/api/pom.xml b/plc4j/transports/api/pom.xml
index 32e3af68af..82027a58bc 100644
--- a/plc4j/transports/api/pom.xml
+++ b/plc4j/transports/api/pom.xml
@@ -58,12 +58,6 @@
       <artifactId>slf4j-api</artifactId>
     </dependency>
 
-    <!-- OSGi Dependencies -->
-    <dependency>
-      <groupId>org.osgi</groupId>
-      <artifactId>org.osgi.service.component.annotations</artifactId>
-    </dependency>
-
     <!-- Test Dependencies -->
     <dependency>
       <groupId>org.mockito</groupId>
diff --git a/plc4j/transports/api/src/main/java/org/apache/plc4x/java/spi/transports/api/OsgiTransportManager.java b/plc4j/transports/api/src/main/java/org/apache/plc4x/java/spi/transports/api/OsgiTransportManager.java
deleted file mode 100644
index 07096d59d8..0000000000
--- a/plc4j/transports/api/src/main/java/org/apache/plc4x/java/spi/transports/api/OsgiTransportManager.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.plc4x.java.spi.transports.api;
-
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.osgi.service.component.annotations.ReferencePolicy;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Map;
-import java.util.Optional;
-import java.util.concurrent.ConcurrentHashMap;
-
-@Component(service = TransportManager.class, immediate = true)
-public class OsgiTransportManager implements TransportManager {
-
-    private static final Logger LOGGER = LoggerFactory.getLogger(OsgiTransportManager.class);
-
-    private final Map<String, Transport<?>> transportMap = new ConcurrentHashMap<>();
-
-    @Reference(
-        cardinality = ReferenceCardinality.MULTIPLE,
-        policy = ReferencePolicy.DYNAMIC
-    )
-    protected void bindTransport(Transport<?> transport) {
-        String transportCode = transport.getTransportCode();
-        LOGGER.info("Registering transport {} ({})", transportCode, transport.getTransportName());
-
-        Transport<?> existing = transportMap.putIfAbsent(transportCode, transport);
-        if (existing != null) {
-            LOGGER.warn("Transport with code '{}' is already registered. Ignoring duplicate.", transportCode);
-        }
-    }
-
-    protected void unbindTransport(Transport<?> transport) {
-        String transportCode = transport.getTransportCode();
-        LOGGER.info("Unregistering transport {} ({})", transportCode, transport.getTransportName());
-        transportMap.remove(transportCode);
-    }
-
-    @Override
-    public Optional<Transport> getTransport(String transportCode) {
-        return Optional.ofNullable(transportMap.get(transportCode));
-    }
-
-}
diff --git a/plc4j/transports/api/src/test/java/org/apache/plc4x/java/spi/transports/api/OsgiTransportManagerTest.java b/plc4j/transports/api/src/test/java/org/apache/plc4x/java/spi/transports/api/OsgiTransportManagerTest.java
deleted file mode 100644
index 1dc2fd9660..0000000000
--- a/plc4j/transports/api/src/test/java/org/apache/plc4x/java/spi/transports/api/OsgiTransportManagerTest.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.plc4x.java.spi.transports.api;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
-
-import java.util.Optional;
-
-import static org.junit.jupiter.api.Assertions.*;
-import static org.mockito.Mockito.when;
-
-class OsgiTransportManagerTest {
-
-    private OsgiTransportManager manager;
-    private Transport<?> mockTransport;
-
-    @BeforeEach
-    void setUp() {
-        manager = new OsgiTransportManager();
-        mockTransport = Mockito.mock(Transport.class);
-        when(mockTransport.getTransportCode()).thenReturn("tcp");
-        when(mockTransport.getTransportName()).thenReturn("TCP Transport");
-    }
-
-    @Test
-    void testGetTransport_whenTransportNotRegistered() {
-        Optional<Transport> result = manager.getTransport("tcp");
-        assertFalse(result.isPresent());
-    }
-
-    @Test
-    void testBindTransport_registersTransport() {
-        manager.bindTransport(mockTransport);
-
-        Optional<Transport> result = manager.getTransport("tcp");
-        assertTrue(result.isPresent());
-        assertEquals(mockTransport, result.get());
-    }
-
-    @Test
-    void testBindTransport_duplicateTransportIgnored() {
-        Transport<?> mockTransport2 = Mockito.mock(Transport.class);
-        when(mockTransport2.getTransportCode()).thenReturn("tcp");
-        when(mockTransport2.getTransportName()).thenReturn("TCP Transport 2");
-
-        manager.bindTransport(mockTransport);
-        manager.bindTransport(mockTransport2);
-
-        Optional<Transport> result = manager.getTransport("tcp");
-        assertTrue(result.isPresent());
-        assertEquals(mockTransport, result.get());
-    }
-
-    @Test
-    void testUnbindTransport_removesTransport() {
-        manager.bindTransport(mockTransport);
-
-        Optional<Transport> result = manager.getTransport("tcp");
-        assertTrue(result.isPresent());
-
-        manager.unbindTransport(mockTransport);
-
-        result = manager.getTransport("tcp");
-        assertFalse(result.isPresent());
-    }
-
-    @Test
-    void testBindMultipleTransports() {
-        Transport<?> mockTransport2 = Mockito.mock(Transport.class);
-        when(mockTransport2.getTransportCode()).thenReturn("udp");
-        when(mockTransport2.getTransportName()).thenReturn("UDP Transport");
-
-        manager.bindTransport(mockTransport);
-        manager.bindTransport(mockTransport2);
-
-        Optional<Transport> tcpResult = manager.getTransport("tcp");
-        Optional<Transport> udpResult = manager.getTransport("udp");
-
-        assertTrue(tcpResult.isPresent());
-        assertTrue(udpResult.isPresent());
-        assertEquals(mockTransport, tcpResult.get());
-        assertEquals(mockTransport2, udpResult.get());
-    }
-
-    @Test
-    void testGetTransport_returnsEmptyForUnknownCode() {
-        manager.bindTransport(mockTransport);
-
-        Optional<Transport> result = manager.getTransport("unknown");
-        assertFalse(result.isPresent());
-    }
-}
diff --git a/plc4j/transports/can-socketcan/pom.xml b/plc4j/transports/can-socketcan/pom.xml
index 4c619b1692..17e8936a37 100644
--- a/plc4j/transports/can-socketcan/pom.xml
+++ b/plc4j/transports/can-socketcan/pom.xml
@@ -118,6 +118,13 @@
       <artifactId>slf4j-api</artifactId>
     </dependency>
 
+    <!-- Holds the Bundle-Activator. Compile scope, as the Karaf feature generator only picks up those -->
+    <dependency>
+      <groupId>org.apache.plc4x</groupId>
+      <artifactId>plc4j-osgi</artifactId>
+      <version>1.1.0-SNAPSHOT</version>
+    </dependency>
+
     <!-- Test Dependencies -->
     <dependency>
       <groupId>ch.qos.logback</groupId>
diff --git a/plc4j/transports/can-virtualcan/pom.xml b/plc4j/transports/can-virtualcan/pom.xml
index 94d8113ffc..d534c41633 100644
--- a/plc4j/transports/can-virtualcan/pom.xml
+++ b/plc4j/transports/can-virtualcan/pom.xml
@@ -66,6 +66,13 @@
       <artifactId>slf4j-api</artifactId>
     </dependency>
 
+    <!-- Holds the Bundle-Activator. Compile scope, as the Karaf feature generator only picks up those -->
+    <dependency>
+      <groupId>org.apache.plc4x</groupId>
+      <artifactId>plc4j-osgi</artifactId>
+      <version>1.1.0-SNAPSHOT</version>
+    </dependency>
+
     <!-- Test Dependencies -->
     <dependency>
       <groupId>ch.qos.logback</groupId>
diff --git a/plc4j/transports/cotp/pom.xml b/plc4j/transports/cotp/pom.xml
index 6d7f2de36d..bd8ded28bb 100644
--- a/plc4j/transports/cotp/pom.xml
+++ b/plc4j/transports/cotp/pom.xml
@@ -86,6 +86,13 @@
       <artifactId>slf4j-api</artifactId>
     </dependency>
 
+    <!-- Holds the Bundle-Activator. Compile scope, as the Karaf feature generator only picks up those -->
+    <dependency>
+      <groupId>org.apache.plc4x</groupId>
+      <artifactId>plc4j-osgi</artifactId>
+      <version>1.1.0-SNAPSHOT</version>
+    </dependency>
+
     <!-- Test Dependencies -->
     <dependency>
       <groupId>ch.qos.logback</groupId>
diff --git a/plc4j/transports/pcap-replay/pom.xml b/plc4j/transports/pcap-replay/pom.xml
index 72b1d75cc8..b6f429345d 100644
--- a/plc4j/transports/pcap-replay/pom.xml
+++ b/plc4j/transports/pcap-replay/pom.xml
@@ -132,6 +132,13 @@
       <artifactId>pcap4j-packetfactory-static</artifactId>
     </dependency>
 
+    <!-- Holds the Bundle-Activator. Compile scope, as the Karaf feature generator only picks up those -->
+    <dependency>
+      <groupId>org.apache.plc4x</groupId>
+      <artifactId>plc4j-osgi</artifactId>
+      <version>1.1.0-SNAPSHOT</version>
+    </dependency>
+
     <!-- Test Dependencies -->
     <dependency>
       <groupId>org.apache.plc4x</groupId>
diff --git a/plc4j/transports/raw-socket/pom.xml b/plc4j/transports/raw-socket/pom.xml
index 66aea8d692..996da1fe6f 100644
--- a/plc4j/transports/raw-socket/pom.xml
+++ b/plc4j/transports/raw-socket/pom.xml
@@ -118,6 +118,13 @@
       <artifactId>pcap4j-core</artifactId>
     </dependency>
 
+    <!-- Holds the Bundle-Activator. Compile scope, as the Karaf feature generator only picks up those -->
+    <dependency>
+      <groupId>org.apache.plc4x</groupId>
+      <artifactId>plc4j-osgi</artifactId>
+      <version>1.1.0-SNAPSHOT</version>
+    </dependency>
+
     <!-- Test Dependencies -->
     <dependency>
       <groupId>org.apache.plc4x</groupId>
diff --git a/plc4j/transports/serial/pom.xml b/plc4j/transports/serial/pom.xml
index 63495a3119..99e2ba5559 100644
--- a/plc4j/transports/serial/pom.xml
+++ b/plc4j/transports/serial/pom.xml
@@ -118,6 +118,13 @@
       <artifactId>jSerialComm</artifactId>
     </dependency>
 
+    <!-- Holds the Bundle-Activator. Compile scope, as the Karaf feature generator only picks up those -->
+    <dependency>
+      <groupId>org.apache.plc4x</groupId>
+      <artifactId>plc4j-osgi</artifactId>
+      <version>1.1.0-SNAPSHOT</version>
+    </dependency>
+
     <!-- Test Dependencies -->
     <dependency>
       <groupId>ch.qos.logback</groupId>
diff --git a/plc4j/transports/tcp/pom.xml b/plc4j/transports/tcp/pom.xml
index b4d80142ca..775196063f 100644
--- a/plc4j/transports/tcp/pom.xml
+++ b/plc4j/transports/tcp/pom.xml
@@ -68,6 +68,13 @@
       <artifactId>slf4j-api</artifactId>
     </dependency>
 
+    <!-- Holds the Bundle-Activator. Compile scope, as the Karaf feature generator only picks up those -->
+    <dependency>
+      <groupId>org.apache.plc4x</groupId>
+      <artifactId>plc4j-osgi</artifactId>
+      <version>1.1.0-SNAPSHOT</version>
+    </dependency>
+
     <!-- Test Dependencies -->
     <dependency>
       <groupId>ch.qos.logback</groupId>
diff --git a/plc4j/transports/test/pom.xml b/plc4j/transports/test/pom.xml
index 2a98373450..53e94f186a 100644
--- a/plc4j/transports/test/pom.xml
+++ b/plc4j/transports/test/pom.xml
@@ -61,6 +61,13 @@
       <artifactId>slf4j-api</artifactId>
     </dependency>
 
+    <!-- Holds the Bundle-Activator. Compile scope, as the Karaf feature generator only picks up those -->
+    <dependency>
+      <groupId>org.apache.plc4x</groupId>
+      <artifactId>plc4j-osgi</artifactId>
+      <version>1.1.0-SNAPSHOT</version>
+    </dependency>
+
     <!-- Test Dependencies -->
     <dependency>
       <groupId>ch.qos.logback</groupId>
diff --git a/plc4j/transports/tls/pom.xml b/plc4j/transports/tls/pom.xml
index 258b912158..d405613ca2 100644
--- a/plc4j/transports/tls/pom.xml
+++ b/plc4j/transports/tls/pom.xml
@@ -80,6 +80,13 @@
       <artifactId>slf4j-api</artifactId>
     </dependency>
 
+    <!-- Holds the Bundle-Activator. Compile scope, as the Karaf feature generator only picks up those -->
+    <dependency>
+      <groupId>org.apache.plc4x</groupId>
+      <artifactId>plc4j-osgi</artifactId>
+      <version>1.1.0-SNAPSHOT</version>
+    </dependency>
+
     <!-- Test Dependencies -->
     <dependency>
       <groupId>ch.qos.logback</groupId>
diff --git a/plc4j/transports/udp/pom.xml b/plc4j/transports/udp/pom.xml
index 193153d28c..5677657b0c 100644
--- a/plc4j/transports/udp/pom.xml
+++ b/plc4j/transports/udp/pom.xml
@@ -62,6 +62,13 @@
       <artifactId>slf4j-api</artifactId>
     </dependency>
 
+    <!-- Holds the Bundle-Activator. Compile scope, as the Karaf feature generator only picks up those -->
+    <dependency>
+      <groupId>org.apache.plc4x</groupId>
+      <artifactId>plc4j-osgi</artifactId>
+      <version>1.1.0-SNAPSHOT</version>
+    </dependency>
+
     <!-- Test Dependencies -->
     <dependency>
       <groupId>ch.qos.logback</groupId>
diff --git a/pom.xml b/pom.xml
index 7ca245d061..ea3d4207ad 100644
--- a/pom.xml
+++ b/pom.xml
@@ -166,6 +166,8 @@
     <jsoup.version>1.22.2</jsoup.version>
     <jssc.version>2.10.4</jssc.version>
     <junit.jupiter.version>6.1.3</junit.jupiter.version>
+    <!-- Karaf the generated driver features are verified against, and the karaf-maven-plugin version -->
+    <karaf.version>4.4.12</karaf.version>
     <logback.version>1.6.5</logback.version>
     <maven-artifact.version>3.10.0</maven-artifact.version>
     <maven-dependency-tree.version>3.3.0</maven-dependency-tree.version>
@@ -450,11 +452,6 @@
         <artifactId>osgi.core</artifactId>
         <version>8.0.0</version>
       </dependency>
-      <dependency>
-        <groupId>org.osgi</groupId>
-        <artifactId>org.osgi.service.component.annotations</artifactId>
-        <version>1.5.1</version>
-      </dependency>
       <!-- The framework Karaf 4.4 runs on, used to test the OSGi activators against a real service registry -->
       <dependency>
         <groupId>org.apache.felix</groupId>
@@ -1141,7 +1138,46 @@
         <plugin>
           <groupId>org.apache.karaf.tooling</groupId>
           <artifactId>karaf-maven-plugin</artifactId>
-          <version>4.4.12</version>
+          <version>${karaf.version}</version>
+          <executions>
+            <!-- Not at compile time: the feature contains the module's own jar, which needs to exist first -->
+            <execution>
+              <id>verify-feature-xml</id>
+              <phase>verify</phase>
+              <goals>
+                <goal>verify</goal>
+              </goals>
+            </execution>
+          </executions>
+          <configuration>
+            <!-- Without this the feature holds only the dependencies, not the driver bundle itself -->
+            <includeProjectArtifact>true</includeProjectArtifact>
+            <!--
+              Karaf's pax-logging already exports org.slf4j. The plain slf4j-api bundle would
+              additionally require SPI Fly and a separate SLF4J provider bundle to resolve.
+            -->
+            <excludedArtifactIds>
+              <excludedArtifactId>slf4j-api</excludedArtifactId>
+            </excludedArtifactIds>
+            <!--
+              Used by the verify goal: resolve the module's own feature in a simulated Karaf. Without
+              explicit descriptors the goal has nothing to check and passes no matter what.
+            -->
+            <karafVersion>${karaf.version}</karafVersion>
+            <distribution>org.apache.karaf.features:framework:kar</distribution>
+            <distDir>resources</distDir>
+            <javase>${java.version}</javase>
+            <framework>
+              <feature>framework</feature>
+            </framework>
+            <descriptors>
+              <descriptor>mvn:org.apache.karaf.features/standard/${karaf.version}/xml/features</descriptor>
+              <descriptor>file:${project.build.directory}/feature/feature.xml</descriptor>
+            </descriptors>
+            <features>
+              <feature>${project.artifactId}</feature>
+            </features>
+          </configuration>
         </plugin>
 
         <plugin>