我正在通过框架实现Felix5.4来处理OSGi。目前,我希望将应用服务器作为一个包安装在OSGi框架上。我已经看过Pax了,这似乎是我的完美解决方案。但是,在成功启动所有所需的包后,软件会出现以下错误:
org.ops4j.pax.web.pax-web-jetty-bundle[org.ops4j.pax.web.service.internal.Activator] : Unable to start pax web server: Exception while starting Jetty
java.lang.RuntimeException: Exception while starting Jetty
at org.ops4j.pax.web.service.jetty.internal.JettyServerImpl.start(JettyServerImpl.java:188)
at org.ops4j.pax.web.service.jetty.internal.ServerControllerImpl$Stopped.start(ServerControllerImpl.java:415)
at org.ops4j.pax.web.service.jetty.internal.ServerControllerImpl.start(ServerControllerImpl.java:71)
at org.ops4j.pax.web.service.jetty.internal.ServerControllerImpl$Unconfigured.configure(ServerControllerImpl.java:707)
at org.ops4j.pax.web.service.jetty.internal.ServerControllerImpl.configure(ServerControllerImpl.java:87)
at org.ops4j.pax.web.service.internal.Activator.updateController(Activator.java:353)
at org.ops4j.pax.web.service.internal.Activator$3.run(Activator.java:295)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.ops4j.pax.web.service.jetty.internal.JettyServerImpl.start(JettyServerImpl.java:151)
... 11 more
Caused by: java.lang.NoSuchMethodException: class org.eclipse.jetty.server.HttpConfiguration.setMaxErrorDispatches(class java.lang.String)
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.set(XmlConfiguration.java:582)
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:411)
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.newObj(XmlConfiguration.java:815)
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:423)
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:298)
at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:248)
... 16 more通过查看错误,似乎有些Jetty配置在pax嵌入式jetty版本中不可用。特别是maxErrorDispatches、blockingTimeout和persistentConnectionsEnabled会导致错误。但是,即使注释掉这3个属性,pax-web也不会启动(无法连接到127.0.0.1),并且在一些日志之后,只需打印:
org.ops4j.pax.web.pax-web-jetty-bundleorg.ops4j.pax.web.service.internal.ConfigurationImpl :读取配置属性org.ops4j.pax.web.config.url失败
我试图解决这个问题,但由于我在OSGi和Jetty方面都不是专家,所以我无法找到解决方案。为了在我的场景中添加一些上下文,下面是一些附加信息:
java -jar bin\felix.jar发射felix安装了Bundles:
lb
START LEVEL 1
ID|State |Level|Name
0|Active | 0|System Bundle (5.6.0)|5.6.0
1|Active | 1|ASM (5.1.0)|5.1.0
2|Active | 1|ASM commons classes (5.1.0)|5.1.0
3|Active | 1|ASM Tree class visitor (5.1.0)|5.1.0
4|Active | 1|javax.servlet API v.3.0 (3.0.0.SNAPSHOT)|3.0.0.SNAPSHOT
5|Active | 1|Apache Felix Bundle Repository (2.0.8)|2.0.8
6|Active | 1|Apache Felix Gogo Command (0.16.0)|0.16.0
7|Active | 1|Apache Felix Gogo Runtime (0.16.2)|0.16.2
8|Active | 1|Apache Felix Gogo Shell (0.10.0)|0.10.0
9|Active | 1|osgi (3.0.0)|3.0.0
10|Active | 1|OPS4J Pax Logging - API (1.9.0)|1.9.0
11|Active | 1|OPS4J Pax Web - API (4.3.0)|4.3.0
12|Active | 1|OPS4J Pax Web - Extender - WAR (4.3.0)|4.3.0
13|Active | 1|OPS4J Pax Web - Jetty Bundle (4.3.0)|4.3.0
14|Active | 1|OPS4J Pax Web - Jsp Support (4.3.0)|4.3.0
15|Active | 1|OPS4J Pax Web - Service SPI (4.3.0)|4.3.0
16|Active | 1|Apache XBean OSGI Bundle Utilities (4.5.0)|4.5.0
17|Active | 1|Apache XBean :: Classpath Resource Finder (4.5.0)|4.5.0config.properties (从评论中去掉):
org.osgi.framework.system.packages.extra=org.apache.juli.logging
org.osgi.framework.bootdelegation=sun.*,com.sun.*
org.osgi.framework.storage.clean=onFirstInit
felix.auto.deploy.action=install,start
felix.auto.deploy.dir=pax
felix.log.level=1
org.osgi.framework.startlevel.beginning=1
felix.startlevel.bundle=1
org.osgi.service.http.port=8080
obr.repository.url=http://felix.apache.org/obr/releases.xml
org.ops4j.pax.web.config.file=jetty.xmlJetty配置(没有注释):
<?xml version="1.0"?>
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Get name="ThreadPool">
<Set name="minThreads" type="int"><Property name="jetty.threadPool.minThreads" deprecated="threads.min" default="10"/></Set>
<Set name="maxThreads" type="int"><Property name="jetty.threadPool.maxThreads" deprecated="threads.max" default="200"/></Set>
<Set name="idleTimeout" type="int"><Property name="jetty.threadPool.idleTimeout" deprecated="threads.timeout" default="60000"/></Set>
<Set name="detailedDump">false</Set>
</Get>
<Call name="addBean">
<Arg>
<New class="org.eclipse.jetty.util.thread.ScheduledExecutorScheduler"/>
</Arg>
</Call>
<New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
<Set name="secureScheme"><Property name="jetty.httpConfig.secureScheme" default="https" /></Set>
<Set name="securePort"><Property name="jetty.httpConfig.securePort" deprecated="jetty.secure.port" default="8443" /></Set>
<Set name="outputBufferSize"><Property name="jetty.httpConfig.outputBufferSize" deprecated="jetty.output.buffer.size" default="32768" /></Set>
<Set name="outputAggregationSize"><Property name="jetty.httpConfig.outputAggregationSize" deprecated="jetty.output.aggregation.size" default="8192" /></Set>
<Set name="requestHeaderSize"><Property name="jetty.httpConfig.requestHeaderSize" deprecated="jetty.request.header.size" default="8192" /></Set>
<Set name="responseHeaderSize"><Property name="jetty.httpConfig.responseHeaderSize" deprecated="jetty.response.header.size" default="8192" /></Set>
<Set name="sendServerVersion"><Property name="jetty.httpConfig.sendServerVersion" deprecated="jetty.send.server.version" default="true" /></Set>
<Set name="sendDateHeader"><Property name="jetty.httpConfig.sendDateHeader" deprecated="jetty.send.date.header" default="false" /></Set>
<Set name="headerCacheSize"><Property name="jetty.httpConfig.headerCacheSize" default="512" /></Set>
<Set name="delayDispatchUntilContent"><Property name="jetty.httpConfig.delayDispatchUntilContent" deprecated="jetty.delayDispatchUntilContent" default="true"/></Set>
<Set name="maxErrorDispatches"><Property name="jetty.httpConfig.maxErrorDispatches" default="10"/></Set>
<Set name="blockingTimeout"><Property name="jetty.httpConfig.blockingTimeout" default="-1"/></Set>
<Set name="persistentConnectionsEnabled"><Property name="jetty.httpConfig.persistentConnectionsEnabled" default="true"/></Set>
</New>
<Set name="handler">
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
<Set name="handlers">
<Array type="org.eclipse.jetty.server.Handler">
<Item>
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
</Item>
<Item>
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
</Item>
</Array>
</Set>
</New>
</Set>
<Set name="stopAtShutdown"><Property name="jetty.server.stopAtShutdown" default="true"/></Set>
<Set name="stopTimeout"><Property name="jetty.server.stopTimeout" default="5000"/></Set>
<Set name="dumpAfterStart"><Property name="jetty.server.dumpAfterStart" deprecated="jetty.dump.start" default="false"/></Set>
<Set name="dumpBeforeStop"><Property name="jetty.server.dumpBeforeStop" deprecated="jetty.dump.stop" default="false"/></Set>
</Configure>发布于 2016-10-18 07:24:21
您的jetty版本似乎与pax web版本相匹配。所以这不应该是问题所在。
我刚刚在Apache 4.0.7中测试了pax。这里也使用pax-web4.3.0和jetty9.2.1。不过,Karaf使用的是个别的码头捆绑包。
因此,我怀疑pax-web-jetty包中有一个错误。您能在ops4j上打开一个jira问题吗?
为了现在解决问题,您应该安装Apache使用的相同的包。下载并启动karaf 4.0.7并做功能:安装http。
然后使用la -u检查这些包。如果您使用相同的包,那么它也适用于您。
https://stackoverflow.com/questions/40097071
复制相似问题