eclipse-ee4j / jersey

Eclipse Jersey Project - Read our Wiki:

Home Page:https://github.com/eclipse-ee4j/jersey/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

thiagohora opened this issue · comments

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

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

I just added it

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

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

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