You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by to...@quarendon.net on 2017/09/07 08:06:19 UTC

Creating a karaf feature containing a karaf shell command breaks karaf

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:
...
mvn:org.apache.karaf.shell/org.apache.karaf.shell.console/4.1.2
null <-- This is clearly bad
mvn:org.apache.karaf.shell/org.apache.karaf.shell.ssh/4.1.2
...

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) [10:org.apache.karaf.features.core:4.1.2]
	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) [10:org.apache.karaf.features.core:4.1.2]
	at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$0(FeaturesServiceImpl.java:1132) [10:org.apache.karaf.features.core:4.1.2]
	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.
Thanks.

Re: Creating a karaf feature containing a karaf shell command breaks karaf

Posted by to...@quarendon.net.
So although moving 
<feature>eventadmin</feature>
out of startupFeatures makes the command work, it seems to break a bunch of other things, so doesn't seem wise afterall. E.g, I get things like the following that only seem to happen if I've moved that line:

Bundle org.ops4j.pax.web.pax-web-extender-whiteboard [115] Error starting mvn:org.ops4j.pax.web/pax-web-extender-whiteboard/6.0.6 (org.osgi.framework.BundleException: Activator start error in bundle org.ops4j.pax.web.pax-web-extender-whiteboard [115].)
org.osgi.framework.BundleException: Activator start error in bundle org.ops4j.pax.web.pax-web-extender-whiteboard [115].
	at org.apache.felix.framework.Felix.activateBundle(Felix.java:2289) [?:?]
	at org.apache.felix.framework.Felix.startBundle(Felix.java:2145) [?:?]
	at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1372) [?:?]
	at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308) [?:?]
	at java.lang.Thread.run(Thread.java:745) [?:?]
Caused by: java.lang.IllegalStateException: HttpService must be implementing Pax-Web WebContainer!
	at org.ops4j.pax.web.extender.whiteboard.internal.ExtendedHttpServiceRuntime.serviceChanged(ExtendedHttpServiceRuntime.java:110) ~[?:?]
	at org.ops4j.pax.web.extender.whiteboard.internal.ExtendedHttpServiceRuntime.serviceChanged(ExtendedHttpServiceRuntime.java:44) ~[?:?]
	at org.ops4j.pax.web.extender.whiteboard.internal.util.tracker.ReplaceableService.bind(ReplaceableService.java:86) ~[?:?]
	at org.ops4j.pax.web.extender.whiteboard.internal.util.tracker.ReplaceableService$Customizer.addingService(ReplaceableService.java:105) ~[?:?]
	at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:941) ~[?:?]
	at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:870) ~[?:?]
	at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) ~[?:?]
	at org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:183) ~[?:?]
	at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:318) ~[?:?]
	at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:261) ~[?:?]
	at org.ops4j.pax.web.extender.whiteboard.internal.util.tracker.ReplaceableService.start(ReplaceableService.java:72) ~[?:?]
	at org.ops4j.pax.web.extender.whiteboard.internal.ExtendedHttpServiceRuntime.start(ExtendedHttpServiceRuntime.java:153) ~[?:?]
	at org.ops4j.pax.web.extender.whiteboard.internal.Activator.start(Activator.java:65) ~[?:?]
	at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:697) ~[?:?]
	at org.apache.felix.framework.Felix.activateBundle(Felix.java:2239) ~[?:?]
	... 4 more

Re: Creating a karaf feature containing a karaf shell command breaks karaf

Posted by to...@quarendon.net.
> Thanks, I'm checking out and I will take a look (and eventually submit a PR ;)).
OK, thanks.

Re: Creating a karaf feature containing a karaf shell command breaks karaf

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Thanks, I'm checking out and I will take a look (and eventually submit a PR ;)).

Regards
JB

On 09/07/2017 10:22 AM, tom@quarendon.net wrote:
> There's a complete example here:
> https://github.com/tomq42/karaf-command-feature
> 
> Thanks.
> 
>> On 07 September 2017 at 09:15 Jean-Baptiste Onofré <jb...@nanthrax.net> wrote:
>>
>>
>> Hi Tom,
>>
>> can you share the pom.xml you use to create your custom distro ?
>>
>> It looks like some resources are missing in the distro.
>>
>> Regards
>> JB
>>
>> On 09/07/2017 10:06 AM, tom@quarendon.net wrote:
>>> 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:
>>> ...
>>> mvn:org.apache.karaf.shell/org.apache.karaf.shell.console/4.1.2
>>> null <-- This is clearly bad
>>> mvn:org.apache.karaf.shell/org.apache.karaf.shell.ssh/4.1.2
>>> ...
>>>
>>> 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) [10:org.apache.karaf.features.core:4.1.2]
>>> 	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) [10:org.apache.karaf.features.core:4.1.2]
>>> 	at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$0(FeaturesServiceImpl.java:1132) [10:org.apache.karaf.features.core:4.1.2]
>>> 	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.
>>> Thanks.
>>>
>>
>> -- 
>> Jean-Baptiste Onofré
>> jbonofre@apache.org
>> http://blog.nanthrax.net
>> Talend - http://www.talend.com

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Creating a karaf feature containing a karaf shell command breaks karaf

Posted by to...@quarendon.net.
There's a complete example here:
https://github.com/tomq42/karaf-command-feature

Thanks.

> On 07 September 2017 at 09:15 Jean-Baptiste Onofré <jb...@nanthrax.net> wrote:
> 
> 
> Hi Tom,
> 
> can you share the pom.xml you use to create your custom distro ?
> 
> It looks like some resources are missing in the distro.
> 
> Regards
> JB
> 
> On 09/07/2017 10:06 AM, tom@quarendon.net wrote:
> > 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:
> > ...
> > mvn:org.apache.karaf.shell/org.apache.karaf.shell.console/4.1.2
> > null <-- This is clearly bad
> > mvn:org.apache.karaf.shell/org.apache.karaf.shell.ssh/4.1.2
> > ...
> > 
> > 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) [10:org.apache.karaf.features.core:4.1.2]
> > 	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) [10:org.apache.karaf.features.core:4.1.2]
> > 	at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$0(FeaturesServiceImpl.java:1132) [10:org.apache.karaf.features.core:4.1.2]
> > 	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.
> > Thanks.
> > 
> 
> -- 
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com

Re: Creating a karaf feature containing a karaf shell command breaks karaf

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Tom,

can you share the pom.xml you use to create your custom distro ?

It looks like some resources are missing in the distro.

Regards
JB

On 09/07/2017 10:06 AM, tom@quarendon.net wrote:
> 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:
> ...
> mvn:org.apache.karaf.shell/org.apache.karaf.shell.console/4.1.2
> null <-- This is clearly bad
> mvn:org.apache.karaf.shell/org.apache.karaf.shell.ssh/4.1.2
> ...
> 
> 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) [10:org.apache.karaf.features.core:4.1.2]
> 	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) [10:org.apache.karaf.features.core:4.1.2]
> 	at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$0(FeaturesServiceImpl.java:1132) [10:org.apache.karaf.features.core:4.1.2]
> 	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.
> Thanks.
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com