[PAX WEB] overrideDescriptor missing from HttpServiceContext

74 views
Skip to first unread message

Andrew Lienhard

unread,
Apr 27, 2021, 12:17:01 PM4/27/21
to OPS4J

Hi. I added a jetty-web.xml to a WEB-INF, which is being read, but as noted in other posts here the HttpServiceContext doesn't implement all of the methods in WebAppContext. The one I'd like to use is overrideDescriptor. 

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <Set name="overrideDescriptor"><SystemProperty name="jetty.home" default="."/>./etc/override-web.xml</Set>
</Configure>

Outcome:
Exception while configuring webApp!
java.lang.NoSuchMethodException: class org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.setOverrideDescriptor(class java.lang.String)

Is there a workaround?

Context: we're trying to apply a security-constraint to override what the various deployed web apps may have set in our karaf container. I suspect our solution will be to use an Apache front-end.

Thanks in advance!

Grzegorz Grzybek

unread,
Apr 28, 2021, 1:10:31 AM4/28/21
to op...@googlegroups.com
Hello

Unfortunately, big changes are coming only to Pax Web 8 and I don't see a chance to change this critical part of Pax Web 7 (so Pax Web's HttpServiceContexts extends different class or implements this method you need).

If you're trying to "apply security-constraints", you may try https://ops4j1.jira.com/wiki/spaces/paxweb/pages/354025473/HTTP+Context+processing - I implemented it some time ago to be able to override a "context" created by CXF, but it should apply to "contexts" created within the scope of WABs as well.

regards
Grzegorz Grzybek

--
--
------------------
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/ops4j/9013094a-e73a-49a9-9b69-1b82bce2c225n%40googlegroups.com.

Andrew Lienhard

unread,
Apr 28, 2021, 12:37:10 PM4/28/21
to OPS4J
Thanks for the response Grzegorz! I ran across that keycloak OSGI adapter yesterday and was starting down a similar path to unregister/reregister the corresponding servlets but your PID approach is clearly much better. To that end, I created a etc/org.ops4j.pax.web.context.cfg file in our karaf (specifically, unomi) environment. I see it listed in the karaf configuration under that PID, but it doesn't appear to be getting applied. Am I missing something? Also, does this approach work for multiple contexts? Do we create additional PIDs for each?

karaf/configuration

PID = org.ops4j.pax.web.context   
BundleLocation = ?   
bundle.symbolicName = org.apache.cxf.cxf-rt-transports-http   
context.id = default   
felix.fileinstall.filename = file:/PATH/etc/org.ops4j.pax.web.context.cfg   
javax.servlet.context.tempdir = /PATH/data/pax-web-jsp   
login.config.authMethod = BASIC   
login.config.realmName = myrealm
org.osgi.service.http.port = 8181   
security.constraint1.roles = foo
security.constraint1.url = /*   


Thanks!

Andrew Lienhard

unread,
Apr 28, 2021, 12:44:31 PM4/28/21
to OPS4J
I should add: I'm using pax web 7.2.19 via karaf 4.2.10

Grzegorz Grzybek

unread,
Apr 28, 2021, 1:32:49 PM4/28/21
to op...@googlegroups.com
Hello

Pax Web 7.2.19 should be fine. I can't check the code at the moment, but what I spotted is that you've created "etc/org.ops4j.pax.web.context.cfg" file which is "org.ops4j.pax.web.context" PID. You have to create a "factory PID", so please create a "etc/org.ops4j.pax.web.context-somename.cfg" file - dash ("-") in a PID makes it a factory PID and that's what the context processing needs.

regards
Grzegorz Grzybek

Andrew Lienhard

unread,
Apr 29, 2021, 11:20:48 AM4/29/21
to OPS4J
Great, that works!  And I learned about the Configuration Admin architecture too. Question: is this doable with other HttpServices like WAB or the karaf console as well? For example, in a separate file, I tried bundle.symbolicName = org.apache.karaf.webconsole.console which I got from its HttpContext entry in the karaf services console. Not sure if I'm using the correct bundle name and/or if it's supported. 

Thanks


Grzegorz Grzybek

unread,
Apr 30, 2021, 1:25:37 AM4/30/21
to op...@googlegroups.com
Hello

I'm glad it worked - answers inline

czw., 29 kwi 2021 o 17:20 Andrew Lienhard <alie...@gmail.com> napisał(a):
Great, that works!  And I learned about the Configuration Admin architecture too. Question: is this doable with other HttpServices like WAB or the karaf console as well? For example, in a separate file, I tried bundle.symbolicName = org.apache.karaf.webconsole.console which I got from its HttpContext entry in the karaf services console. Not sure if I'm using the correct bundle name and/or if it's supported. 

In theory, it should be supported - symbolic name is required to obtain HttpService reference in the context of proper BundleContext, so it should work for any bundle - with whiteboard/httpservice or WAB scenario.

regards
Grzegorz Grzybek
 
Reply all
Reply to author
Forward
0 new messages