Apache
Home » Documentation » FAQs

Apache Felix SCR Plugin Frequently Asked Questions

This page provides answers to frequently asked questions using the Maven SCR Plugin. See Apache Felix Maven SCR Plugin for documentation on that plugin.

Syntax Error when Enums are used?

During a SCR plugin run, a syntax error might occur if enums are used in the source code. This is a know problem of the used QDox version that reads the Java source files. Usually this happens when an enum is used inline and does not end with a ";". So adding this character should solve the problem:

public interface MyTest {

    /** more error codes may be added */
    enum Result {
        OK, UNKNOWN, ERROR, DENIED
    };     // <!-- HERE

    /** @return the result */
    public void getResult(); 
}

NoClassDefFoundError during build

This error might happen with older versions of the Maven SCR Plugins in combination with javadoc tags or newer versions in combination with the annotations. In both cases, the scanned classes have to be loaded and static fields have to be initialized. If you have have for example something like

private static final org.slf4f.Logger LOGGER = org.slf4j.LoggerFactory.getLogger("name");

in your code, during the plugin run, a slf4j logger is tried to be instantiated. This requires an implementation of the logger. Ususally your module only depends on the slf4j API and therefore a

java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder

is thrown - this often happens with slf4j but might also happen with other libraries.

In these cases you should add a dependency to the missing class to the dependency list of the plugin, for example:

<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-scr-plugin</artifactId>
    <version>1.9.0</version>
    <dependencies>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.5.2</version>
        </dependency>
    </dependencies>
    ...
</plugin>

or in the special case of slf4j, using slf4j API 1.6 or higher solves the problem as well

Rev. 1482228 by cziegeler on Tue, 14 May 2013 06:48:44 +0000
Apache Felix, Felix, Apache, the Apache feather logo, and the Apache Felix project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.