You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Alex Soto <al...@envieta.com> on 2016/04/26 18:55:21 UTC
command not found
Hello,
Running Karaf 4.0.3, and pax-exam 4.7.0.
From my pax-exam integration test I have no problem running command “bundle:list”, however, on the next line, I try to run “bundle:restart” and get exception:
org.apache.felix.gogo.runtime.CommandNotFoundException: Command not found: bundle:restart
I assume that all bundle commands are deployed by the same feature, so why is list is available and not restart?
Is there something else I need to do to get access to the restart command?
Best regards,
Alex soto
Re: command not found
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
You can directly leverage KarafTestSupport.
It basically does:
protected String executeCommand(final String command, final Long
timeout, final Boolean silent, final Principal ... principals) {
waitForCommandService(command);
String response;
final ByteArrayOutputStream byteArrayOutputStream = new
ByteArrayOutputStream();
final PrintStream printStream = new
PrintStream(byteArrayOutputStream);
final Callable<String> commandCallable = new Callable<String>() {
@Override
public String call() throws Exception {
try {
if (!silent) {
System.err.println(command);
}
final CommandProcessor commandProcessor =
getOsgiService(CommandProcessor.class);
final CommandSession commandSession =
commandProcessor.createSession(System.in, printStream, System.err);
commandSession.execute(command);
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
printStream.flush();
return byteArrayOutputStream.toString();
}
};
FutureTask<String> commandFuture;
if (principals.length == 0) {
commandFuture = new FutureTask<String>(commandCallable);
} else {
// If principals are defined, run the command callable via
Subject.doAs()
commandFuture = new FutureTask<String>(new Callable<String>() {
@Override
public String call() throws Exception {
Subject subject = new Subject();
subject.getPrincipals().addAll(Arrays.asList(principals));
return Subject.doAs(subject, new
PrivilegedExceptionAction<String>() {
@Override
public String run() throws Exception {
return commandCallable.call();
}
});
}
});
}
try {
executor.submit(commandFuture);
response = commandFuture.get(timeout, TimeUnit.MILLISECONDS);
} catch (TimeoutException e) {
e.printStackTrace(System.err);
response = "SHELL COMMAND TIMED OUT: ";
} catch (ExecutionException e) {
Throwable cause = e.getCause().getCause();
throw new RuntimeException(cause.getMessage(), cause);
} catch (InterruptedException e) {
throw new RuntimeException(e.getMessage(), e);
}
return response;
}
Providing your principals.
Regards
JB
On 04/26/2016 08:29 PM, Alex Soto wrote:
> session execute:
>
> final Session session = sessionFactory.create(System.in, printStream,
> System.err);
> session.execute(command);
>
> with some future, callable, etc. as the done in Karaf’s own ITs
> Best regards,
>
> Alex soto
>
>
>
>
>> On Apr 26, 2016, at 1:50 PM, Jean-Baptiste Onofré <jb@nanthrax.net
>> <ma...@nanthrax.net>> wrote:
>>
>> I bet the ACL files are missing in the etc folder (probably custom
>> distribution).
>>
>> Can you check this ?
>>
>> Regards
>> JB
>>
>> On 04/26/2016 06:55 PM, Alex Soto wrote:
>>> Hello,
>>>
>>> Running Karaf 4.0.3, and pax-exam 4.7.0.
>>> From my pax-exam integration test I have no problem running command
>>> “bundle:list”, however, on the next line, I try to run “bundle:restart”
>>> and get exception:
>>>
>>> org.apache.felix.gogo.runtime.CommandNotFoundException: Command not
>>> found: bundle:restart
>>>
>>> I assume that all bundle commands are deployed by the same feature, so
>>> why is /list/ is available and not /restart/?
>>> Is there something else I need to do to get access to the /restart
>>> /command?
>>>
>>> Best regards,
>>> Alex soto
>>>
>>>
>>>
>>
>> --
>> 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: command not found
Posted by Alex Soto <al...@envieta.com>.
session execute:
final Session session = sessionFactory.create(System.in, printStream, System.err);
session.execute(command);
with some future, callable, etc. as the done in Karaf’s own ITs
Best regards,
Alex soto
> On Apr 26, 2016, at 1:50 PM, Jean-Baptiste Onofré <jb...@nanthrax.net> wrote:
>
> I bet the ACL files are missing in the etc folder (probably custom distribution).
>
> Can you check this ?
>
> Regards
> JB
>
> On 04/26/2016 06:55 PM, Alex Soto wrote:
>> Hello,
>>
>> Running Karaf 4.0.3, and pax-exam 4.7.0.
>> From my pax-exam integration test I have no problem running command
>> “bundle:list”, however, on the next line, I try to run “bundle:restart”
>> and get exception:
>>
>> org.apache.felix.gogo.runtime.CommandNotFoundException: Command not
>> found: bundle:restart
>>
>> I assume that all bundle commands are deployed by the same feature, so
>> why is /list/ is available and not /restart/?
>> Is there something else I need to do to get access to the /restart /command?
>>
>> Best regards,
>> Alex soto
>>
>>
>>
>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
Re: command not found
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
How do you execute the command in Pax Exam ? Using session.execute or
directly using the processor ?
Regards
JB
On 04/26/2016 08:19 PM, Alex Soto wrote:
> Verified that the ACL file under etc is present
> `org.apache.karaf.command.acl.bundle.cfg’ with:
>
> restart[/.*[-][f].*/] = admin
> restart = manager
>
>
> File: users.properties
>
> karaf = karaf,_g_:admingroup
> _g_\:admingroup=group,admin,manager,viewer,_system bundles_
>
>
>
> I am now passing a principal when invoking the command:
>
> log.info(karafCtl.executeCommand("bundle:restart \”business bundle\"",
> false, newRolePrincipal("karaf")));
>
> Best regards,
> Alex soto
>
>
>
>> On Apr 26, 2016, at 1:50 PM, Jean-Baptiste Onofré <jb@nanthrax.net
>> <ma...@nanthrax.net>> wrote:
>>
>> I bet the ACL files are missing in the etc folder (probably custom
>> distribution).
>>
>> Can you check this ?
>>
>> Regards
>> JB
>>
>> On 04/26/2016 06:55 PM, Alex Soto wrote:
>>> Hello,
>>>
>>> Running Karaf 4.0.3, and pax-exam 4.7.0.
>>> From my pax-exam integration test I have no problem running command
>>> “bundle:list”, however, on the next line, I try to run “bundle:restart”
>>> and get exception:
>>>
>>> org.apache.felix.gogo.runtime.CommandNotFoundException: Command not
>>> found: bundle:restart
>>>
>>> I assume that all bundle commands are deployed by the same feature, so
>>> why is /list/ is available and not /restart/?
>>> Is there something else I need to do to get access to the /restart
>>> /command?
>>>
>>> Best regards,
>>> Alex soto
>>>
>>>
>>>
>>
>> --
>> 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: command not found
Posted by Alex Soto <al...@envieta.com>.
Verified that the ACL file under etc is present `org.apache.karaf.command.acl.bundle.cfg’ with:
restart[/.*[-][f].*/] = admin
restart = manager
File: users.properties
karaf = karaf,_g_:admingroup
_g_\:admingroup = group,admin,manager,viewer,system bundles
I am now passing a principal when invoking the command:
log.info(karafCtl.executeCommand("bundle:restart \”business bundle\"", false, new RolePrincipal("karaf")));
Best regards,
Alex soto
> On Apr 26, 2016, at 1:50 PM, Jean-Baptiste Onofré <jb...@nanthrax.net> wrote:
>
> I bet the ACL files are missing in the etc folder (probably custom distribution).
>
> Can you check this ?
>
> Regards
> JB
>
> On 04/26/2016 06:55 PM, Alex Soto wrote:
>> Hello,
>>
>> Running Karaf 4.0.3, and pax-exam 4.7.0.
>> From my pax-exam integration test I have no problem running command
>> “bundle:list”, however, on the next line, I try to run “bundle:restart”
>> and get exception:
>>
>> org.apache.felix.gogo.runtime.CommandNotFoundException: Command not
>> found: bundle:restart
>>
>> I assume that all bundle commands are deployed by the same feature, so
>> why is /list/ is available and not /restart/?
>> Is there something else I need to do to get access to the /restart /command?
>>
>> Best regards,
>> Alex soto
>>
>>
>>
>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
Re: command not found
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
I bet the ACL files are missing in the etc folder (probably custom
distribution).
Can you check this ?
Regards
JB
On 04/26/2016 06:55 PM, Alex Soto wrote:
> Hello,
>
> Running Karaf 4.0.3, and pax-exam 4.7.0.
> From my pax-exam integration test I have no problem running command
> “bundle:list”, however, on the next line, I try to run “bundle:restart”
> and get exception:
>
> org.apache.felix.gogo.runtime.CommandNotFoundException: Command not
> found: bundle:restart
>
> I assume that all bundle commands are deployed by the same feature, so
> why is /list/ is available and not /restart/?
> Is there something else I need to do to get access to the /restart /command?
>
> Best regards,
> Alex soto
>
>
>
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
Re: command not found
Posted by Charles Moulliard <ch...@gmail.com>.
As Karaf uses Roles assigned to user (
https://karaf.apache.org/manual/latest/users-guide/security.html), I
suspect that the user or ACL defined doesn't allow you to use this command
http://grepcode.com/file/repo1.maven.org/maven2/org.apache.karaf.shell/org.apache.karaf.shell.core/4.0.0/org/apache/karaf/shell/impl/console/osgi/secured/SecuredSessionFactoryImpl.java#96
On Tue, Apr 26, 2016 at 7:12 PM, Alex Soto <al...@envieta.com> wrote:
> It is not very deep, but here it goes:
>
>
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredSessionFactoryImpl.checkSecurity(
> SecuredSessionFactoryImpl.java:116)
> at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(
> SecuredCommand.java:66)
> at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(
> SecuredCommand.java:87)
> at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:480)
> at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:406
> )
> at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
> at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:182)
> at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:119)
> at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(
> CommandSessionImpl.java:94)
> at org.apache.karaf.shell.impl.console.HeadlessSessionImpl.execute(
> HeadlessSessionImpl.java:90)
>
>
>
> Best regards,
> Alex soto
>
>
>
> On Apr 26, 2016, at 1:04 PM, Charles Moulliard <ch...@gmail.com> wrote:
>
> Hi Alex,
>
> List and Restart Commands are packaged within the same bundle
>
>
> https://github.com/apache/karaf/tree/master/bundle/core/src/main/java/org/apache/karaf/bundle/command
>
> Do you have more info within the stack trace ?
>
> Regards,
>
> On Tue, Apr 26, 2016 at 6:55 PM, Alex Soto <al...@envieta.com> wrote:
>
>> Hello,
>>
>> Running Karaf 4.0.3, and pax-exam 4.7.0.
>> From my pax-exam integration test I have no problem running command
>> “bundle:list”, however, on the next line, I try to run “bundle:restart” and
>> get exception:
>>
>> org.apache.felix.gogo.runtime.CommandNotFoundException: Command not
>> found: bundle:restart
>>
>> I assume that all bundle commands are deployed by the same feature, so
>> why is *list* is available and not *restart*?
>> Is there something else I need to do to get access to the *restart *
>> command?
>>
>> Best regards,
>> Alex soto
>>
>>
>>
>>
>
>
> --
> Charles Moulliard
> Apache Committer & PMC / Architect @RedHat
> Twitter : @cmoulliard | Blog : http://cmoulliard.github.io
>
>
>
--
Charles Moulliard
Apache Committer & PMC / Architect @RedHat
Twitter : @cmoulliard | Blog : http://cmoulliard.github.io
Re: command not found
Posted by Alex Soto <al...@envieta.com>.
It is not very deep, but here it goes:
org.apache.karaf.shell.impl.console.osgi.secured.SecuredSessionFactoryImpl.checkSecurity(SecuredSessionFactoryImpl.java:116)
at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:66)
at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:87)
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:480)
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:406)
at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:182)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:119)
at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:94)
at org.apache.karaf.shell.impl.console.HeadlessSessionImpl.execute(HeadlessSessionImpl.java:90)
Best regards,
Alex soto
> On Apr 26, 2016, at 1:04 PM, Charles Moulliard <ch...@gmail.com> wrote:
>
> Hi Alex,
>
> List and Restart Commands are packaged within the same bundle
>
> https://github.com/apache/karaf/tree/master/bundle/core/src/main/java/org/apache/karaf/bundle/command <https://github.com/apache/karaf/tree/master/bundle/core/src/main/java/org/apache/karaf/bundle/command>
>
> Do you have more info within the stack trace ?
>
> Regards,
>
> On Tue, Apr 26, 2016 at 6:55 PM, Alex Soto <alex.soto@envieta.com <ma...@envieta.com>> wrote:
> Hello,
>
> Running Karaf 4.0.3, and pax-exam 4.7.0.
> From my pax-exam integration test I have no problem running command “bundle:list”, however, on the next line, I try to run “bundle:restart” and get exception:
>
> org.apache.felix.gogo.runtime.CommandNotFoundException: Command not found: bundle:restart
>
> I assume that all bundle commands are deployed by the same feature, so why is list is available and not restart?
> Is there something else I need to do to get access to the restart command?
>
> Best regards,
> Alex soto
>
>
>
>
>
>
> --
> Charles Moulliard
> Apache Committer & PMC / Architect @RedHat
> Twitter : @cmoulliard | Blog : http://cmoulliard.github.io <http://cmoulliard.github.io/>
>
Re: command not found
Posted by Charles Moulliard <ch...@gmail.com>.
Hi Alex,
List and Restart Commands are packaged within the same bundle
https://github.com/apache/karaf/tree/master/bundle/core/src/main/java/org/apache/karaf/bundle/command
Do you have more info within the stack trace ?
Regards,
On Tue, Apr 26, 2016 at 6:55 PM, Alex Soto <al...@envieta.com> wrote:
> Hello,
>
> Running Karaf 4.0.3, and pax-exam 4.7.0.
> From my pax-exam integration test I have no problem running command
> “bundle:list”, however, on the next line, I try to run “bundle:restart” and
> get exception:
>
> org.apache.felix.gogo.runtime.CommandNotFoundException: Command not
> found: bundle:restart
>
> I assume that all bundle commands are deployed by the same feature, so why
> is *list* is available and not *restart*?
> Is there something else I need to do to get access to the *restart *
> command?
>
> Best regards,
> Alex soto
>
>
>
>
--
Charles Moulliard
Apache Committer & PMC / Architect @RedHat
Twitter : @cmoulliard | Blog : http://cmoulliard.github.io