Reputation: 243
I am calling a REST service and the provider has supplied a client. Client's specification is to use Jersey 2.18. So i have used the below jersey dependencies
I am making calls using scheduledThreadPoolExecutor and my application is running in tc server and JDK 1.8. Sporadically i get the below exception. I tried searching this exception in google but no luck. But i see the below for almost everytime
Cannot create new registration for component type class > org.glassfish.jersey.client.authentication.HttpAuthenticationFeature
Exception
java.lang.NullPointerException at org.glassfish.jersey.model.internal.CommonConfig.configureFeatures(CommonConfig.java:694) at org.glassfish.jersey.model.internal.CommonConfig.configureMetaProviders(CommonConfig.java:644) at org.glassfish.jersey.client.ClientConfig$State.configureMetaProviders(ClientConfig.java:365) at org.glassfish.jersey.client.ClientConfig$State.initRuntime(ClientConfig.java:398) at org.glassfish.jersey.client.ClientConfig$State.access$000(ClientConfig.java:88) at org.glassfish.jersey.client.ClientConfig$State$3.get(ClientConfig.java:120) at org.glassfish.jersey.client.ClientConfig$State$3.get(ClientConfig.java:117) at org.glassfish.jersey.internal.util.collection.Values$LazyValueImpl.get(Values.java:340) at org.glassfish.jersey.client.ClientConfig.getRuntime(ClientConfig.java:726) at org.glassfish.jersey.client.ClientRequest.getConfiguration(ClientRequest.java:285) at org.glassfish.jersey.client.JerseyInvocation.validateHttpMethodAndEntity(JerseyInvocation.java:126) at org.glassfish.jersey.client.JerseyInvocation.(JerseyInvocation.java:98) at org.glassfish.jersey.client.JerseyInvocation.(JerseyInvocation.java:91) at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:411) at org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:307)
Upvotes: 0
Views: 811
Reputation: 243
I resolved this issue. My implementation was wrong. The client object was defined as a class level variable and it was initialized during every method call. During parallel call. every thread concurrent call attacks the same class level object and tries to modify and hence the object was not properly initialized. Now i fixed it by injecting the class from spring so that it is not modified during every call.
Upvotes: 1