Osgi 使用Puppet运行Karaf客户端时出现的问题

Osgi 使用Puppet运行Karaf客户端时出现的问题,osgi,puppet,apache-karaf,Osgi,Puppet,Apache Karaf,我试图运行一个脚本来使用puppet安装一些功能,但我遇到了一个奇怪的错误(确切地说是NullPointerException)。但是,如果我从计算机中的用户处运行脚本,则所有操作都会正确运行。我使用的是apachekaraf3.0.0和Puppet2.7 我的脚本非常简单: #!/bin/bash #### #### A init script for Karaf #### # Repos for REPO in <%= repos.sort.join(' ') %> do

我试图运行一个脚本来使用puppet安装一些功能,但我遇到了一个奇怪的错误(确切地说是
NullPointerException
)。但是,如果我从计算机中的用户处运行脚本,则所有操作都会正确运行。我使用的是
apachekaraf
3.0.0和
Puppet
2.7

我的脚本非常简单:

#!/bin/bash
####
#### A init script for Karaf
####

# Repos
for REPO in <%= repos.sort.join(' ') %>
do
   /opt/karaf/bin/client -a 8101 -h 127.0.0.1 -v feature:repo-add $REPO
done

# Features
for FEATURE in <%= features.sort.join(' ') %>
do
   /opt/karaf/bin/client -a 8101 -h 127.0.0.1 -v feature:install $FEATURE
done
这是我在机器中运行
Puppet
时得到的输出:

info: /Stage[main]/Karaf/File[/opt/karaf/bin/init.sh]: Filebucketed /opt/karaf/bin/init.sh to puppet with sum 7687821cc06d43754a4f44aa9b9a69ff
notice: /Stage[main]/Karaf/File[/opt/karaf/bin/init.sh]/content: content changed '{md5}7687821cc06d43754a4f44aa9b9a69ff' to '{md5}6bb98d2e1079c66a7b9e16fff5ec1860'
notice: /Stage[main]/Karaf/Exec[/opt/karaf/bin/init.sh]/returns: 30 [main] INFO org.apache.sshd.common.util.SecurityUtils - BouncyCastle not registered, using the default JCE provider
notice: /Stage[main]/Karaf/Exec[/opt/karaf/bin/init.sh]/returns: 519 [pool-2-thread-1] INFO org.apache.sshd.client.session.ClientSessionImpl - Session created...
notice: /Stage[main]/Karaf/Exec[/opt/karaf/bin/init.sh]/returns: java.lang.NullPointerException
notice: /Stage[main]/Karaf/Exec[/opt/karaf/bin/init.sh]/returns:   at org.apache.karaf.client.Main.main(Main.java:83)
notice: /Stage[main]/Karaf/Exec[/opt/karaf/bin/init.sh]/returns: 20 [main] INFO org.apache.sshd.common.util.SecurityUtils - BouncyCastle not registered, using the default JCE provider
notice: /Stage[main]/Karaf/Exec[/opt/karaf/bin/init.sh]/returns: 386 [pool-2-thread-1] INFO org.apache.sshd.client.session.ClientSessionImpl - Session created...
notice: /Stage[main]/Karaf/Exec[/opt/karaf/bin/init.sh]/returns: java.lang.NullPointerException
notice: /Stage[main]/Karaf/Exec[/opt/karaf/bin/init.sh]/returns:   at org.apache.karaf.client.Main.main(Main.java:83)
notice: /Stage[main]/Karaf/Exec[/opt/karaf/bin/init.sh]/returns: 27 [main] INFO org.apache.sshd.common.util.SecurityUtils - BouncyCastle not registered, using the default JCE provider
notice: /Stage[main]/Karaf/Exec[/opt/karaf/bin/init.sh]/returns: 497 [pool-2-thread-1] INFO org.apache.sshd.client.session.ClientSessionImpl - Session created...
notice: /Stage[main]/Karaf/Exec[/opt/karaf/bin/init.sh]/returns: java.lang.NullPointerException
但是,如果我在我的用户或根目录下运行它:

30 [main] INFO org.apache.sshd.common.util.SecurityUtils - BouncyCastle not registered, using the default JCE provider
550 [pool-2-thread-1] INFO org.apache.sshd.client.session.ClientSessionImpl - Session created...
561 [pool-2-thread-1] INFO org.apache.sshd.client.session.ClientSessionImpl - Server version string: SSH-2.0-SSHD-CORE-0.9.0
Logging in as karaf
564 [pool-2-thread-1] INFO org.apache.sshd.client.session.ClientSessionImpl - Received SSH_MSG_KEXINIT
592 [pool-2-thread-1] INFO org.apache.sshd.client.kex.DHG1 - Send SSH_MSG_KEXDH_INIT
602 [pool-2-thread-2] INFO org.apache.sshd.client.kex.DHG1 - Received SSH_MSG_KEXDH_REPLY
619 [pool-2-thread-2] WARN org.apache.sshd.client.keyverifier.AcceptAllServerKeyVerifier - Server at /127.0.0.1:8101 presented unverified key:
620 [pool-2-thread-2] INFO org.apache.sshd.client.session.ClientSessionImpl - Received SSH_MSG_NEWKEYS
625 [pool-2-thread-2] INFO org.apache.sshd.client.session.ClientSessionImpl - Send SSH_MSG_SERVICE_REQUEST for ssh-userauth
631 [main] INFO org.apache.sshd.client.auth.UserAuthAgent - Send SSH_MSG_USERAUTH_REQUEST for publickey
643 [pool-2-thread-5] INFO org.apache.sshd.client.auth.UserAuthAgent - Received SSH_MSG_USERAUTH_SUCCESS
675 [main] INFO org.apache.sshd.client.channel.ChannelExec - Send SSH_MSG_CHANNEL_OPEN on channel 101
678 [pool-2-thread-2] INFO org.apache.sshd.client.channel.ChannelExec - Send SSH_MSG_CHANNEL_REQUEST exec
Adding feature url mvn:io.hawt/hawtio-karaf/1.2.3/xml/features
936 [pool-2-thread-5] INFO org.apache.sshd.client.channel.ChannelExec - Received SSH_MSG_CHANNEL_REQUEST on channel 101
29 [main] INFO org.apache.sshd.common.util.SecurityUtils - BouncyCastle not registered, using the default JCE provider
539 [pool-2-thread-1] INFO org.apache.sshd.client.session.ClientSessionImpl - Session created...
Logging in as karaf
552 [pool-2-thread-1] INFO org.apache.sshd.client.session.ClientSessionImpl - Server version string: SSH-2.0-SSHD-CORE-0.9.0
554 [pool-2-thread-1] INFO org.apache.sshd.client.session.ClientSessionImpl - Received SSH_MSG_KEXINIT
579 [pool-2-thread-1] INFO org.apache.sshd.client.kex.DHG1 - Send SSH_MSG_KEXDH_INIT
592 [pool-2-thread-2] INFO org.apache.sshd.client.kex.DHG1 - Received SSH_MSG_KEXDH_REPLY
609 [pool-2-thread-2] WARN org.apache.sshd.client.keyverifier.AcceptAllServerKeyVerifier - Server at /127.0.0.1:8101 presented unverified key:
609 [pool-2-thread-2] INFO org.apache.sshd.client.session.ClientSessionImpl - Received SSH_MSG_NEWKEYS
615 [pool-2-thread-2] INFO org.apache.sshd.client.session.ClientSessionImpl - Send SSH_MSG_SERVICE_REQUEST for ssh-userauth
620 [main] INFO org.apache.sshd.client.auth.UserAuthAgent - Send SSH_MSG_USERAUTH_REQUEST for publickey
631 [pool-2-thread-5] INFO org.apache.sshd.client.auth.UserAuthAgent - Received SSH_MSG_USERAUTH_SUCCESS
668 [main] INFO org.apache.sshd.client.channel.ChannelExec - Send SSH_MSG_CHANNEL_OPEN on channel 101
670 [pool-2-thread-2] INFO org.apache.sshd.client.channel.ChannelExec - Send SSH_MSG_CHANNEL_REQUEST exec
Adding feature url mvn:org.apache.camel.karaf/apache-camel/2.13.0/xml/features
985 [pool-2-thread-5] INFO org.apache.sshd.client.channel.ChannelExec - Received SSH_MSG_CHANNEL_REQUEST on channel 101
27 [main] INFO org.apache.sshd.common.util.SecurityUtils - BouncyCastle not registered, using the default JCE provider
515 [pool-2-thread-1] INFO org.apache.sshd.client.session.ClientSessionImpl - Session created...
526 [pool-2-thread-1] INFO org.apache.sshd.client.session.ClientSessionImpl - Server version string: SSH-2.0-SSHD-CORE-0.9.0
Logging in as karaf
528 [pool-2-thread-1] INFO org.apache.sshd.client.session.ClientSessionImpl - Received SSH_MSG_KEXINIT
553 [pool-2-thread-1] INFO org.apache.sshd.client.kex.DHG1 - Send SSH_MSG_KEXDH_INIT
562 [pool-2-thread-2] INFO org.apache.sshd.client.kex.DHG1 - Received SSH_MSG_KEXDH_REPLY
578 [pool-2-thread-2] WARN org.apache.sshd.client.keyverifier.AcceptAllServerKeyVerifier - Server at /127.0.0.1:8101 presented unverified key:
579 [pool-2-thread-2] INFO org.apache.sshd.client.session.ClientSessionImpl - Received SSH_MSG_NEWKEYS
584 [pool-2-thread-2] INFO org.apache.sshd.client.session.ClientSessionImpl - Send SSH_MSG_SERVICE_REQUEST for ssh-userauth
590 [main] INFO org.apache.sshd.client.auth.UserAuthAgent - Send SSH_MSG_USERAUTH_REQUEST for publickey
602 [pool-2-thread-5] INFO org.apache.sshd.client.auth.UserAuthAgent - Received SSH_MSG_USERAUTH_SUCCESS
630 [main] INFO org.apache.sshd.client.channel.ChannelExec - Send SSH_MSG_CHANNEL_OPEN on channel 101
632 [pool-2-thread-2] INFO org.apache.sshd.client.channel.ChannelExec - Send SSH_MSG_CHANNEL_REQUEST exec
666 [pool-2-thread-4] INFO org.apache.sshd.client.channel.ChannelExec - Received SSH_MSG_CHANNEL_REQUEST on channel 101

它是不是在做我错过的事?Karaf 3.0.0的客户端是否存在错误?谢谢你,很抱歉发了这么长的帖子

我对木偶知之甚少。傀儡试图抓住karaf客户端在控制台中吐出的东西。如果是这样,则很可能出现空指针异常。我还没有找到一种从karaf客户端捕获输出的方法

我对木偶知之甚少。傀儡试图抓住karaf客户端在控制台中吐出的东西。如果是这样,则很可能出现空指针异常。我还没有找到一种从karaf客户端捕获输出的方法

这是Karaf 3.0.0中的一个bug,它在Karaf 3.0.1中被修复了这是Karaf 3.0.0中的一个bug,在Karaf 3.0.1中被修复了这似乎在3.0.1中得到了修复。详见以下Jira报告:


这似乎在3.0.1中得到了修复。详见以下Jira报告:


当Puppet运行时调用
System.console(..)
似乎返回null。你知道解决这个问题的方法吗?是的,我找到了JIRA票据:当Puppet运行时调用
System.console(…)
似乎返回空值。你知道解决这个问题的方法吗?是的,我找到了JIRA罚单:谢谢你的评论。我遇到了同样的问题,但我决定只使用纯SSH而不是客户端。我相信客户端(在我的场景中)有一个bug,因为Puppet运行时似乎没有连接控制台。控制台(…)返回
null
,当尝试使用它时,它抛出
NullPointerException
,感谢您的评论。我遇到了同样的问题,但我决定只使用纯SSH而不是客户端。我相信客户端(在我的场景中)有一个bug,因为Puppet在运行时似乎没有连接控制台。控制台(…)返回
null
,当试图使用它时,它抛出
NullPointerException
,如果这是真正的解决方案,请提供更多信息,可能还有某种链接或引文。如果这真的是解决方案,请提供更多信息,可能还有某种链接或引文。
30 [main] INFO org.apache.sshd.common.util.SecurityUtils - BouncyCastle not registered, using the default JCE provider
550 [pool-2-thread-1] INFO org.apache.sshd.client.session.ClientSessionImpl - Session created...
561 [pool-2-thread-1] INFO org.apache.sshd.client.session.ClientSessionImpl - Server version string: SSH-2.0-SSHD-CORE-0.9.0
Logging in as karaf
564 [pool-2-thread-1] INFO org.apache.sshd.client.session.ClientSessionImpl - Received SSH_MSG_KEXINIT
592 [pool-2-thread-1] INFO org.apache.sshd.client.kex.DHG1 - Send SSH_MSG_KEXDH_INIT
602 [pool-2-thread-2] INFO org.apache.sshd.client.kex.DHG1 - Received SSH_MSG_KEXDH_REPLY
619 [pool-2-thread-2] WARN org.apache.sshd.client.keyverifier.AcceptAllServerKeyVerifier - Server at /127.0.0.1:8101 presented unverified key:
620 [pool-2-thread-2] INFO org.apache.sshd.client.session.ClientSessionImpl - Received SSH_MSG_NEWKEYS
625 [pool-2-thread-2] INFO org.apache.sshd.client.session.ClientSessionImpl - Send SSH_MSG_SERVICE_REQUEST for ssh-userauth
631 [main] INFO org.apache.sshd.client.auth.UserAuthAgent - Send SSH_MSG_USERAUTH_REQUEST for publickey
643 [pool-2-thread-5] INFO org.apache.sshd.client.auth.UserAuthAgent - Received SSH_MSG_USERAUTH_SUCCESS
675 [main] INFO org.apache.sshd.client.channel.ChannelExec - Send SSH_MSG_CHANNEL_OPEN on channel 101
678 [pool-2-thread-2] INFO org.apache.sshd.client.channel.ChannelExec - Send SSH_MSG_CHANNEL_REQUEST exec
Adding feature url mvn:io.hawt/hawtio-karaf/1.2.3/xml/features
936 [pool-2-thread-5] INFO org.apache.sshd.client.channel.ChannelExec - Received SSH_MSG_CHANNEL_REQUEST on channel 101
29 [main] INFO org.apache.sshd.common.util.SecurityUtils - BouncyCastle not registered, using the default JCE provider
539 [pool-2-thread-1] INFO org.apache.sshd.client.session.ClientSessionImpl - Session created...
Logging in as karaf
552 [pool-2-thread-1] INFO org.apache.sshd.client.session.ClientSessionImpl - Server version string: SSH-2.0-SSHD-CORE-0.9.0
554 [pool-2-thread-1] INFO org.apache.sshd.client.session.ClientSessionImpl - Received SSH_MSG_KEXINIT
579 [pool-2-thread-1] INFO org.apache.sshd.client.kex.DHG1 - Send SSH_MSG_KEXDH_INIT
592 [pool-2-thread-2] INFO org.apache.sshd.client.kex.DHG1 - Received SSH_MSG_KEXDH_REPLY
609 [pool-2-thread-2] WARN org.apache.sshd.client.keyverifier.AcceptAllServerKeyVerifier - Server at /127.0.0.1:8101 presented unverified key:
609 [pool-2-thread-2] INFO org.apache.sshd.client.session.ClientSessionImpl - Received SSH_MSG_NEWKEYS
615 [pool-2-thread-2] INFO org.apache.sshd.client.session.ClientSessionImpl - Send SSH_MSG_SERVICE_REQUEST for ssh-userauth
620 [main] INFO org.apache.sshd.client.auth.UserAuthAgent - Send SSH_MSG_USERAUTH_REQUEST for publickey
631 [pool-2-thread-5] INFO org.apache.sshd.client.auth.UserAuthAgent - Received SSH_MSG_USERAUTH_SUCCESS
668 [main] INFO org.apache.sshd.client.channel.ChannelExec - Send SSH_MSG_CHANNEL_OPEN on channel 101
670 [pool-2-thread-2] INFO org.apache.sshd.client.channel.ChannelExec - Send SSH_MSG_CHANNEL_REQUEST exec
Adding feature url mvn:org.apache.camel.karaf/apache-camel/2.13.0/xml/features
985 [pool-2-thread-5] INFO org.apache.sshd.client.channel.ChannelExec - Received SSH_MSG_CHANNEL_REQUEST on channel 101
27 [main] INFO org.apache.sshd.common.util.SecurityUtils - BouncyCastle not registered, using the default JCE provider
515 [pool-2-thread-1] INFO org.apache.sshd.client.session.ClientSessionImpl - Session created...
526 [pool-2-thread-1] INFO org.apache.sshd.client.session.ClientSessionImpl - Server version string: SSH-2.0-SSHD-CORE-0.9.0
Logging in as karaf
528 [pool-2-thread-1] INFO org.apache.sshd.client.session.ClientSessionImpl - Received SSH_MSG_KEXINIT
553 [pool-2-thread-1] INFO org.apache.sshd.client.kex.DHG1 - Send SSH_MSG_KEXDH_INIT
562 [pool-2-thread-2] INFO org.apache.sshd.client.kex.DHG1 - Received SSH_MSG_KEXDH_REPLY
578 [pool-2-thread-2] WARN org.apache.sshd.client.keyverifier.AcceptAllServerKeyVerifier - Server at /127.0.0.1:8101 presented unverified key:
579 [pool-2-thread-2] INFO org.apache.sshd.client.session.ClientSessionImpl - Received SSH_MSG_NEWKEYS
584 [pool-2-thread-2] INFO org.apache.sshd.client.session.ClientSessionImpl - Send SSH_MSG_SERVICE_REQUEST for ssh-userauth
590 [main] INFO org.apache.sshd.client.auth.UserAuthAgent - Send SSH_MSG_USERAUTH_REQUEST for publickey
602 [pool-2-thread-5] INFO org.apache.sshd.client.auth.UserAuthAgent - Received SSH_MSG_USERAUTH_SUCCESS
630 [main] INFO org.apache.sshd.client.channel.ChannelExec - Send SSH_MSG_CHANNEL_OPEN on channel 101
632 [pool-2-thread-2] INFO org.apache.sshd.client.channel.ChannelExec - Send SSH_MSG_CHANNEL_REQUEST exec
666 [pool-2-thread-4] INFO org.apache.sshd.client.channel.ChannelExec - Received SSH_MSG_CHANNEL_REQUEST on channel 101