Search code examples
osgi

Non annotation argument to lifecycle method with descriptor


I am adding Maven build capability to an existing OSGI 7 project. It builds just fine with bnd within Eclipse, and with Gradle. But I am getting the following error when building with Maven:

[ERROR] /Users/randy/projects/xyz/src/com.xyz.masterdata/com.xyz.masterdata.core.logic.provider/bnd.bnd [0:0]: Non annotation argument to lifecycle method with descriptor (Lorg/osgi/service/transaction/control/TransactionControl;Lorg/osgi/service/transaction/control/jdbc/JDBCConnectionProvider;)V,  type org/osgi/service/transaction/control/TransactionControl
[ERROR] /Users/randy/projects/xyz/src/com.xyz.masterdata/com.xyz.masterdata.core.logic.provider/bnd.bnd [0:0]: Non annotation argument to lifecycle method with descriptor (Lorg/osgi/service/transaction/control/TransactionControl;Lorg/osgi/service/transaction/control/jdbc/JDBCConnectionProvider;)V,  type org/osgi/service/transaction/control/jdbc/JDBCConnectionProvider

The offending code is as follows, specifically the constructor method with the @Activate annotation:

@Component(property = {
                "provider.target=(databaseName=MasterData)"
        })
public class ConsumerChannelDaoImpl implements ConsumerChannelDao
{
    private final TransactionControl _transactionControl;
    private Connection _connection;

    @Activate
    public ConsumerChannelDaoImpl(@Reference TransactionControl txControl, @Reference(name = "provider") JDBCConnectionProvider provider)
    {
        _transactionControl = txControl;
        _connection = provider.getResource(txControl);
    }

My pom.xml has the following dependencies:

<dependencies>
    <dependency>
        <groupId>org.osgi</groupId>
        <artifactId>osgi.annotation</artifactId>
        <version>7.0.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.osgi</groupId>
        <artifactId>osgi.core</artifactId>
        <version>7.0.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.osgi</groupId>
        <artifactId>osgi.cmpn</artifactId>
        <version>7.0.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.osgi</groupId>
        <artifactId>org.osgi.service.http.whiteboard</artifactId>
        <version>1.1.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.osgi</groupId>
        <artifactId>org.osgi.service.jaxrs</artifactId>
        <version>1.0.0</version>
    </dependency>
    <dependency>
        <groupId>org.osgi</groupId>
        <artifactId>org.osgi.service.jdbc</artifactId>
        <version>1.0.0</version>
        <scope>provided</scope>
    </dependency>
    ....
</dependencies>

I'm at a loss as to what is causing this issue. Some thoughts on how to resolve when building an OSGi 7 project with Maven is appreciated.

Thanks, Randy


Solution

  • BJ Hargrave had pointed out I was using an older version of bnd-maven-plugin. Updating to v4.3.1 did the trick.

            <plugin>
                <groupId>biz.aQute.bnd</groupId>
                <artifactId>bnd-maven-plugin</artifactId>
                <version>4.3.1</version>
                <executions>
                    <execution>
                        <id>default-bnd-process</id>
                        <goals>
                            <goal>bnd-process</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>