You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Thorsten Schöning <ts...@am-soft.de> on 2019/09/30 10:06:23 UTC

NPE at org.wicketstuff.rest.injection.InjectResourceTest.testInjection(InjectResourceTest.java:59)

Hi all,

I'm trying to build WicketStuff 8.0.6 from source and during running
tests I get the following exception:

> -------------------------------------------------------------------------------
> Test set: org.wicketstuff.rest.injection.InjectResourceTest
> -------------------------------------------------------------------------------
> Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.414 s <<< FAILURE! - in org.wicketstuff.rest.injection.InjectResourceTest
> testInjection(org.wicketstuff.rest.injection.InjectResourceTest)  Time elapsed: 1.357 s  <<< ERROR!
> java.lang.NullPointerException
>         at org.wicketstuff.rest.injection.InjectResourceTest.testInjection(InjectResourceTest.java:59)

The code at that line:

> ResourceReferenceRegistry registry = Application.get().getResourceReferenceRegistry();
> ResourceReference resourceReference = registry.getResourceReference(Application.class, "MountedResource", null, null, null, false, false);
> MountedResource resource = (MountedResource) resourceReference.getResource();

There's no additional logging or message which might help me
understand the purpose of this test and what might be missing why. The
test has been introduced pretty recently before the release of that
version:

https://github.com/wicketstuff/core/commit/12fcca8cd8d214008e4c164cfae76df2c88f9faa

What makes me wonder is using alternatives in providing the resources:

> //apply injection if we are in a container
>                 if (Injector.get() != null) {
>                     Injector.get().inject(resourceInstance);
>         }

https://github.com/wicketstuff/core/commit/12fcca8cd8d214008e4c164cfae76df2c88f9faa#diff-1eb6b497214e19671d478080efcee7bdR96

I would have expected that to be reflected somehow in the test or by
test execution as well, but in the end I'm only guessing about the
purpose etc. of this test anyway.

I'm using Java 8 on Windows 10 1903:

> openjdk version "1.8.0_222"
> OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_222-b10)
> OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.222-b10, mixed mode)

Any idea on how to resolve the problem? Thanks!

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow

Re: NPE at org.wicketstuff.rest.injection.InjectResourceTest.testInjection(InjectResourceTest.java:59)

Posted by Thorsten Schöning <ts...@am-soft.de>.
Guten Tag Thorsten Schöning,
am Montag, 30. September 2019 um 12:06 schrieben Sie:

>> -------------------------------------------------------------------------------
>> Test set: org.wicketstuff.rest.injection.InjectResourceTest
>> -------------------------------------------------------------------------------
>> Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.414 s <<< FAILURE! - in org.wicketstuff.rest.injection.InjectResourceTest
>> testInjection(org.wicketstuff.rest.injection.InjectResourceTest)  Time elapsed: 1.357 s  <<< ERROR!
>> java.lang.NullPointerException
>>         at org.wicketstuff.rest.injection.InjectResourceTest.testInjection(InjectResourceTest.java:59)

Just in case anyone else comes across this thread: I'm building Wicket
Stuff using a path with spaces and some places in the code use
URL.getFile, which doesn't properly decode that. Instead of failing
because of some missing path, resources for the test seemed to have
simply not been provided as expected. Changing that to properly
decode the URL fixes the build.

https://github.com/wicketstuff/core/pull/678

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow