Today, a colleague suddenly reported such an error. At first, he really didn’t react. Member variables can’t be serialized….
Exception in thread "main" org.apache.flink.api.common.InvalidProgramException: java.lang.ref.ReferenceQueue$Lock@11fc564b is not serializable. The object probably contains or references non serializable fields.
at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:151)
at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:126)
at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:126)
at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:126)
at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:126)
at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:126)
at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:71)
at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.clean(StreamExecutionEnvironment.java:1821)
at org.apache.flink.streaming.api.datastream.DataStream.clean(DataStream.java:188)
at org.apache.flink.streaming.api.datastream.KeyedStream.process(KeyedStream.java:398)
at org.apache.flink.streaming.api.datastream.KeyedStream.process(KeyedStream.java:374)
at com.xintujing.flinkdemo.text.UserCount_3.main(UserCount_3.java:53)
Caused by: java.io.NotSerializableException: java.lang.ref.ReferenceQueue$Lock
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
at org.apache.flink.util.InstantiationUtil.serializeObject(InstantiationUtil.java:586)
at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:133)
... 11 more
When you see this error, you are in an ignorant state and cannot be serialized. What do you mean?
First, analyze the problem. He tells us that a class cannot be serialized,
What happens if a member in a class does not implement a serializable interface?A simple question about the Java serialization process. If you try to serialize an object that implements a serializable class, but the object contains a reference to a non serializable class, a non serializable exception notserializableexception will be thrown at run time,
Well, if you take an object as a member variable of another object, all member variables of the object must be serializable. If the member variables cannot be serialized, this error will be reported. So. Don’t treat non serializable things as member variables.
Read More:
- [Solved] org.apache.flink.client.program.ProgramInvocationException: The main method caused an error
- How to Solve Flick operate Error: not serialized
- Java uses single thread pool to realize multi thread sequential execution (non alternating, non synchronous)
- How to Fix flink OutputTag Error
- [How to Solve] Java nested object @validated is not valid
- [Solved] Flink1.12 integrate Hadoop 3.X error: java.lang.RuntimeException…
- org.hibernate.exception.SQLGrammarException: could not extract ResultSet, Resolve MySQL 5.7.5 or above GROUP_BY is not supported
- [Solved] write javaBean error, fastjson version 1.2.76, class org.apache.flink.table.data.binary
- Monitoring session to determine whether the user is online or not
- [Solved] Error getting generated key or setting result to parameter object. UnsupportedOperationException
- Mapper.xml Error: Error setting non null for parameter #3 with JdbcType null.
- [Solved] Error resolving template [x] template might not exist or might not be accessible by any of the con
- Springboot integrates Redis annotation and access error: java.io.NotSerializableException: com.demo.entity.MemberEntity
- Request processing failed; nested exception is java.lang.NullPointerException or UnsatisfiedDependencyE
- [Solved] Error occurred during initialization of VM Could not reserve enough space for object heap
- [Solved] Kafka Error: is/are not present and missingTopicsFatal is true
- Java Running Error: Could not find or load main class
- How to Solve ERROR: Java 1.7 or later is required to run Apache Drill
- [Solved] Error occurred during initialization of VM Could not reserve enough space for 1572864KB object heap