我一直在努力让一个Web应用程序在Karaf 2.2.0的根应用程序上下文中运行(它在Karaf 2.1.4中运行良好).我已经能够使用Tomcat示例WAR将问题隔离到容易复制的问题.
从Karaf运行以下命令:
osgi:install -s webbundle:http://tomcat.apache.org/tomcat-5.5-doc/appdev/sample/sample.war?Bundle-SymbolicName = tomcat-sample&Webapp-Context =/anything
从Web浏览器访问应用程序(http:// localhost:8181/anything/index.html)
使用根上下文路径使用以下命令重新安装捆绑包:
osgi:install -s webbundle:http://tomcat.apache.org/tomcat-5.5-doc/appdev/sample/sample.war?Bundle-SymbolicName = tomcat-sample&Webapp-Context = /
尝试从Web浏览器访问该应用程序(http:// localhost:8181/index.html)
查看日志时,似乎当Web应用程序位于根应用程序上下文中时,它会为任何请求添加"/ default /".例如,在尝试访问/index.html时,它会在/default/index.html中查找,无法找到该页面,并返回未找到的错误(有关详细信息,请参阅下面的日志输出).
有谁知道如何解决这个问题?
日志输出
15:14:46,270 | DEBUG | 30 - /index.html | log | .eclipse.jetty.util.log.Slf4jLog 70 | 43 - org.eclipse.jetty.util - 7.2.2.v20101205 | REQUEST /index.html on org.eclipse.jetty.server.nio.SelectChannelConnector$3@693a1324
15:14:46,270 | DEBUG | 30 - /index.html | ServerModel | eb.service.spi.model.ServerModel 268 | 52 - org.ops4j.pax.web.pax-web-spi - 1.0.1 | Matching [/index.html]...
15:14:46,270 | DEBUG | 30 - /index.html …Run Code Online (Sandbox Code Playgroud) 我想在启动karaf时启动Camel和ActiveMQ,我发现的是etc/org.apache.karaf.features.cfg,它列出了应该在启动时启动的功能.
featuresBoot=config,ssh,management,camel,activemq,camel-jms,activemq-spring,activemq-camel
Run Code Online (Sandbox Code Playgroud)
除了'activemq-camel'之外,这种方式适用于所有人(很公平,因为它不是一个功能).为了安装apache-camel bundle,我要运行命令:
karaf@...>osgi:install -s mvn:org.apache.activemq/activemq-camel/5.5.0
Run Code Online (Sandbox Code Playgroud)
它可以工作,但我宁愿让它在启动时运行.我可以以某种方式在启动时安装activemq-camel bundle而不为它创建自定义功能吗?
对于Apache Karaf的人来说,这是一些真正的菜鸟(这是我对Karaf的第一次捆绑)问题.我正在部署一个使用了很多org.apache.commons.*bundle的bundle.当我部署我的捆绑包然后尝试启动它时,Karaf抛出了一个关于没有找到org.apache.commons.pools的错误.我做了一些谷歌搜索并运行以下内容:
osgi:install mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-pool
Run Code Online (Sandbox Code Playgroud)
这安装了丢失的捆绑包,我点击下一个.虽然我知道所需的软件包没有安装到OSGI容器中,但我有一些问题需要澄清.
希望问题足够清楚.我正在与卡拉夫取得进展,只需澄清这些要点.
有没有提供OSGi容器作为服务的Java PaaS解决方案?
If not a full-blown PaaS, just a clusterable/scalable OSGi host. Google turned up nothing, so I'm assuming there isn't anything like this. Thanks in advance!
我正在尝试集成测试Karaf功能与Pax考试,但我无法解决如何在我的config()方法中安装功能.
Pax考试版本为2.6.0,Apache Karaf 2.3.2版本.
这是我的配置方法:
@Configuration
public Option[] config() {
return new Option[]{karafDistributionConfiguration().frameworkUrl(
maven().groupId("org.apache.karaf").artifactId("apache-karaf").type("zip").versionAsInProject())
.karafVersion("2.3.2").name("Apache Karaf").unpackDirectory(new File("target")),
keepRuntimeFolder()};
}
Run Code Online (Sandbox Code Playgroud)
个别捆绑包可以安装,mavenBundle("group", "artifact", "version")但似乎没有机制来安装Pax考试的Karaf功能.
我能够在使用Junit注释的设置方法中以实用方式安装功能,@Before但是使用@Inject注入我的服务为时已晚.
是否可以在config()Pax考试测试的方法中安装Apache Karaf功能?
当尝试在Apache Karaf OSGi容器中安装httpclient-osgi 4.3.2软件包(org.apache.httpcomponents:httpclient-osgi:bundle:4.3.2,如HC站点上指定)时,我收到以下错误报告:
karaf@root> install mvn:org.apache.httpcomponents/httpclient-osgi/4.3.2
Bundle ID: 60
karaf@root> start 60
Error executing command: Error starting bundles:
Unable to start bundle 60: Unresolved constraint in bundle
org.apache.httpcomponents.httpclient [60]: Unable to resolve 60.0:
missing requirement [60.0] osgi.wiring.package;
(&(osgi.wiring.package=org.apache.http.concurrent)(version>=4.3.0)
(!(version>=4.4.0)))
Run Code Online (Sandbox Code Playgroud)
在检查标头时,似乎它尝试加载的依赖项被标记为Private-Package,并且可以在包JAR中找到类:
karaf@root> headers 60
Run Code Online (Sandbox Code Playgroud)
=>
...
Private-Package =
org.apache.commons.codec,
org.apache.commons.codec.binary,
org.apache.commons.codec.digest,
org.apache.commons.codec.language,
org.apache.commons.codec.language.bm,
org.apache.commons.codec.net,
org.apache.http,
org.apache.http.annotation,
org.apache.http.concurrent,
org.apache.http.config,
org.apache.http.entity,
org.apache.http.impl,
org.apache.http.impl.entity,
org.apache.http.impl.io,
org.apache.http.impl.pool,
org.apache.http.io,
org.apache.http.message,
org.apache.http.osgi.impl,
org.apache.http.params,
org.apache.http.pool,
org.apache.http.protocol,
org.apache.http.util
Run Code Online (Sandbox Code Playgroud)
同时,org.apache.http*也被定义为Import-Package …
我正在尝试使用Karaf并安装了一些捆绑X.这个捆绑包X抱怨缺少要求: Unresolved requirements ... osgi.wiring.package; (osgi.wiring.package=org.apache.commons.httpclient)]
因此,我试图提供通过bundle:install mvn:commons-httpclient/commons-httpclient/3.1其工作的org.apache.commons.httpclient .
但是,在尝试再次启动X后,我仍然得到相同的错误消息.
谢谢!
我有各种自制项目,具有第三方库依赖项.我将它们捆绑为OSGI容器但无法解决我的项目中的深度依赖项.现在我正在寻找karaf文件夹,我可以放置我的库,所以捆绑可以直接访问它们而不是安装它们.
更多我正在使用maven.
编辑:在遵循你的'功能'解决方案后,我能够产生明显的传递依赖性,但问题是现在它也寻找非常常见的java文件:例如:下面是相当大的依赖列表:
bsh -- Cannot be resolved
com.fasterxml.jackson.annotation -- Cannot be resolved
com.fasterxml.jackson.core -- Cannot be resolved
com.fasterxml.jackson.databind -- Cannot be resolved
com.fasterxml.jackson.databind.annotation -- Cannot be resolved
com.fasterxml.jackson.databind.module -- Cannot be resolved
com.gargoylesoftware.htmlunit -- Cannot be resolved
com.gargoylesoftware.htmlunit.util -- Cannot be resolved
com.google.protobuf -- Cannot be resolved
com.ibm.uvm.tools -- Cannot be resolved
com.ibm.websphere.uow -- Cannot be resolved
com.ibm.wsspi.uow -- Cannot be resolved
com.jamonapi -- Cannot be resolved
com.jamonapi.utils -- Cannot be resolved
com.jayway.jsonpath -- Cannot be resolved
com.jcraft.jzlib -- …Run Code Online (Sandbox Code Playgroud) 它是使用camel-cxf 部署在Apache Karaf 上的Web 服务。我能够在 URL localhost:8181/cxf 中看到 cxf 服务列表,其中部署了一些 rest 和 soap 服务。
问题是只要任何请求带有关键字“服务”,它就会返回服务列表。例如 url http://localhost:8181/abcd/services返回 cxf 服务列表页面而不是处理实际请求。
我从http://cxf.apache.org/docs/jaxrs-services-description.html 了解到这是因为 CXFServet 的 service-list-path 的默认值是 services。
这是我的问题。如果我想覆盖它,我应该在 etc/org.apache.cxf.osgi.cfg 中设置这个属性。这个 cfg 文件不在我的 karaf 的 etc 文件夹下。如果我手动创建此属性文件,需要采取哪些步骤?我需要安装哪些功能?或者创建这个配置文件就足够了?
感谢你的帮助 !
我正在使用ServiceMix,我试图列出一些捆绑包,只检索捆绑包ID.我正在尝试执行以下操作:
osgi:list | grep -i | awk xxx
我尝试使用awk,但ServiceMix中没有提供.我也试过用shell:exec这样:
osgi:list | grep -i | 外壳:EXEC
awk 'xxx'
但这也行不通,也许我的做法完全错了.有没有其他人有一些经验,我怎么能达到我的目标,只检索捆绑的id?
apache-karaf ×10
osgi ×8
java ×6
karaf ×3
apache-camel ×2
architecture ×1
cxf ×1
jetty ×1
maven ×1
osgi-bundle ×1
paas ×1
packaging ×1
pax ×1
pax-exam ×1
soa ×1
spring ×1