[PAX-WEB] org.ops4j.lang.NullArgumentException: Context model is null

49 views
Skip to first unread message

Silvano Maffeis

unread,
Dec 12, 2019, 9:42:26 AM12/12/19
to op...@googlegroups.com
Hi

I'm using pax-web 7.3.5. In the activate() method of my OSGi bundle I'm doing the following:

final ServiceReference<WebContainer> ref = ctx.getServiceReference(WebContainer.class);
final WebContainer webCont = ctx.getService(ref);

webCont.registerWelcomeFiles(new String[] { "index.html" }, true, null);

and I'm getting the following error. I also tried with a non-null HttpContext, but I'm hitting the same exception:

org.apache.felix.log.LogException: org.ops4j.lang.NullArgumentException: Context model is null.
at org.ops4j.lang.NullArgumentException.validateNotNull(NullArgumentException.java:74)
at org.ops4j.pax.web.service.spi.model.Model.<init>(Model.java:27)
at org.ops4j.pax.web.service.spi.model.WelcomeFileModel.<init>(WelcomeFileModel.java:32)
at org.ops4j.pax.web.service.internal.HttpServiceStarted.registerWelcomeFiles(HttpServiceStarted.java:1005)
at org.ops4j.pax.web.service.internal.HttpServiceProxy.registerWelcomeFiles(HttpServiceProxy.java:364)


I'm on Apache Felix, not on Karaf.

Silvano

Grzegorz Grzybek

unread,
Dec 12, 2019, 10:39:12 AM12/12/19
to op...@googlegroups.com
Hello

Was it working before (an upgrade)?

I believe no one predicted that someone could register ONLY welcome files, without servlets/filters... But I may be wrong ;)
Could be a good (?) candidate for unit test.

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/CAMuHPN0hZtUpb065B8yD62JS%3De1qKb-4aDVXmAMfCf8mpzpQag%40mail.gmail.com.

Silvano Maffeis

unread,
Dec 12, 2019, 12:15:05 PM12/12/19
to op...@googlegroups.com
This used to work with pax-web 4.2.7

Achim Nierbeck

unread,
Dec 14, 2019, 10:34:43 AM12/14/19
to op...@googlegroups.com
Hi,

this use-case should work, so if it's not working anymore it's clearly a bug.

regards, Achim


Am Do., 12. Dez. 2019 um 18:15 Uhr schrieb Silvano Maffeis <sil...@maffeis.com>:
This used to work with pax-web 4.2.7

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


--

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/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master 

Silvano Maffeis

unread,
Feb 26, 2020, 3:32:08 AM2/26/20
to op...@googlegroups.com
I've tried the newest 7.3.6 now and I'm still getting this NullPointerException:

org.apache.felix.log.LogException: org.ops4j.lang.NullArgumentException: Context model is null.
at org.ops4j.lang.NullArgumentException.validateNotNull(NullArgumentException.java:74)
at org.ops4j.pax.web.service.spi.model.Model.<init>(Model.java:27)
at org.ops4j.pax.web.service.spi.model.WelcomeFileModel.<init>(WelcomeFileModel.java:32)
at org.ops4j.pax.web.service.internal.HttpServiceStarted.registerWelcomeFiles(HttpServiceStarted.java:1005)
at org.ops4j.pax.web.service.internal.HttpServiceProxy.registerWelcomeFiles(HttpServiceProxy.java:364)


The use case is where only static resources are being exposes, and registerWelcomeFiles is called.
I hit the NPE trying to access the welcome page (index.html):

WebContainer webCont = ...

webCont.registerResources(urlPath, urlPath , httpContext);
webCont.registerWelcomeFiles(new String[] { "index.html" }, true, httpContext);

Silvano

On Thu, Dec 12, 2019 at 6:14 PM Silvano Maffeis <sil...@maffeis.com> wrote:
This used to work with pax-web 4.2.7



--
Silvano Maffeis
Dr. oec. publ.

Grzegorz Grzybek

unread,
Feb 26, 2020, 4:49:58 AM2/26/20
to op...@googlegroups.com
Hello

I had your email marked as _unread_ for long time - sorry I didn't answer earlier...

I think the answer may be funnier and simpler than expected...

Most registerXXX() methods inside HttpServiceStarted call `org.ops4j.pax.web.service.internal.HttpServiceStarted#getOrCreateContext()` method. Only `org.ops4j.pax.web.service.internal.HttpServiceStarted#registerWelcomeFiles()` calls simply org.ops4j.pax.web.service.spi.model.ServiceModel#getContextModel(), so if the welcome files are first thing you do, no wonder you're getting null "context".


I'm just checking org.ops4j.pax.web.itest.common.AbstractWebContainerIntegrationTest#testWelcomFiles test and everything works fine, because the sequence of registrations in org.ops4j.pax.web.samples.helloworld.wc.internal.Activator#start() starts with servlet registration...

so I have one recommendation - please register something before welcome pages ;)

I'm reviewing entire Pax Web in version 8 and the registrations will be done a bit different (but not much).

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.
Reply all
Reply to author
Forward
0 new messages