You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Elliot Metsger <em...@gmail.com> on 2016/04/04 16:15:26 UTC

feature:repo-add -i broken in 4.0.4?

Hi everyone,

I'm trying use the '-i' (--install) option of `feature:repo-add`, and it
isn't working:

karaf@root()> feature:repo-add -i
mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
Adding feature url mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
Error executing command: java.lang.UnsupportedOperationException
karaf@root()>


The feature repo installs just fine on its own, without -i:
karaf@root()> feature:repo-add
mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
Adding feature url mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
karaf@root()>

This feature repository is available on Maven central if you care to
replicate the problem.

Is there something wrong with the feature file that is causing this error,
or is this a bug in Karaf?

Thanks,
Elliot

Re: Scripting installation of features - Command not found: feature:repo-add (was Re: feature:repo-add -i broken in 4.0.4?)

Posted by Benson Margulies <be...@basistech.com>.
Have you considered just making a karaf assembly?

On Oct 8, 2016 11:22 AM, "emetsger@gmail.com" <em...@gmail.com> wrote:

> Hi Guillaume,
>
> After digging a bit more, the apparent disparity between the client and the
> interactive console seems to be related to timing:
>
> bin/start && \
> bin/client -r 10 -d 5  "feature:repo-add -i
> mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features" && \
> sleep 20 && \
> bin/stop
>
> Adding a `sleep` before stopping the console allows the bundles to be
> started!  I assumed that `feature:repo-add -i` was blocking until
> everything
> was installed, but I was mistaken?  Or maybe calling bin/stop so quickly
> aborts the preservation of the bundle state?
>
> In any case, adding the sleep is allowing everything to come up nicely.
>
> Thanks,
> Elliot
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.
> com/feature-repo-add-i-broken-in-4-0-4-tp4046143p4048280.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>

Re: Scripting installation of features - Command not found: feature:repo-add (was Re: feature:repo-add -i broken in 4.0.4?)

Posted by "emetsger@gmail.com" <em...@gmail.com>.
Hi Guillaume,

After digging a bit more, the apparent disparity between the client and the
interactive console seems to be related to timing:

bin/start && \
bin/client -r 10 -d 5  "feature:repo-add -i
mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features" && \
sleep 20 && \
bin/stop

Adding a `sleep` before stopping the console allows the bundles to be
started!  I assumed that `feature:repo-add -i` was blocking until everything
was installed, but I was mistaken?  Or maybe calling bin/stop so quickly
aborts the preservation of the bundle state?

In any case, adding the sleep is allowing everything to come up nicely.

Thanks,
Elliot



--
View this message in context: http://karaf.922171.n3.nabble.com/feature-repo-add-i-broken-in-4-0-4-tp4046143p4048280.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Scripting installation of features - Command not found: feature:repo-add (was Re: feature:repo-add -i broken in 4.0.4?)

Posted by "emetsger@gmail.com" <em...@gmail.com>.
Hi Guillaume,


Thanks for the reply!  I'll look forward to 4.0.8.  However, I have found
some additional behavior regarding `feature:repo-add -i` documented below,
showing that the command behaves differently when executed from the Karaf
client (bin/client) vs the interactive console.


Guillaume Nodet-2 wrote
> The commands may not be available yet when the script is started.
> I think this should be fixed in 4.0.8.

I attempted a work around: 
1) Start Karaf
2) Use the client to connect and install the features

For example:

bin/start && \
bin/client -r 10 -d 5  "feature:repo-add -i
mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features" && \
bin/stop

However, there does not seem to be parity between `feature:repo-add -i` when
executed from the Karaf client, vs execution from the interactive Karaf
console.

When `feature:repo-add -i` is executed by the client in a non-interactive
fashion (per my example above), features will be in the 'STARTED' state, but
their bundles will be in the 'INSTALLED' state (https://goo.gl/7mnYxG).

When `feature:repo-add -i` is executed from the interactive Karaf console,
features will be in the 'STARTED' state, AND the bundles will be in the
'ACTIVE' state (https://goo.gl/S87ThA).

I wanted to bring this to your attention in case it can be addressed for
4.0.8.

Best,
Elliot






--
View this message in context: http://karaf.922171.n3.nabble.com/feature-repo-add-i-broken-in-4-0-4-tp4046143p4048279.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Scripting installation of features - Command not found: feature:repo-add (was Re: feature:repo-add -i broken in 4.0.4?)

Posted by Guillaume Nodet <gn...@apache.org>.
The commands may not be available yet when the script is started.
I think this should be fixed in 4.0.8.

In the main time, you can try with the following script:

loadclass = {
  (($.context bundle 0) loadClass $1)
}
dosleep = {
  longClass = (((loadclass java.lang.Long) getField "TYPE") get null)
  threadClass = (loadclass java.lang.Thread)
  sleepMethod = ($threadClass getMethod "sleep" $longClass)
  $sleepMethod invoke null $1
}
not = { if $1 { false  } { true  } }
wait-for-command = {
  while  { not { $.commands contains $1 } } {
    dosleep 50
  }
}
// this first sleep is needed in order to ensure that the if and while
command are available
dosleep 500
wait-for-command "feature:repo-add"
feature:repo-add -i mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features


Cheers,
Guillaume

2016-09-26 22:37 GMT+02:00 emetsger@gmail.com <em...@gmail.com>:

> Hi,
>
> I've upgraded to Karaf 4.0.6, and I'm attempting to script the installation
> of all features in a features repository, without having to enumerate each
> feature.
>
> With the return of the '-i' argument to feature:repo-add, I've added the
> following line to 'etc/shell.init.script':
> feature:repo-add -i mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
>
> After adding that line, I start the Karaf console and receive the following
> error:
> "Error in initialization script: Command not found: feature:repo-add"
>
> The command works when I copy and paste it into the Karaf console, but does
> not work when appended to to 'etc/shell.init.script'.  Do I mis-understand
> the purpose or syntax of 'etc/shell.init.script', or is this a bug in
> Karaf?
>
> Thanks again,
> Elliot
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.
> com/feature-repo-add-i-broken-in-4-0-4-tp4046143p4048173.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>



-- 
------------------------
Guillaume Nodet
------------------------
Red Hat, Open Source Integration

Email: gnodet@redhat.com
Web: http://fusesource.com
Blog: http://gnodet.blogspot.com/

Scripting installation of features - Command not found: feature:repo-add (was Re: feature:repo-add -i broken in 4.0.4?)

Posted by "emetsger@gmail.com" <em...@gmail.com>.
Hi,

I've upgraded to Karaf 4.0.6, and I'm attempting to script the installation
of all features in a features repository, without having to enumerate each
feature.  

With the return of the '-i' argument to feature:repo-add, I've added the
following line to 'etc/shell.init.script':
feature:repo-add -i mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features

After adding that line, I start the Karaf console and receive the following
error:
"Error in initialization script: Command not found: feature:repo-add"

The command works when I copy and paste it into the Karaf console, but does
not work when appended to to 'etc/shell.init.script'.  Do I mis-understand
the purpose or syntax of 'etc/shell.init.script', or is this a bug in Karaf?

Thanks again,
Elliot




--
View this message in context: http://karaf.922171.n3.nabble.com/feature-repo-add-i-broken-in-4-0-4-tp4046143p4048173.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: feature:repo-add -i broken in 4.0.4?

Posted by Elliot Metsger <em...@gmail.com>.
Many thanks for the pointers!

Best,
Elliot

On Mon, Apr 4, 2016 at 11:36 AM, Jean-Baptiste Onofré <jb...@nanthrax.net>
wrote:

> You can create a script (in etc/shell.init.script), that list all features
> in a repo (feature:list with grep on the repo), and then install the
> features with feature:install.
>
> You can take a look on
> http://karaf.apache.org/manual/latest/developers-guide/scripting.html for
> details about scripting.
>
> Regards
> JB
>
> On 04/04/2016 05:32 PM, Elliot Metsger wrote:
>
>> Thank you Jean-Baptiste, for looking into this.  I'll look forward to
>> 4.0.6.
>>
>> In the interim, is there a workaround for telling Karaf to "install all
>> of the features in a features repository"?
>>
>> Thanks,
>> Elliot
>>
>> On Mon, Apr 4, 2016 at 10:57 AM, Jean-Baptiste Onofré <jb@nanthrax.net
>> <ma...@nanthrax.net>> wrote:
>>
>>     Yes, it could be considered as a regression as it works before but
>>     no more in Karaf 4.x:
>>
>>          public void addRepository(URI uri, boolean install) throws
>>     Exception {
>>              if (install) {
>>                  // TODO: implement
>>                  throw new UnsupportedOperationException();
>>              }
>>     ...
>>
>>     The same happens for removeRepository where the uninstall flag is
>>     simply ignored.
>>
>>     Due to the introduction of the Features resolver in Karaf 4, we
>>     changed the implementation of these methods.
>>
>>     I will re-introduce support of these flags in 4.0.6:
>>
>>     https://issues.apache.org/jira/browse/KARAF-4468
>>
>>     Sorry about that.
>>
>>     Regards
>>     JB
>>
>>     On 04/04/2016 04:15 PM, Elliot Metsger wrote:
>>
>>         Hi everyone,
>>
>>         I'm trying use the '-i' (--install) option of
>>         `feature:repo-add`, and it
>>         isn't working:
>>
>>         karaf@root()> feature:repo-add -i
>>         mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
>>         Adding feature url
>>         mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
>>         Error executing command: java.lang.UnsupportedOperationException
>>         karaf@root()>
>>
>>
>>         The feature repo installs just fine on its own, without -i:
>>         karaf@root()> feature:repo-add
>>         mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
>>         Adding feature url
>>         mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
>>         karaf@root()>
>>
>>         This feature repository is available on Maven central if you care
>> to
>>         replicate the problem.
>>
>>         Is there something wrong with the feature file that is causing
>> this
>>         error, or is this a bug in Karaf?
>>
>>         Thanks,
>>         Elliot
>>
>>
>>     --
>>     Jean-Baptiste Onofré
>>     jbonofre@apache.org <ma...@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: feature:repo-add -i broken in 4.0.4?

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
You can create a script (in etc/shell.init.script), that list all 
features in a repo (feature:list with grep on the repo), and then 
install the features with feature:install.

You can take a look on 
http://karaf.apache.org/manual/latest/developers-guide/scripting.html 
for details about scripting.

Regards
JB

On 04/04/2016 05:32 PM, Elliot Metsger wrote:
> Thank you Jean-Baptiste, for looking into this.  I'll look forward to 4.0.6.
>
> In the interim, is there a workaround for telling Karaf to "install all
> of the features in a features repository"?
>
> Thanks,
> Elliot
>
> On Mon, Apr 4, 2016 at 10:57 AM, Jean-Baptiste Onofré <jb@nanthrax.net
> <ma...@nanthrax.net>> wrote:
>
>     Yes, it could be considered as a regression as it works before but
>     no more in Karaf 4.x:
>
>          public void addRepository(URI uri, boolean install) throws
>     Exception {
>              if (install) {
>                  // TODO: implement
>                  throw new UnsupportedOperationException();
>              }
>     ...
>
>     The same happens for removeRepository where the uninstall flag is
>     simply ignored.
>
>     Due to the introduction of the Features resolver in Karaf 4, we
>     changed the implementation of these methods.
>
>     I will re-introduce support of these flags in 4.0.6:
>
>     https://issues.apache.org/jira/browse/KARAF-4468
>
>     Sorry about that.
>
>     Regards
>     JB
>
>     On 04/04/2016 04:15 PM, Elliot Metsger wrote:
>
>         Hi everyone,
>
>         I'm trying use the '-i' (--install) option of
>         `feature:repo-add`, and it
>         isn't working:
>
>         karaf@root()> feature:repo-add -i
>         mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
>         Adding feature url
>         mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
>         Error executing command: java.lang.UnsupportedOperationException
>         karaf@root()>
>
>
>         The feature repo installs just fine on its own, without -i:
>         karaf@root()> feature:repo-add
>         mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
>         Adding feature url
>         mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
>         karaf@root()>
>
>         This feature repository is available on Maven central if you care to
>         replicate the problem.
>
>         Is there something wrong with the feature file that is causing this
>         error, or is this a bug in Karaf?
>
>         Thanks,
>         Elliot
>
>
>     --
>     Jean-Baptiste Onofré
>     jbonofre@apache.org <ma...@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: feature:repo-add -i broken in 4.0.4?

Posted by Elliot Metsger <em...@gmail.com>.
Thank you Jean-Baptiste, for looking into this.  I'll look forward to 4.0.6.

In the interim, is there a workaround for telling Karaf to "install all of
the features in a features repository"?

Thanks,
Elliot

On Mon, Apr 4, 2016 at 10:57 AM, Jean-Baptiste Onofré <jb...@nanthrax.net>
wrote:

> Yes, it could be considered as a regression as it works before but no more
> in Karaf 4.x:
>
>     public void addRepository(URI uri, boolean install) throws Exception {
>         if (install) {
>             // TODO: implement
>             throw new UnsupportedOperationException();
>         }
> ...
>
> The same happens for removeRepository where the uninstall flag is simply
> ignored.
>
> Due to the introduction of the Features resolver in Karaf 4, we changed
> the implementation of these methods.
>
> I will re-introduce support of these flags in 4.0.6:
>
> https://issues.apache.org/jira/browse/KARAF-4468
>
> Sorry about that.
>
> Regards
> JB
>
> On 04/04/2016 04:15 PM, Elliot Metsger wrote:
>
>> Hi everyone,
>>
>> I'm trying use the '-i' (--install) option of `feature:repo-add`, and it
>> isn't working:
>>
>> karaf@root()> feature:repo-add -i
>> mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
>> Adding feature url mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
>> Error executing command: java.lang.UnsupportedOperationException
>> karaf@root()>
>>
>>
>> The feature repo installs just fine on its own, without -i:
>> karaf@root()> feature:repo-add
>> mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
>> Adding feature url mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
>> karaf@root()>
>>
>> This feature repository is available on Maven central if you care to
>> replicate the problem.
>>
>> Is there something wrong with the feature file that is causing this
>> error, or is this a bug in Karaf?
>>
>> Thanks,
>> Elliot
>>
>>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>

Re: feature:repo-add -i broken in 4.0.4?

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Yes, it could be considered as a regression as it works before but no 
more in Karaf 4.x:

     public void addRepository(URI uri, boolean install) throws Exception {
         if (install) {
             // TODO: implement
             throw new UnsupportedOperationException();
         }
...

The same happens for removeRepository where the uninstall flag is simply 
ignored.

Due to the introduction of the Features resolver in Karaf 4, we changed 
the implementation of these methods.

I will re-introduce support of these flags in 4.0.6:

https://issues.apache.org/jira/browse/KARAF-4468

Sorry about that.

Regards
JB

On 04/04/2016 04:15 PM, Elliot Metsger wrote:
> Hi everyone,
>
> I'm trying use the '-i' (--install) option of `feature:repo-add`, and it
> isn't working:
>
> karaf@root()> feature:repo-add -i
> mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
> Adding feature url mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
> Error executing command: java.lang.UnsupportedOperationException
> karaf@root()>
>
>
> The feature repo installs just fine on its own, without -i:
> karaf@root()> feature:repo-add
> mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
> Adding feature url mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
> karaf@root()>
>
> This feature repository is available on Maven central if you care to
> replicate the problem.
>
> Is there something wrong with the feature file that is causing this
> error, or is this a bug in Karaf?
>
> Thanks,
> Elliot
>

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

Re: feature:repo-add -i broken in 4.0.4?

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

let me check.

Regards
JB

On 04/04/2016 04:15 PM, Elliot Metsger wrote:
> Hi everyone,
>
> I'm trying use the '-i' (--install) option of `feature:repo-add`, and it
> isn't working:
>
> karaf@root()> feature:repo-add -i
> mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
> Adding feature url mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
> Error executing command: java.lang.UnsupportedOperationException
> karaf@root()>
>
>
> The feature repo installs just fine on its own, without -i:
> karaf@root()> feature:repo-add
> mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
> Adding feature url mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
> karaf@root()>
>
> This feature repository is available on Maven central if you care to
> replicate the problem.
>
> Is there something wrong with the feature file that is causing this
> error, or is this a bug in Karaf?
>
> Thanks,
> Elliot
>

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