Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NullPointerException: Cannot invoke "org.glassfish.jersey.client.ClientRequest.getPropertiesDelegate()" because the return value of "jakarta.inject.Provider.get()" is null #5732

Open
thiagohora opened this issue Aug 27, 2024 · 5 comments

Comments

@thiagohora
Copy link

thiagohora commented Aug 27, 2024

Error when using async request client

Version: 3.0.12

Code:

  try (Response response = client.target(BASE_RESOURCE_URI.formatted(baseURI))
                    .path("items")
                    .path("stream")
                    .request()
                    .accept(MediaType.APPLICATION_OCTET_STREAM)
                    .async()
                    .post(Entity.json(streamRequest)).get()) {

                assertThat(response.getStatus()).isEqualTo(200);

                List<String> actualItems = new ArrayList<>();

                try (ChunkedInput<String> chunkedInput = response.readEntity(new GenericType<ChunkedInput<String>>() {})) {
                    String chunk;
                    while ((chunk = chunkedInput.read()) != null) {
                        actualItems.add(chunk);
                    }
                }

Logs:

ARN  [2024-08-27 10:26:06,898] org.glassfish.jersey.internal.Errors: The following warnings have been detected: WARNING: Unknown HK2 failure detected:
MultiException stack 1 of 1
java.lang.NullPointerException: Cannot invoke "org.glassfish.jersey.client.ClientRequest.getPropertiesDelegate()" because the return value of "jakarta.inject.Provider.get()" is null
	at org.glassfish.jersey.client.ClientBinder$PropertiesDelegateFactory.get(ClientBinder.java:69)
	at org.glassfish.jersey.client.ClientBinder$PropertiesDelegateFactory.get(ClientBinder.java:58)
	at org.glassfish.jersey.inject.hk2.SupplierFactoryBridge.provide(SupplierFactoryBridge.java:76)
	at org.jvnet.hk2.internal.FactoryCreator.create(FactoryCreator.java:129)
	at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:466)
	at org.glassfish.jersey.inject.hk2.RequestContext.findOrCreate(RequestContext.java:59)
	at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2109)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetService(ServiceLocatorImpl.java:769)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.getUnqualifiedService(ServiceLocatorImpl.java:781)
	at org.jvnet.hk2.internal.IterableProviderImpl.get(IterableProviderImpl.java:88)
	at org.glassfish.jersey.client.ChunkedInputReader.readFrom(ChunkedInputReader.java:79)
	at org.glassfish.jersey.client.ChunkedInputReader.readFrom(ChunkedInputReader.java:44)
	at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.invokeReadFrom(ReaderInterceptorExecutor.java:233)
	at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:212)
	at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:132)
	at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1072)
	at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:919)
	at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:879)
	at org.glassfish.jersey.client.ClientResponse.readEntity(ClientResponse.java:340)
	at org.glassfish.jersey.client.InboundJaxrsResponse$2.call(InboundJaxrsResponse.java:104)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:205)
	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:365)
	at org.glassfish.jersey.client.InboundJaxrsResponse.runInScopeIfPossible(InboundJaxrsResponse.java:244)
	at org.glassfish.jersey.client.InboundJaxrsResponse.readEntity(InboundJaxrsResponse.java:101)

Screenshot 2024-08-27 at 13 10 46

@senivam
Copy link
Contributor

senivam commented Aug 27, 2024

the most probable reason is some required dependency, which is missing from your project. Could you please list dependencies here?

@thiagohora
Copy link
Author

I just added it

@senivam
Copy link
Contributor

senivam commented Aug 28, 2024

why is there org.glassfish.jersey.inject:jersey-hk2:3.1.8 and all other Jersey is of 3.0.12?

@thiagohora
Copy link
Author

It's a dependency of the framework I'm using. I changed it, but the result is the same.

Screenshot 2024-08-28 at 11 55 41

@senivam
Copy link
Contributor

senivam commented Aug 28, 2024

try with hk2 (api, locator, utils) version 3.0.3 which is the default for Jersey 3.0.12.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants