2016-10-17 62 views
0

我正在通過框架實現Felix 5.4玩OSGi。目前我想要將一個應用程序服務器作爲一個包安裝在OSGi框架上。我已經看過Pax-web,它對我來說似乎是最完美的解決方案。 然而,在成功啓動了所有需要的軟件包,軟件抱怨,出現以下錯誤:無法啓動Pax-web

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 

通過查看錯誤,似乎有些碼頭配置不是在PAX-嵌入式碼頭版本。特別是maxErrorDispatches,blockingTimeoutpersistentConnectionsEnabled會導致錯誤。然而,即使註釋掉那些3個屬性,PAX-網頁將無法啓動(不能連接到127.0.0.1)和一些登錄後,將只打印:

org.ops4j.pax.web.pax-web-jetty-bundle[org.ops4j.pax.web.service.internal.ConfigurationImpl] : Reading configuration property org.ops4j.pax.web.config.url has failed

我試圖解決這個問題問題,但既然我既不是OSGi和Jetty的專家,也不能提出解決方案。要添加一些上下文到我的方案,這裏有一些額外的信息:

  • 我使用felix 5.4;
  • 我使用Windows 10 64位;
  • jetty.xml我在conf /,bin/felix文件夾的同一目錄下;
  • 安裝經由java -jar bin\felix.jar

束中的發射菲利克斯:

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.0 

config.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.xml 

碼頭結構(不帶註釋):

<?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> 
+0

你使用哪個碼頭版本?您的套餐清單不顯示碼頭。 –

+0

@ChristianSchneider:現在我正在使用4.3.0版本的「pax-web-jetty-bundle」。通過查看罐子內部,我發現Jetty嵌入其中:所述束的清單包含一個Export-Package條目,它聲明:org.eclipse.jetty; version =「9.2.19.v20160908」。我推斷我正在使用9.2碼頭版本;我錯了嗎? – Koldar

回答

0

您的碼頭版本似乎與pax web版本相匹配。所以這不應該是問題。

我剛剛在Apache karaf 4.0.7中測試了pax web。還有使用pax-web 4.3.0和jetty 9.2.1。雖然卡拉夫使用單獨的碼頭包。

所以我懷疑pax-web-jetty-bundle中有錯誤。你可以在ops4j上打開一個jira問題嗎?

要解決您的問題,現在應該安裝Apache karaf使用的相同捆綁包。下載並啓動karaf 4.0.7並執行功能:安裝http。

然後使用la -u檢查捆綁包。如果你使用相同的捆綁包,那麼它也適合你。