While hitting the url it throws
11:13:11,515 ERROR [org.springframework.boot.web.servlet.support.ErrorPageFilter] (default task-1) Cannot forward to error page for request [/resources/build/index.html] as the response has already been committed. As a result, the response may have the wrong status code. If your application is running on WebSphere Application Server you may be able to resolve this problem by setting com.ibm.ws.webcontainer.invokeFlushAfterService to false: java.io.IOException: UT010029: Stream is closed
Related
My spring boot app has a feign client that POST a payload to external endpoint.
There is requirement to audit all the calls, especially when any errors occurs in calling the endpoint (connection, unauthorized etc), after retry are exhausted. To audit,
need some information from original payload
http status
underlying exception message,
backup original payload for reference
endpoint
I tried below approaches (for error handling), but still unable to find a solution that covers all above
feign Fallbackfactory - it has handle to exception, but unable to effectively capture feign response/original payload
fallbackMethod with resilence4j - here i get access to original payload and exception, but again unable to capture actual response status (401, 503 etc)
CustomErrorDecoder - Here able to get access to feign Response, but then have to map response body (any request body/payload). Also have to map exception
Appreciate any suggestion/ advise?
I am having a hard time in Chaos Monkey For Spring Boot regarding error responses when a user POSTs an invalid (like {"level": -2}update via REST to our actuator endpoint where one can update options of the behavior of CMSB (only positive levels are allowed). In the first image, I set the management.server.port to 8888 and the app port to 8080. When posting a new property to the CMSB REST API I am getting the following response (which is not what we would have expected):
And in case I leave the management port at the same port the same as the app I am getting the following response:
For both cases we would have expected the same error response (the second one). So we're asking us (at CMSB) whether this is an intended behavior of spring boot and if not, what our options are to get around writing our own error response handler in case the management port is different from the app port.
Please note that this is not about the intended behavior of chaos monkey for spring boot but rather about whether this is a spring boot bug or not. In both cases we would like to have a detailed error response so a user knows what's wrong. Under the hood we are using the #Validated annotation in combination with something like this to validate inputs:
#Data
#NoArgsConstructor
#Validated
#JsonInclude(JsonInclude.Include.NON_NULL)
public class AssaultPropertiesUpdate {
#Nullable
#Min(value = 1)
#Max(value = 10000)
private Integer level;
On a side note: in both cases the error message in the logs is correct. But only in the second case is this error message
WARN 4477 --- [nio-8080-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.bind.MethodArgumentNotValidException: Validation failed for argument [0] in public org.springframework.http.ResponseEntity<?> de.codecentric.spring.boot.chaos.monkey.endpoints.ChaosMonkeyRestEndpoint.updateAssaultProperties(de.codecentric.spring.boot.chaos.monkey.endpoints.AssaultPropertiesUpdate): [Field error in object 'assaultPropertiesUpdate' on field 'level': rejected value [-2]; codes [Min.assaultPropertiesUpdate.level,Min.level,Min.java.lang.Integer,Min]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [assaultPropertiesUpdate.level,level]; arguments []; default message [level],1]; default message [must be greater than or equal to 1]] ]
used as the response payload.
Minimal example project: https://github.com/fletchgqc/mediator
Start the project with mvn spring-boot:run. and then do a POST against http://localhost:8080/actuator/chaosmonkey/assaults with the the payload: {"level": -2}. Correct error response should be shown (like in image 2).
Then stop the project, to https://github.com/fletchgqc/mediator/blob/master/src/main/resources/application.properties add management.server.port=8888 and start the app again. Do a POST against http://localhost:8888/actuator/chaosmonkey/assaults with the same payload as before. The wrong error message should appear (like in image 1).
Looks like the spring team fixed it here: https://github.com/spring-projects/spring-boot/issues/21036
AM trying to invoke a spring boot microservice from another application.
Here is my Server code, if any exception occurs
return ResponseEntity.status(HttpStatus.FORBIDDEN)
.body(new com.test.models.ResponseEntity("Tenant details
not found"));
Here is my client code,
ResponseEntity<Object> uploadResponse =
restTemplate.exchange("http://TESTAPPLICATION/v1/object",
HttpMethod.POST, requestEntity, Object.class);
Am getting a response as
Caused by: org.springframework.web.client.HttpClientErrorException: 403 null
If I hit my endpoint from PostMan, am getting proper response message.
But from my client-side application am getting response message as null. Please let me know what is going wrong.
UPDATE:
Screenshot.
Client Responds with INTERNAL_SERVER_ERROR. But from my server iam responding 403.
Whenever I restart hazelcast server, without restarting client in spring boot. I'm getting following error :
03-01-2018 16:44:17.966 [http-nio-8080-exec-7] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet].log - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is com.hazelcast.client.HazelcastClientNotActiveException: Partition does not have owner. partitionId : 203] with root cause
java.io.IOException: Partition does not have owner. partitionId : 203
at com.hazelcast.client.spi.impl.ClientSmartInvocationServiceImpl.invokeOnPartitionOwner(ClientSmartInvocationServiceImpl.java:43)
at com.hazelcast.client.spi.impl.ClientInvocation.invokeOnSelection(ClientInvocation.java:142)
at com.hazelcast.client.spi.impl.ClientInvocation.invoke(ClientInvocation.java:122)
at com.hazelcast.client.spi.ClientProxy.invokeOnPartition(ClientProxy.java:152)
at com.hazelcast.client.spi.ClientProxy.invoke(ClientProxy.java:147)
at com.hazelcast.client.proxy.ClientMapProxy.getInternal(ClientMapProxy.java:245)
at com.hazelcast.client.proxy.ClientMapProxy.get(ClientMapProxy.java:240)
at com.hazelcast.spring.cache.HazelcastCache.lookup(HazelcastCache.java:139)
at com.hazelcast.spring.cache.HazelcastCache.get(HazelcastCache.java:57)
at org.springframework.cache.interceptor.AbstractCacheInvoker.doGet(AbstractCacheInvoker.java:71)
If I enabled hot-restart, the issue is solved. But is there a way to resume client application without restarting it and hot-restart is disabled ?
Hazelcast client tries to reconnect to the cluster if the connection drops. It uses ClientNetworkConfig.connectionAttemptLimit and ClientNetworkConfig.connectionAttemptPeriod elements to configure how frequently it will try. connectionAttemptLimit defines the number of attempts on a disconnection and connectionAttemptPeriod defines the period between two retries in ms. Please see the usage example below:
ClientConfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig().setConnectionAttemptLimit(5);
clientConfig.getNetworkConfig().setConnectionAttemptPeriod(5000);
Starting with Hazelcast 3.9, you can use reconnect-mode property to configure how the client will reconnect to the cluster after it disconnects. It has three options:
The option OFF disables the reconnection.
ON enables reconnection in a blocking manner where all the waiting invocations will be blocked until a cluster connection is established or failed.
The option ASYNC enables reconnection in a non-blocking manner where all the waiting invocations will receive a HazelcastClientOfflineException.
Its default value is ON. You can see a configuration example below:
ClientConfig clientConfig = new ClientConfig();
clientConfig.getConnectionStrategyConfig()
.setReconnectMode(ClientConnectionStrategyConfig.ReconnectMode.ON);
By using these configuration elements, you can resume your client without restarting it.
Hi i am following below link .
http://oozie.apache.org/docs/4.0.0/AG_Install.html#Notifications_Configuration
i have done all the configuration in cdh as said in the above link and restarted the oozie
Now for consumer application i have simple java main class for test purpose
code snippet
OozieClient oc = new OozieClient("ooziebaseurl:11000/oozie");
JMSConnectionInfo jmsInfo = oc.getJMSConnectionInfo();
Properties jndiProperties = jmsInfo.getJNDIProperties();
Context jndiContext = new InitialContext(jndiProperties);
while getting JMSConnectionInfo i am having below exception
Exception in thread "main" E1601 : E1601: Cannot retrieve JMS connection info [JMSTopicService is not initialized. JMS notificationmay not be enabled]
at org.apache.oozie.client.OozieClient.handleError(OozieClient.java:508)
at org.apache.oozie.client.OozieClient$JMSInfo.call(OozieClient.java:757)
at org.apache.oozie.client.OozieClient$JMSInfo.call(OozieClient.java:744)
at org.apache.oozie.client.OozieClient$ClientCallable.call(OozieClient.java:479)
at org.apache.oozie.client.OozieClient.getJMSConnectionInfo(OozieClient.java:800)
at com.oozie.jms.OozieJMSClient.main(OozieJMSClient.java:25)
few more info while debug i found that it is trying to call
http://IP:11000/oozie/v2/admin/jmsinfo
Which says 404
when i try to hit in the browser it says
HTTP STATUS 404
The request sent by the client was syntactically incorrect.
one more curious thing for me is as per link
http://oozie.apache.org/docs/4.0.1/WebServicesAPI.html
Admin End-Point
This endpoint is for obtaining Oozie system status and configuration information.
It supports the following sub-resources: status, os-env, sys-props, configuration, instrumentation, systems, available-timezones .
then why /jmsinfo is getting as a rest call ?
please suggest me. Thanks
The above is solved it was my bad. After restart the oozie with correctly updating the notification configuration it is done. Now CDH is also showing those services in the web console.