karaf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@quarendon.net
Subject Creating a karaf feature containing a karaf shell command breaks karaf
Date Thu, 07 Sep 2017 08:06:19 GMT
Clearly this can't be true, since karaf ships with features containing bundles containing commands,
but I can't get it to work.

I've created a simple karaf shell command, following the tutorial in the documentation. As
per the example, it just says "hello world".
If I build that as an isolated bundle, install it into karaf and run it, it works, as per
the documentation.

What I'm trying to do though is build that into a feature to include into a custom karaf distribution.

I can build the feature, and I can manually install the feature into a karaf distribution,
and it works OK, I can run the resulting command. 
I can build the karaf distribution containing the feature OK, but when I then run the resulting
karaf then fails to initialise properly.

In the log file, I get:
Adding features: 
Changes to perform:
Region: root
Bundles to install:
null <-- This is clearly bad

Installing bundles:
null <-- This is the same null as before and causes the problem below.
Error installing boot features
java.lang.IllegalStateException: Resource has no uri
	at org.apache.karaf.features.internal.service.Deployer.getBundleInputStream(Deployer.java:1460)
	at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:766) [10:org.apache.karaf.features.core:4.1.2]
	at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1233)
	at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$0(FeaturesServiceImpl.java:1132)
	at org.apache.karaf.features.internal.service.FeaturesServiceImpl$$Lambda$15/951619949.call(Unknown
Source) [10:org.apache.karaf.features.core:4.1.2]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:?]

The console then goes funny, and you get: 
Error in initialization script: etc\shell.init.script: String index out of range: 0
which I'm assuming is a knockon issue.

I've got no idea where this "null" bundle is coming from, but it's clearly causing the karaf
initialisation to go wrong.

I have created an example project at https://github.com/tomq42/karaf-command-feature which
I hope shows the problem.
Just build with maven, then run the karaf-distro\target\assembly\bin\karaf(.bat) command.
You should see the error above on the console, and the error in the log.

Any insight would be very welcome.

View raw message