Reputation: 1407
I'm playing with OSGi via the framework implementation Felix 5.4. Currently I want to install an application server on a OSGi framework as a bundle. I've look at Pax-web and it seems the perfect solution for me. However, after successfully started up all the required bundles, The software complains with the following error:
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
By looking at the error, it seems that some Jetty configurations are not available in the pax-embedded jetty version. In particular maxErrorDispatches
, blockingTimeout
and persistentConnectionsEnabled
causes the error. However, even commenting out those 3 properties, pax-web won't start (can't connect to 127.0.0.1) and, after some logs, will simply print:
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
I've tried to solve this issue, but since I'm no expert in neither OSGi and Jetty I couldn't come up with no solution. To add some context to my scenario, here's some additional information:
java -jar bin\felix.jar
Bundles installed:
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 (stripped from comments):
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
Jetty configuration (without comments):
<?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>
Upvotes: 1
Views: 2614
Reputation: 19626
Your jetty version seems to match the pax web version. So this should not be the problem.
I just tested pax web in Apache karaf 4.0.7. There pax-web 4.3.0 and jetty 9.2.1 are used too. Karaf uses the individual jetty bundles though.
So I suspect there is an error in the pax-web-jetty-bundle. Can you open a jira issue at ops4j for this?
To fix your problem now you should install the same bundles that Apache karaf uses. Download and start karaf 4.0.7 and do feature:install http.
Then check the bundles using la -u. If you use the same bundles then it should work for you too.
Upvotes: 0