Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
scr ant task 1.6.0
-
None
Description
The SCR ant task throws a NoClassDefFoundError:
BUILD FAILED
[...]/build.xml:13: java.lang.NoClassDefFoundError: org/osgi/service/component/annotations/Component
at org.apache.felix.scrplugin.ds.DSAnnotationProcessor.process(DSAnnotationProcessor.java:69)
at [...]
This even happens with a minimal project consisting of a single empty component class:
import org.apache.felix.scr.annotations.Component;
@Component
public class C { }
The easiest workaround is to add org.osgi.compendium-4.3.1.jar to the taskdef classpath:
<taskdef resource="scrtask.properties" classpath="org.apache.felix.scr.ant-1.6.0.jar;${user.home}/.m2/repository/org/osgi/org.osgi.compendium/4.3.1/org.osgi.compendium-4.3.1.jar" />
If it's supposed to work like this please update the docs at https://cwiki.apache.org/FELIX/apache-felix-scr-ant-task-use.html
If not please embed missing dependencies into the ant task jar file. For the above minimal project it's enough to add org/osgi/service/component/annotations/Component.class and org/osgi/service/component/ComponentContext.class from org.osgi.compendium-4.3.1.jar, but I don't know if this is sufficient in all cases.