jetty-web.xml : method not found & jetty.xml ignored

230 views
Skip to first unread message

Pierre Mardon

unread,
Sep 12, 2014, 5:55:58 AM9/12/14
to op...@googlegroups.com
Hi there !

Context : Karaf 3.0.1, Pax Web 3.1.0, building an app with Osgiliath Enterprise Framework

First of all, I'm pretty new to everything here, so I may
## First problem

When embedding my jetty-web.xml :

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <Set name="virtualHosts">
    <Array type="java.lang.String">
      <Item>www.blah.com</Item>
    </Array>
  </Set>
</Configure>

I get the java.lang.NoSuchMethodException: class org.ops4j.pax.web.service.jetty.internal.HttpServiceContext$2.setVirtualHosts(class [Ljava.lang.String;)
It happens for all methods (like getSecurityHandler()).

Looking at class hierarchy and DOMJettyWebXmlParser works, I can't figure out why as ServletContextHandler implements those public methods and org.ops4j.pax.web.service.jetty.internal.HttpServiceContext extends it.

Any idea what I could do wrong ?

## Second one

I tried to embed a jetty.xml configuration in a fragment. My fragment is correctly hosted but jetty.xml seems ignored.
in osgi.bnd :

Fragment-Host: org.ops4j.pax.web.pax-web-jetty-bundle

my jetty.xml at the root of the bundle fragment  :

<Configure class="org.eclipse.jetty.server.Server">
    <Call name="addConnector">
        <Arg>
            <New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
                <Set name="host">
                    <Property name="jetty.host" />
                </Set>
                <Set name="port">
                    <Property name="jetty.port" default="8282" />
                </Set>
                <Set name="maxIdleTime">300000</Set>
                <Set name="Acceptors">2</Set>
                <Set name="statsOn">false</Set>
                <Set name="confidentialPort">8443</Set>
                <Set name="lowResourcesConnections">20000</Set>
                <Set name="lowResourcesMaxIdleTime">5000</Set>
            </New>
        </Arg>
    </Call>
</Configure>

No such connector is opened and I cant find any trace like :
DEBUG  pax.web.service.internal.JettyServerImpl  - configure using bundleresource://100/jetty.xml

Again, what's wrong with this ?

Thanks in advance !


Pierre Mardon

unread,
Sep 12, 2014, 5:58:10 AM9/12/14
to op...@googlegroups.com

Oops, unended sentence :
First of all, I'm pretty new to everything here, so I may do an obvious mistake, but I investigated all this seriously.

Achim Nierbeck

unread,
Sep 12, 2014, 9:25:54 AM9/12/14
to op...@googlegroups.com
Hi Pierre, 

You didn't do much wrong :)
Let me answer you in the reverse order ;)

First when running with Karaf a custom jetty.xml isn't placed in a fragment bundle but in the etc folder of Karaf. 
And with Karaf 3.0.1 there is already one available for you to alter to your needs. 
The fragment approach is valid for Pax Web if it doesn't find a jetty.xml in the configured location.

Second regarding the jetty-web.xml 
Under the impression that you want to bind a specific war to an extra host, take a look at my blog posts on how to setup this scenario at [1] and [2]. 

If this isn't your favored way, give me a ping about the virtual host jetty-web.xml. 
Cause this should work right away. 
--> sample war [3]
--> integration test for 3.1.x [4] 

regards, Achim 





--
--
------------------
OPS4J - http://www.ops4j.org - op...@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & Project Lead
blog <http://notizblog.nierbeck.de/>

Software Architect / Project Manager / Scrum Master

Pierre Mardon

unread,
Sep 12, 2014, 2:02:02 PM9/12/14
to op...@googlegroups.com
Thanks Achim !


2014-09-12 15:25 GMT+02:00 Achim Nierbeck <bcan...@googlemail.com>:
Hi Pierre, 

You didn't do much wrong :)
Let me answer you in the reverse order ;)

First when running with Karaf a custom jetty.xml isn't placed in a fragment bundle but in the etc folder of Karaf. 
And with Karaf 3.0.1 there is already one available for you to alter to your needs. 
The fragment approach is valid for Pax Web if it doesn't find a jetty.xml in the configured location.

Ok, it makes sense to put the jetty's global configuration in karaf's etc.
 
Second regarding the jetty-web.xml 
Under the impression that you want to bind a specific war to an extra host, take a look at my blog posts on how to setup this scenario at [1] and [2]. 


The manifest way works perfectly for virtualhost :)
 
If this isn't your favored way, give me a ping about the virtual host jetty-web.xml. 
Cause this should work right away. 

Yep, the problem is that my global concern was to evaluate if I have to use apache2 in front of Jetty.
Playing with the jetty-web.xml was a move to determine if I can finely configure my apps.

For example, I want to use realms. I can declare them in karaf's jetty.xml, but I need to bind them in my apps.
I didn't find a manifest way to do this and I prefer using jetty-web.xml as it's more opened for fine tuning.
For now I'm stucked in this not found method problem whatever the method I try to call (here for virtualhosts) :


 java.lang.NoSuchMethodException: class org.ops4j.pax.web.service.jetty.internal.HttpServiceContext$2.setVirtualHosts(class [Ljava.lang.String;)
    at org.ops4j.pax.web.service.jetty.internal.util.DOMJettyWebXmlParser.set(DOMJettyWebXmlParser.java:341)
    at org.ops4j.pax.web.service.jetty.internal.util.DOMJettyWebXmlParser.configure(DOMJettyWebXmlParser.java:114)
    at org.ops4j.pax.web.service.jetty.internal.util.DOMJettyWebXmlParser.parse(DOMJettyWebXmlParser.java:79)
    at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext$2.call(HttpServiceContext.java:199)
    at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext$2.call(HttpServiceContext.java:193)
    at org.ops4j.pax.swissbox.core.ContextClassLoaderUtils.doWithClassLoader(ContextClassLoaderUtils.java:60)
...

Any suggestion is welcomed :)

BTW, is there any possible collision with Pax Web using rewrite rules in Jetty ?

Thanks very much for your support and reactivity ;)

 
You received this message because you are subscribed to a topic in the Google Groups "OPS4J" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ops4j/WaBUanBCpHE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ops4j+un...@googlegroups.com.

Achim Nierbeck

unread,
Sep 14, 2014, 3:06:26 AM9/14/14
to op...@googlegroups.com
Hi Pierre, 

I looked into this I think this is a bug in Pax Web. Right now the HttpServiceContext (which is not inherited from WebAppContext) doesn't support all of the methods from the WebAppContext. [1] 

regards, Achim


Achim Nierbeck

unread,
Sep 14, 2014, 11:38:25 AM9/14/14
to op...@googlegroups.com
Hi Pierre, 

I investigated some more and come to the conclusion, that this is a red herring. 
Must be something else that blocks your jetty-web.xml configuration as this works without any changes in the integration tests, and all the crucial methods are also inherited by the WebAppContext class, so it must be something in your setup. 

regards, Achim 

Pierre Mardon

unread,
Sep 14, 2014, 11:57:30 AM9/14/14
to op...@googlegroups.com
Ok, thanks for looking at this !

I also gave a try to url rewritting and adding a handler (tried many ways) seems to conflict with Pax Web services.
I'll stop playing with the fragile balance of the well configured stack of Osgiliath EF and end up using apache2 in front of Jetty for now...
It's not that ugly, and has many benefits ;)

If someone in this ecosystem (karaf / pax web / OEF) is interested in solving this, I'm available for any tests, but I have to move on for my project !

Thanks again !
Reply all
Reply to author
Forward
0 new messages