Recently, I was doing real-time data analysis and used Twitter's open-source storm. during initialization, I reported a serialization error:
Java. Lang. runtimeexception: Java. Io. notserializableexception: org. joda. Time. format. datetimeformatter
The error message is obvious because datetimeformatter does not support serialization. But I only used this time class in bolt, so I won't report an error during initialization?
I searched the internet for the reason because of the working mechanism of storm. After you start a topology, the supervisor initializes the bolt and sends it to the worker. Then, the supervisor calls the bolt prepare () method. OK. It can be seen from this that the serialization is involved in the step sent to bolt, so an error is reported.
The solution is that sending data from the supervisor to bolt does not initialize the datetimeformatter class. You can declare the relevant object first, and then wait for the data to be sent to the worker () to avoid this problem. Below is a line from Google:
The supervisor instantiates the bolts, sends them to the workers, and then CILS prepare () on all of them. Therefore, anything
That isn't serializable that is instantiated before prepare () causes this process to fail.