Platform: Java 1.8, karaf 4.1.3
I have the following DS component that exposes a Servlet to the Pax Web
Whiteboard Extender:
https://github.com/steinarb/sonar-collector/blob/master/sonar-collector-webhook/src/main/java/no/priv/bang/sonar/collector/webhook/SonarCollectorServlet.java#L55
The component starts fine, and exposes a Servlet service that is picked
up by the whiteboard extender, and as far as I can tell, it does what it
is expected to do (receive POSTs from SonarQube/SonarCloud and store
build statistics in a PostgreSQL database).
However, if I add an empty activate method, like so:
@Component(service={Servlet.class}, property={"alias=/sonar-collector"} )
public class SonarCollectorServlet extends HttpServlet {
...
@Activate
public void activate(Map<String, Object> config) {
}
...
}
then the component fails to load, because of missing dependencies:
karaf@root()> feature:repo-add
mvn:no.priv.bang.sonar.sonar-collector/sonar-collector-webhook/LATEST/xml/features
Adding feature url
mvn:no.priv.bang.sonar.sonar-collector/sonar-collector-webhook/LATEST/xml/features
karaf@root()> feature:install sonar-collector-webhook
Error executing command: Unable to resolve root: missing requirement [root]
osgi.identity; osgi.identity=sonar-collector-webhook; type=karaf.feature;
version="[1.0.0.SNAPSHOT,1.0.0.SNAPSHOT]";
filter:="(&(osgi.identity=sonar-collector-webhook)(type=karaf.feature)(version>=1.0.0.SNAPSHOT)(version<=1.0.0.SNAPSHOT))"
[caused by: Unable to resolve sonar-collector-webhook/1.0.0.SNAPSHOT: missing
requirement [sonar-collector-webhook/1.0.0.SNAPSHOT] osgi.identity;
osgi.identity=no.priv.bang.sonar.sonar-collector-webhook; type=osgi.bundle;
version="[1.0.0.SNAPSHOT,1.0.0.SNAPSHOT]"; resolution:=mandatory [caused by:
Unable to resolve no.priv.bang.sonar.sonar-collector-webhook/1.0.0.SNAPSHOT:
missing requirement [no.priv.bang.sonar.sonar-collector-webhook/1.0.0.SNAPSHOT]
osgi.service; effective:=active;
filter:="(objectClass=org.osgi.service.jdbc.DataSourceFactory)"]]
karaf@root()>
If remove the "@Activate" annotation, the component loads again.
Does anyone know what might cause this?
The full error message from karaf.log below.
Thanks!
- Steinar
Error message from karaf.log follows:
2017-12-04T20:28:57,555 | ERROR | Karaf local console user karaf | ShellUtil
| 42 - org.apache.karaf.shell.core - 4.1.3 | Exception
caught while executing command
org.osgi.service.resolver.ResolutionException: Unable to resolve root: missing
requirement [root] osgi.identity; osgi.identity=sonar-collector-webhook;
type=karaf.feature; version="[1.0.0.SNAPSHOT,1.0.0.SNAPSHOT]";
filter:="(&(osgi.identity=sonar-collector-webhook)(type=karaf.feature)(version>=1.0.0.SNAPSHOT)(version<=1.0.0.SNAPSHOT))"
[caused by: Unable to resolve sonar-collector-webhook/1.0.0.SNAPSHOT: missing
requirement [sonar-collector-webhook/1.0.0.SNAPSHOT] osgi.identity;
osgi.identity=no.priv.bang.sonar.sonar-collector-webhook; type=osgi.bundle;
version="[1.0.0.SNAPSHOT,1.0.0.SNAPSHOT]"; resolution:=mandatory [caused by:
Unable to resolve no.priv.bang.sonar.sonar-collector-webhook/1.0.0.SNAPSHOT:
missing requirement [no.priv.bang.sonar.sonar-collector-webhook/1.0.0.SNAPSHOT]
osgi.service; effective:=active;
filter:="(objectClass=org.osgi.service.jdbc.DataSourceFactory)"]]
at
org.apache.felix.resolver.ResolutionError.toException(ResolutionError.java:42)
~[?:?]
at
org.apache.felix.resolver.ResolverImpl.doResolve(ResolverImpl.java:391) ~[?:?]
at
org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:377) ~[?:?]
at
org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:349) ~[?:?]
at
org.apache.karaf.features.internal.region.SubsystemResolver.resolve(SubsystemResolver.java:218)
~[?:?]
at
org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:291)
~[?:?]
at
org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1248)
~[?:?]
at
org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$1(FeaturesServiceImpl.java:1147)
~[?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[?:?]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[?:?]
at java.lang.Thread.run(Thread.java:748) [?:?]