HttpClient not Serializable Exception - apache-httpclient-4.x

I am trying to implement a basic 1 spout - 1 bolt Storm Topology. I have a Storm Bolt to make an HTTP Request using the Apache HttpClient (4.3.1). But, I get the following exception when I run it:
[main] ERROR org.apache.zookeeper.server.NIOServerCnxn - Thread Thread[main,5,main] died
java.lang.RuntimeException: java.io.NotSerializableException: org.apache.http.impl.client.InternalHttpClient
at backtype.storm.utils.Utils.serialize(Utils.java:56)
at backtype.storm.topology.TopologyBuilder.createTopology(TopologyBuilder.java:89)
at app.storm.StormTopology.main(StormTopology.java:26)
Caused by: java.io.NotSerializableException: org.apache.http.impl.client.InternalHttpClient
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1183)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1508)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
at backtype.storm.utils.Utils.serialize(Utils.java:52)
... 2 more
Anyone else seen this? I know Storm itself uses the HTTP Client (4.1.1) internally. I tried to replace the internal library with the 4.3.1 version and I got another error:
Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE
at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<init>(DefaultHttpRequestWriterFactory.java:52)
at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<init>(DefaultHttpRequestWriterFactory.java:56)
at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<clinit>(DefaultHttpRequestWriterFactory.java:46)
at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.<init>(ManagedHttpClientConnectionFactory.java:72)
at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.<init>(ManagedHttpClientConnectionFactory.java:84)
at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.<clinit>(ManagedHttpClientConnectionFactory.java:59)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager$InternalConnectionFactory.<init>(PoolingHttpClientConnectionManager.java:487)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:147)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:136)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:112)
at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:727)
at org.apache.http.impl.client.HttpClients.createDefault(HttpClients.java:58)
at app.storm.bolts.DataFetcherBolt.<init>(DataFetcherBolt.java:34)
at app.storm.StormTopology.main(StormTopology.java:18)

I got my answer from the Google Forum for the Storm project. Here is the link to that post:
https://groups.google.com/forum/#!topic/storm-user/vdfamKeR9Lk
The fix is to instantiate the HttpClient instance in the prepare method of the Bolt class.

Related

java.lang.IllegalStateException: The content of this Observable is already released

I am using Spring web flux + Reactive Couchbase 6.0.
After deploying my code, I am getting below two errors off and on.
First Error:
[QueryEndpoint]: Got error while consuming KeepAliveResponse. java.util.concurrent.TimeoutException: null at rx.internal.operators.OnSubscribeTimeoutTimedWithFallback$TimeoutMainSubscriber.onTimeout(OnSubscribeTimeoutTimedWithFallback.java:166)
Second Error:
java.lang.IllegalStateException: The content of this Observable (queryRow.59645c34-2faf-496f-b0b1-5b63b7f88f6b) is already released. Subscribe earlier or tune the CouchbaseEnvironment#autoreleaseAfter() setting.\n\tat com.couchbase.client.core.utils.UnicastAutoReleaseSubject$OnSubscribeAction.call
I have gone through many similar topics but got confused a bit.
I have below questions:
1: Do the above errors indicate the same issue?
2: If I set autoreleaseAfter and query timeout at CouchbaseEnvironment level, would it solve these errors? If yes does it have any performance implications?
3 : I have gone through this https://forums.couchbase.com/t/n1ql-query-with-adhoc-false-query-runs-into-illegalstateexception-the-content-of-this-observable-is-already-released/11004
here # subhashni indicating that it is a bug and have been resolved.
But I am facing these errors in Couchbase 6.0.
Kindly help me out

Get the true exception class from asmx web service using MSTest

So I have this web service that I am testing using MS Test and I want to get the original exception class which is InvalidOperationException. However whenever I run my test, the exception that I get is the FaultException class (which is the default exception when consuming a web service). I only get the exception in the message property of the exception.
Below is the exception message that I am getting.
`System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: Invalid Entity\n at BL.Lib.WebService.BLWebServiceImpl.UpdateIDNumber(GetUpdateIDNumberRequest idNumberRequest) in [some file]:line 369\n at SSMWebService.Blacklist.BLWebService.BlacklistUpdateIDNumber(GetUpdateIDNumberRequest request) in [some asmx file]:line 132\n --- End of inner exception stack trace ---
Is there a way to get the InvalidOperationException class from the web service?

Spring integration | Service Activator - Error Channel , Exception handling

I have a problem in catching the exceptions in my spring integration application.
Flow of operations in my application.
Http:inbound gateway which receives the request (error-channel defined to my custom error channel)
Service Activator for basic validations (Exceptions which are thrown from here are handled by error-channel defined on the GW)
splitter
Aggregator
Exceptions on my splitter or Aggregator are not handled by my error channel. why?
Steps taken:
I added a chain and included a header enricher and specified an error channel just before the splitter.
After this, any exception on my splitter is handled by my error channel mentioned in the header enricher.
<chain input-channel="invitations">
<header-enricher>
<error-channel ref="failed-invitations" />
</header-enricher>
<int:splitter ref="payloadSplitter" />
</chain>
But the same doesnt work when do the same on my Aggregator. why?
Whenever there is an exception in my code, it retries and gets executed more than one time. why?
I have a "errorChannel" defined which logs the exceptions. it doesnt work.
I know the thread is too old, but I was also facing a similar issue and found I declared error-channel in header-enricher but not provide 'overwrite="true"' as a parameter. And after providing 'overwrite="true"'it is working as needed. I am surprised why spring integration does not provide an overwrite=true by default.
Let us know this is what solution you did in your old code? So everyone can find out the solution for such a scenario.

JAX-RS Client side JSON handling

I am facing an exception on the JAX-RS Client side when I am trying to test JSON data exchange. I am using Jersey 2.10, JDK1.7, Tomcat7.0. Can someone please advise what steps, with examples, that I need to undertake to make this work. I have no ContextResolver, Provider, MessageBodyWriter/Reader configured on the client side as of now.
Following is the exception stack trace,
SEVERE: MessageBodyWriter not found for media type=application/json, type=class org.vedvrat.jaxrs.model.Customer, genericType=class org.vedvrat.jaxrs.model.Customer.
org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyWriter not found for media type=application/json, type=class org.vedvrat.jaxrs.model.Customer, genericType=class org.vedvrat.jaxrs.model.Customer.
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:247)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)
at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1154)
at org.glassfish.jersey.client.ClientRequest.writeEntity(ClientRequest.java:500)
at org.glassfish.jersey.client.HttpUrlConnector._apply(HttpUrlConnector.java:315)
at org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:227)
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:224)
at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:656)
at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:653)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:424)
at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:653)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:413)
at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:322)
at org.vedvrat.jaxrs.client.bbc.six.JSONRequestTest.main(JSONRequestTest.java:40)
You need to register one of the JSON JAX-RS providers. See a chapter dedicated to various JSON providers in Jersey User Guide. Basically, after picking a provider and adding appropriate modules on your class path, you need to register a provider in Jersey runtime, e.g. for Jackson it would be:
Client client = ClientBuilder.newClient().register(JacksonFeature.class);
See also Registering Resources and Providers in Jersey 2 to find out how this concept works.
you have to add genson-1.3.jar, it worked in my case

Grails, Nimble and Blogito

I tried to run the sample application of Nimble 0.2 (blogito) downloaded here but unfortunately I got stuck with 2 major issues:
When running grails run-app, I got 2 times out of 3 the following error :
2009-10-24 14:38:15,198 [main] ERROR context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flowExecutionSnapshotFactory': Cannot resolve reference to bean 'flowRegistry' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flowRegistry': Cannot resolve reference to bean 'flowBuilderServices' while setting bean property 'flowBuilderServices'...
I have also a similar issue on my project running Nimble 0.3-SNAPSHOT
But sometimes, it works (really... I don't know why... it's magical...) So I can use the blogito app until I need to create a local account and I got the following exception:
2009-10-24 14:30:31,846 [4974549#qtp0-4] ERROR view.GroovyPageView - Error processing GroovyPageView: Error executing tag <g:form>: org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException: Error executing tag <n:recaptcharequired>: groovy.lang.MissingPropertyException: No such property:enabled for class: com.megatome.grails.RecaptchaService
So is there anyone here who has ever solved these issues? Do you have any idea about the problems? Do I need to open an issue on Nimble project?
Thx,
Fabien.
If some have encountered the same issue and if you are interested into the solution, I got the answer in another forum.
Here is the link :
http://www.nabble.com/Nimble-and-Blogito-to26038767.html
Fabien