How can I update a existing Keycloak client attribute in a realm? - keycloak

I've added few attributes for each client in keycloak, and now I need to update the existing client attribute to new value without deleting the client.
List<ClientRepresentation> list = realm.clients().findByClientId(client.getClientId());
ClientResource resource = realm.clients().get(client.getClientId());
ClientRepresentation clientRepresentation = list.get(0);
//clientRepresentation.getAttributes().put(KeyCloakAttribute.OBJECT_BASED_ACCESS.getLabel(), application.getAttributes().getObjectBasedModel());
clientRepresentation.setName("updated-name");
resource.update(clientRepresentation); <- This line is throwing error
I could see client resource is providing update method, but when i use it i'm getting 404 error.
2022-01-22 19:07:29.057 -ERROR 15870 [SpringApplication.java] [reportFailure] [org.springframework.boot.SpringApplication]:826 --- [restartedMain] ngp-dev-env o.s.boot.SpringApplication : Application run failed javax.ws.rs.NotFoundException: HTTP 404 Not Found
at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.handleErrorStatus(ClientInvocation.java:225)
at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.extractResult(ClientInvocation.java:195)
at org.jboss.resteasy.client.jaxrs.internal.proxy.extractors.BodyEntityExtractor.extractEntity(BodyEntityExtractor.java:62)
at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.invokeSync(ClientInvoker.java:151)
at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.invoke(ClientInvoker.java:112)
at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientProxy.invoke(ClientProxy.java:76)
at com.sun.proxy.$Proxy229.getServiceAccountUser(Unknown Source)
at com.service.KeycloakApplication.updateAttributes(KeycloakApplication.java:89)
at com.service.RegisterService.register(RegisterService.java:32)
at com.OpenAPI2SpringBoot.registerApplication(OpenAPI2SpringBoot.java:88)
at com.OpenAPI2SpringBoot.onApplicationEvent(OpenAPI2SpringBoot.java:80)
at com.OpenAPI2SpringBoot.onApplicationEvent(OpenAPI2SpringBoot.java:1)
at com.OpenAPI2SpringBoot$$EnhancerBySpringCGLIB$$a66f061b.onApplicationEvent(<generated>)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:403)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:360)
at org.springframework.boot.context.event.EventPublishingRunListener.running(EventPublishingRunListener.java:103)
at org.springframework.boot.SpringApplicationRunListeners.running(SpringApplicationRunListeners.java:77)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:330)
at com.OpenAPI2SpringBoot.main(OpenAPI2SpringBoot.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
keycloak client resource update docs
am I doing it in the wrong way or is there any other way to do it ?

According to the API documentation realm.clients() returns a ClientsResource interface. The method findByClientId requests the clientId as parameter but the method get:
#Path(value="{id}")
ClientResource get(#PathParam(value="id")
String id)
requests the id of the client, not the client ID.
So you need to replace:
realm.clients().get(client.getClientId());
with
realm.clients().get(client.getId());

Related

Kafka Consumer Connecting to MongoDB

I have a Kafka Consumer service
#KafkaListener(
topics = "topic1",
groupId = "cluster1",
containerFactory = "KafkaListenerContainerFactory")
public void consume(Message message) {
logger.info(String.format("Message recieved -> %s", message.getMsg()));
Long id = message.getId()
RepoDetail repoDetail = testRepo.findByID(id);
logger.info(
String.format(
"Message -> %s", repoDetail.getMessage()));
}
but when it tries to hit the mongo repo i get the following error:
No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
Any way I can call a mongoDB from Kafka Consumer?
full log stack:
org.springframework.kafka.listener.ListenerExecutionFailedException: Listener method 'public void com.kafka.api.service.ConsumerService.consume(...)' threw exception; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.decorateException(KafkaMessageListenerContainer.java:2188) ~[spring-kafka-2.6.9.jar:2.6.9]
at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.doInvokeOnMessage(KafkaMessageListenerContainer.java:2159) ~[spring-kafka-2.6.9.jar:2.6.9]
at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.invokeOnMessage(KafkaMessageListenerContainer.java:2120) ~[spring-kafka-2.6.9.jar:2.6.9]
at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.doInvokeRecordListener(KafkaMessageListenerContainer.java:2039) ~[spring-kafka-2.6.9.jar:2.6.9]
at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.doInvokeWithRecords(KafkaMessageListenerContainer.java:1967) ~[spring-kafka-2.6.9.jar:2.6.9]
at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.invokeRecordListener(KafkaMessageListenerContainer.java:1853) ~[spring-kafka-2.6.9.jar:2.6.9]
at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.invokeListener(KafkaMessageListenerContainer.java:1543) ~[spring-kafka-2.6.9.jar:2.6.9]
at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.pollAndInvoke(KafkaMessageListenerContainer.java:1190) ~[spring-kafka-2.6.9.jar:2.6.9]
at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.run(KafkaMessageListenerContainer.java:1087) ~[spring-kafka-2.6.9.jar:2.6.9]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_212]
at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266) ~[?:1.8.0_212]
at java.util.concurrent.FutureTask.run(FutureTask.java) ~[?:1.8.0_212]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_212]
Caused by: java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
at org.springframework.web.context.request.RequestContextHolder.currentRequestAttributes(RequestContextHolder.java:131) ~[spring-web-5.3.8.jar:5.3.8]
at org.springframework.web.context.support.WebApplicationContextUtils.currentRequestAttributes(WebApplicationContextUtils.java:313) ~[spring-web-5.3.8.jar:5.3.8]
at org.springframework.web.context.support.WebApplicationContextUtils.access$400(WebApplicationContextUtils.java:66) ~[spring-web-5.3.8.jar:5.3.8]
at org.springframework.web.context.support.WebApplicationContextUtils$RequestObjectFactory.getObject(WebApplicationContextUtils.java:329) ~[spring-web-5.3.8.jar:5.3.8]
at org.springframework.web.context.support.WebApplicationContextUtils$RequestObjectFactory.getObject(WebApplicationContextUtils.java:324) ~[spring-web-5.3.8.jar:5.3.8]
at org.springframework.beans.factory.support.AutowireUtils$ObjectFactoryDelegatingInvocationHandler.invoke(AutowireUtils.java:292) ~[spring-beans-5.3.8.jar:5.3.8]
at com.sun.proxy.$Proxy156.getHeader(Unknown Source) ~[?:?]
at com.repository.BaseRepository.getTemplate(BaseRepository.java:57) ~[repo-5.3.008.jar:?]
at com.kafka.api.repository.impl.ProductDetailRepositoryImpl.findByID(ProductDetailRepositoryImpl.java:21) ~[classes/:?]
at com.kafka.api.repository.impl.ProductDetailRepositoryImpl$$FastClassBySpringCGLIB$$824634c2.invoke(<generated>) ~[classes/:?]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.8.jar:5.3.8]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:779) ~[spring-aop-5.3.8.jar:5.3.8]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.3.8.jar:5.3.8]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750) ~[spring-aop-5.3.8.jar:5.3.8]
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137) ~[spring-tx-5.3.8.jar:5.3.8]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.8.jar:5.3.8]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750) ~[spring-aop-5.3.8.jar:5.3.8]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:692) ~[spring-aop-5.3.8.jar:5.3.8]
at com.kafka.api.repository.impl.ProductDetailRepositoryImpl$$EnhancerBySpringCGLIB$$ee673ffc.findByID(<generated>) ~[classes/:?]
at com.kafka.api.service.ConsumerService.consume(ConsumerService.java:35) ~[classes/:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_212]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_212]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_212]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_212]
at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:171) ~[spring-messaging-5.3.8.jar:5.3.8]
at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:120) ~[spring-messaging-5.3.8.jar:5.3.8]
at org.springframework.kafka.listener.adapter.HandlerAdapter.invoke(HandlerAdapter.java:48) ~[spring-kafka-2.6.9.jar:2.6.9]
at org.springframework.kafka.listener.adapter.MessagingMessageListenerAdapter.invokeHandler(MessagingMessageListenerAdapter.java:330) ~[spring-kafka-2.6.9.jar:2.6.9]
at org.springframework.kafka.listener.adapter.RecordMessagingMessageListenerAdapter.onMessage(RecordMessagingMessageListenerAdapter.java:87) ~[spring-kafka-2.6.9.jar:2.6.9]
at org.springframework.kafka.listener.adapter.RecordMessagingMessageListenerAdapter.onMessage(RecordMessagingMessageListenerAdapter.java:52) ~[spring-kafka-2.6.9.jar:2.6.9]
at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.doInvokeOnMessage(KafkaMessageListenerContainer.java:2139) ~[spring-kafka-2.6.9.jar:2.6.9]
... 11 more
Yes you can. Using a BSON Document and a perfect Write Model, you can upsert data into Mongo DB through BulkWriteResult interface.
BulkWriteResult result = getMongoClient()
.getDatabase(config.getNamespace().getDatabaseName())
.getCollection(config.getNamespace()
.getCollectionName(),BsonDocument.class)
.bulkWrite(writeModels, BULK_WRITE_OPTIONS);
Declare the below bean in your config class,
#Bean public RequestContextListener requestContextListener(){
return new RequestContextListener();
}

Scala play framework - convert Rest API to HTTPS using .JKS file using organizational CA

Currently I am running scala play application, now it's HTTP APIs are working fine in my Angular UI application locally. But in our organization for higher environment we need to convert it to SSL HTTPS API.
We use our own organizational root CA and I got the myCA_trust.jks certificate file with me.
I added following properties in application.conf file,
play.server.https.keyStore.path="./myCA_trust.jks"
play.server.https.keyStore.password="change_me"
And for deploying the code I am creating the dist, and using following command to deploy it on linux server
./scala-rest-api -Dplay.http.secret.key="application_secreate_key" -Dhttps.port=8094 -Dplay.server.https.keyStore.path=./myCA_trust.jks -Dplay.server.https.keyStore.password=change_me
After doing this I can hit to the HTTPS URL using server address, but getting errors in server console like,
[error] a.a.OneForOneStrategy - ./myCA_trust.jks
akka.actor.ActorInitializationException: akka://application/system/StreamSupervisor-0/flow-2-1: exception during creation
at akka.actor.ActorInitializationException$.apply(Actor.scala:202)
at akka.actor.ActorCell.create(ActorCell.scala:698)
at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:549)
at akka.actor.ActorCell.systemInvoke(ActorCell.scala:571)
at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:293)
at akka.dispatch.Mailbox.run(Mailbox.scala:228)
at akka.dispatch.Mailbox.exec(Mailbox.scala:241)
at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
Caused by: java.lang.reflect.InvocationTargetException: null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at play.core.server.ssl.ServerSSLEngine$.createScalaSSLEngineProvider(ServerSSLEngine.scala:116)
at play.core.server.ssl.ServerSSLEngine$.createSSLEngineProvider(ServerSSLEngine.scala:39)
at play.core.server.AkkaHttpServer$$anon$4$$anon$5.sslEngineProvider$lzycompute(AkkaHttpServer.scala:527)
at play.core.server.AkkaHttpServer$$anon$4$$anon$5.sslEngineProvider(AkkaHttpServer.scala:526)
at play.core.server.AkkaHttpServer$$anon$4$$anon$5.engineCreateSSLEngine(AkkaHttpServer.scala:528)
at javax.net.ssl.SSLContext.createSSLEngine(SSLContext.java:329)
Caused by: java.nio.file.NoSuchFileException: ./myCA_trust.jks
Please help me to configure HTTPS rest API URL, do let me know if there is anything else I need to add in the code and where.
Thanks and in advance.

wslite SOAPClient.send()

I am using wslite(groovy-wslite-0.8.0.jar) from groovy to call a soap service.
Request: (String) SOAP XML-Request
def client = new SOAPClient(URL)
response = client.send(requestSOAPBody)
The above code was working till today morning and now causing exception without any code changes.
I am getting an exception like:
[Fatal Error] :1:10: DOCTYPE is disallowed when the feature "http://apache.org/xml/features/disallow-doctype-decl" set to true.
wslite.soap.SOAPClientException: 500 Internal Server Error
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:202)
at wslite.soap.SOAPClient.generateSOAPFaultException(SOAPClient.groovy:118)
at wslite.soap.SOAPClient.this$2$generateSOAPFaultException(SOAPClient.groovy)
at wslite.soap.SOAPClient$this$2$generateSOAPFaultException$10.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
at wslite.soap.SOAPClient.send(SOAPClient.groovy:59)
What could be the possible solution for this
Have you tried client.allowDocTypeDeclaration = false before calling send()? It looks like SOAPClient passes this property to XmlSlurper on instanciating it, and it is set to true by default (see SOAPClient.groovy).

SOAP error when calling remote service

My webservice was created using plugin: http://www.symfony-project.org/plugins/ckWebServicePlugin provided for Symfony 1.4
It worked fine on local machine but giving me error when I deploy service to remote server.
This is stack trace:
The server sent HTTP status code 200: OK Stack Trace
com.sun.xml.ws.transport.http.client.HttpTransportPipe.createResponsePacket(HttpTransportPipe.java:277)
com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:228)
com.sun.xml.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:143)
com.sun.xml.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:110)
com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:961)
com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:910)
com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:873)
com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:775)
com.sun.xml.ws.client.Stub.process(Stub.java:429)
com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:168)
com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:119)
com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:102)
com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:151)
com.sun.proxy.$Proxy149.restaurantVerificationDetails(Unknown Source)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:483)
org.netbeans.modules.websvc.manager.ui.ReflectionHelper.callMethodWithParams(ReflectionHelper.java:772)
org.netbeans.modules.websvc.manager.ui.TestWebServiceMethodDlg$MethodTask.run(TestWebServiceMethodDlg.java:744)
java.lang.Thread.run(Thread.java:745)

PAX Exam integration test REST client call to REST service fails with Caused by: java.net.SocketTimeoutException: Read timed out

I have an integration test that injects a rest client into the test class. When that rest client calls a rest service being hosted by the same pax exam test container everything stops for about a minute until I get a long list of Socket Read Timeout exceptions and connection refused exceptions. If I inject a rest client that calls a rest service in another container everything works fine. It almost seems like the rest service isn't given a thread to execute in. If I start up the pax exam container manually I can verify that the rest service has started correctly. And if I inject the OSGi service into the test class everything works correctly. Using PaxExam 3.6 and Apache ServiceMix (4.5.3)
Stack Trace:
2015-04-22 17:10:02,211 | WARN | ion(1)-127.0.0.1 | PhaseInterceptorChain | 123 - org.apache.cxf.cxf-api - 2.6.6 | Interceptor for {http://rest.mediation.velocity.randomness.com/}mediationService has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Could not send Message.
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)[123:org.apache.cxf.cxf-api:2.6.6]
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)[123:org.apache.cxf.cxf-api:2.6.6]
at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:530)[139:org.apache.cxf.cxf-rt-frontend-jaxrs:2.6.6]
at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:205)[139:org.apache.cxf.cxf-rt-frontend-jaxrs:2.6.6]
at com.sun.proxy.$Proxy156.getmediations(Unknown Source)
at com.randomness.velocity.mediation.rest.client.mediationClient.getmediations(mediationClient.java:90)[282:mediation-rest-client:3.1.0.SNAPSHOT]
at com.randomness.velocity.mediation.rest.client.mediationClient.getmediations(mediationClient.java:97)[282:mediation-rest-client:3.1.0.SNAPSHOT]
at com.randomness.velocity.itest.client_management.DataCleanupTests.verifyvelocityClientManagementStarts(DataCleanupTests.java:123)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_75]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_75]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_75]
at java.lang.reflect.Method.invoke(Method.java:606)[:1.7.0_75]
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)[313:org.ops4j.pax.tipi.junit:4.11.0.1]
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)[313:org.ops4j.pax.tipi.junit:4.11.0.1]
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)[313:org.ops4j.pax.tipi.junit:4.11.0.1]
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)[313:org.ops4j.pax.tipi.junit:4.11.0.1]
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)[313:org.ops4j.pax.tipi.junit:4.11.0.1]
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)[313:org.ops4j.pax.tipi.junit:4.11.0.1]
at org.ops4j.pax.exam.invoker.junit.internal.ContainerTestRunner.runChild(ContainerTestRunner.java:67)
at org.ops4j.pax.exam.invoker.junit.internal.ContainerTestRunner.runChild(ContainerTestRunner.java:37)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)[313:org.ops4j.pax.tipi.junit:4.11.0.1]
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)[313:org.ops4j.pax.tipi.junit:4.11.0.1]
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)[313:org.ops4j.pax.tipi.junit:4.11.0.1]
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)[313:org.ops4j.pax.tipi.junit:4.11.0.1]
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)[313:org.ops4j.pax.tipi.junit:4.11.0.1]
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)[313:org.ops4j.pax.tipi.junit:4.11.0.1]
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)[313:org.ops4j.pax.tipi.junit:4.11.0.1]
at org.junit.runner.JUnitCore.run(JUnitCore.java:138)[313:org.ops4j.pax.tipi.junit:4.11.0.1]
at org.ops4j.pax.exam.invoker.junit.internal.JUnitProbeInvoker.invokeViaJUnit(JUnitProbeInvoker.java:124)
at org.ops4j.pax.exam.invoker.junit.internal.JUnitProbeInvoker.findAndInvoke(JUnitProbeInvoker.java:97)
at org.ops4j.pax.exam.invoker.junit.internal.JUnitProbeInvoker.call(JUnitProbeInvoker.java:73)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_75]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_75]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_75]
at java.lang.reflect.Method.invoke(Method.java:606)[:1.7.0_75]
at org.ops4j.pax.exam.rbc.internal.RemoteBundleContextImpl.remoteCall(RemoteBundleContextImpl.java:80)[311:org.ops4j.pax.exam.rbc:3.6.0]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_75]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_75]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_75]
at java.lang.reflect.Method.invoke(Method.java:606)[:1.7.0_75]
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)[:1.7.0_75]
at sun.rmi.transport.Transport$2.run(Transport.java:202)[:1.7.0_75]
at sun.rmi.transport.Transport$2.run(Transport.java:199)[:1.7.0_75]
at java.security.AccessController.doPrivileged(Native Method)[:1.7.0_75]
at sun.rmi.transport.Transport.serviceCall(Transport.java:198)[:1.7.0_75]
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:567)[:1.7.0_75]
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:828)[:1.7.0_75]
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.access$400(TCPTransport.java:619)[:1.7.0_75]
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler$1.run(TCPTransport.java:684)[:1.7.0_75]
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler$1.run(TCPTransport.java:681)[:1.7.0_75]
at java.security.AccessController.doPrivileged(Native Method)[:1.7.0_75]
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:681)[:1.7.0_75]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_75]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_75]
at java.lang.Thread.run(Thread.java:745)[:1.7.0_75]
Caused by: java.net.SocketTimeoutException: SocketTimeoutException invoking https://127.0.0.1:7103/mediation/patient/ff8081814ce1299a014ce142cb410065?materialization=Full: Read timed out
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)[:1.7.0_75]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)[:1.7.0_75]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)[:1.7.0_75]
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)[:1.7.0_75]
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1469)[135:org.apache.cxf.cxf-rt-transports-http:2.6.6]
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1454)[135:org.apache.cxf.cxf-rt-transports-http:2.6.6]
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)[123:org.apache.cxf.cxf-api:2.6.6]
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:659)[135:org.apache.cxf.cxf-rt-transports-http:2.6.6]
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)[123:org.apache.cxf.cxf-api:2.6.6]
... 54 more
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)[:1.7.0_75]
at java.net.SocketInputStream.read(SocketInputStream.java:152)[:1.7.0_75]
at java.net.SocketInputStream.read(SocketInputStream.java:122)[:1.7.0_75]
at sun.security.ssl.InputRecord.readFully(InputRecord.java:442)[:1.7.0_75]
at sun.security.ssl.InputRecord.read(InputRecord.java:480)[:1.7.0_75]
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:934)[:1.7.0_75]
at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:891)[:1.7.0_75]
at sun.security.ssl.AppInputStream.read(AppInputStream.java:102)[:1.7.0_75]
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)[:1.7.0_75]
at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)[:1.7.0_75]
at java.io.BufferedInputStream.read(BufferedInputStream.java:334)[:1.7.0_75]
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687)[:1.7.0_75]
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:633)[:1.7.0_75]
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1324)[:1.7.0_75]
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)[:1.7.0_75]
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338)[:1.7.0_75]
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1606)[135:org.apache.cxf.cxf-rt-transports-http:2.6.6]
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1532)[135:org.apache.cxf.cxf-rt-transports-http:2.6.6]
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1440)[135:org.apache.cxf.cxf-rt-transports-http:2.6.6]
I figured out what was going on. I added an osgi:service to a spring config in the integration test project that exposed the rest client as an osgi service so I could inject the client into the test class. By doing that I created a second service in the osgi container that was advertised via the same interface that the rest service was using to look up the real osgi service implementation. So the rest service was actually getting the rest client injected into it instead of the osgi service impl, this created an infinite loop that finally crashed out and threw tons of connection refused and socket read timeout exceptions to my console. Good stuff