java.io.IOException: unexpected exception type

Stack Overflow | alexgbelov | 2 months ago
  1. 0

    Deserialization errors in Spark cluster although all objects implement Serializable

    Stack Overflow | 2 months ago | alexgbelov
    java.io.IOException: unexpected exception type
  2. 0

    GridCompute.[affinity]call() with Java8 lambda Callable throws ClassNotFoundException: MyClass$2$$Lambda$2/1166785921

    GitHub | 2 years ago | ceefour
    org.gridgain.grid.GridException: Failed to deserialize object with given class loader: sun.misc.Launcher$AppClassLoader@73d16e93 For more information see: Troubleshooting: http://bit.ly/GridGain-Troubleshooting Documentation Center: http://bit.ly/GridGain-Documentation
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    "Invalid lambda deserialization" when lambda used for interface implementation

    Stack Overflow | 2 years ago
    java.lang.IllegalArgumentException: Invalid lambda deserialization
  5. 0

    FULL PRODUCT VERSION : java version "1.8.0" Java(TM) SE Runtime Environment (build 1.8.0-b132) Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode) ADDITIONAL OS VERSION INFORMATION : OS X 10.9.3 A DESCRIPTION OF THE PROBLEM : The code below causes a 'java.lang.IllegalArgumentException: Invalid lambda deserialization' exception. If the commented code is uncommented, the code works. It seems that there is a problem with the serialization of lambdas that use attributes from the enclosing class. public class Main implements Serializable { private String text = "Hello!"; private Supplier<String> textSupplier; public Main() { textSupplier = (Supplier<String> & Serializable) () -> this.text; // Main main = this; // textSupplier = (Supplier<String> & Serializable) () -> main.text; } @Override public String toString() { return textSupplier.get(); } public static void main(String[] args) throws Exception { try (ByteArrayOutputStream buffer = new ByteArrayOutputStream()) { try (ObjectOutputStream out = new ObjectOutputStream(buffer)) { out.writeObject(new Main()); } try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()))) { System.out.println(in.readObject()); } } } } Full stack trace: Exception in thread "main" java.io.IOException: unexpected exception type at java.io.ObjectStreamClass.throwMiscException(ObjectStreamClass.java:1538) at java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:1110) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1810) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371) at j8serialization.Main.main(Main.java:29) Caused by: java.lang.reflect.InvocationTargetException 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:483) at java.lang.invoke.SerializedLambda.readResolve(SerializedLambda.java:230) 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:483) at java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:1104) ... 8 more Caused by: java.lang.IllegalArgumentException: Invalid lambda deserialization at j8serialization.Main.$deserializeLambda$(Main.java:1) ... 18 more STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Run this code: public class Main implements Serializable { private String text = "Hello!"; private Supplier<String> textSupplier; public Main() { // String text = this.text; textSupplier = (Supplier<String> & Serializable) () -> text; } @Override public String toString() { return textSupplier.get(); } public static void main(String[] args) throws Exception { try (ByteArrayOutputStream buffer = new ByteArrayOutputStream()) { try (ObjectOutputStream out = new ObjectOutputStream(buffer)) { out.writeObject(new Main()); } try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()))) { System.out.println(in.readObject()); } } } } EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - Should print 'Hello!' to the console. ACTUAL - An exception is thrown when trying to deserialize the object: Exception in thread "main" java.io.IOException: unexpected exception type at java.io.ObjectStreamClass.throwMiscException(ObjectStreamClass.java:1538) at java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:1110) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1810) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371) at j8serialization.Main.main(Main.java:29) Caused by: java.lang.reflect.InvocationTargetException 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:483) at java.lang.invoke.SerializedLambda.readResolve(SerializedLambda.java:230) 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:483) at java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:1104) ... 8 more Caused by: java.lang.IllegalArgumentException: Invalid lambda deserialization at j8serialization.Main.$deserializeLambda$(Main.java:1) ... 18 more ERROR MESSAGES/STACK TRACES THAT OCCUR : java.lang.IllegalArgumentException: Invalid lambda deserialization REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- public class Main implements Serializable { private String text = "Hello!"; private Supplier<String> textSupplier; public Main() { textSupplier = (Supplier<String> & Serializable) () -> this.text; // Main main = this; // textSupplier = (Supplier<String> & Serializable) () -> main.text; } @Override public String toString() { return textSupplier.get(); } public static void main(String[] args) throws Exception { try (ByteArrayOutputStream buffer = new ByteArrayOutputStream()) { try (ObjectOutputStream out = new ObjectOutputStream(buffer)) { out.writeObject(new Main()); } try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()))) { System.out.println(in.readObject()); } } } } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : Declare a local reference to 'this', and use it instead.

    JDK Bug System | 3 years ago | Webbug Group
    java.io.IOException: unexpected exception type

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalArgumentException

      Invalid lambda deserialization

      at com.mypackage.MyApp.$deserializeLambda$()
    2. com.mypackage
      MyApp.$deserializeLambda$
      1. com.mypackage.MyApp.$deserializeLambda$(MyApp.java:27)
      1 frame
    3. Java RT
      ObjectInputStream.readObject
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      4. java.lang.reflect.Method.invoke(Method.java:498)
      5. java.lang.invoke.SerializedLambda.readResolve(SerializedLambda.java:230)
      6. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      7. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      8. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      9. java.lang.reflect.Method.invoke(Method.java:498)
      10. java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:1148)
      11. java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1810)
      12. java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
      13. java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2000)
      14. java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1924)
      15. java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
      16. java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
      17. java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2000)
      18. java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1924)
      19. java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
      20. java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
      21. java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2000)
      22. java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1924)
      23. java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
      24. java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
      25. java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2000)
      26. java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1924)
      27. java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
      28. java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
      29. java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
      29 frames
    4. Spark
      Executor$TaskRunner.run
      1. org.apache.spark.serializer.JavaDeserializationStream.readObject(JavaSerializer.scala:72)
      2. org.apache.spark.serializer.JavaSerializerInstance.deserialize(JavaSerializer.scala:98)
      3. org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:61)
      4. org.apache.spark.scheduler.Task.run(Task.scala:88)
      5. org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:214)
      5 frames
    5. Java RT
      Thread.run
      1. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      2. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      3. java.lang.Thread.run(Thread.java:745)
      3 frames