No valid constructor
See original GitHub issueFirst of all: thanks for this awesome library! I hope it finds its way into core Scala proper 😃
I’m having some issues with enums that override entryName
when I use them together with Spark. I think the problem is in deserializing enums. This is the relevant enum code:
sealed abstract class PhBoardingStatus(override val entryName: String) extends EnumEntry
object PhBoardingStatus extends Enum[PhBoardingStatus] {
val values: IndexedSeq[PhBoardingStatus] = findValues
case object All extends PhBoardingStatus("ALL")
case object Closed extends PhBoardingStatus("BC")
case object Ignored extends PhBoardingStatus("BI")
case object NotOpen extends PhBoardingStatus("BN")
case object Open extends PhBoardingStatus("BO")
case object Suspended extends PhBoardingStatus("BS")
}
When using this enum in Spark code, this stacktrace gets thrown:
2017-05-16 09:22:37 WARN org.apache.spark.scheduler.TaskSetManager:66 - Lost task 0.0 in stage 17.0 (TID 33, kl1393d4.is.klmcorp.net): java.io.InvalidClassException: com.klm.flight720.dataSources.ph.PhBoardingStatus$Closed$; no valid constructor
at java.io.ObjectStreamClass$ExceptionInfo.newInvalidClassException(ObjectStreamClass.java:150)
at java.io.ObjectStreamClass.checkDeserialize(ObjectStreamClass.java:790)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1775)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2000)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1924)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2000)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1924)
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 org.apache.spark.serializer.JavaDeserializationStream.readObject(JavaSerializer.scala:75)
at org.apache.spark.serializer.DeserializationStream.readValue(Serializer.scala:159)
at org.apache.spark.serializer.DeserializationStream$$anon$2.getNext(Serializer.scala:189)
at org.apache.spark.serializer.DeserializationStream$$anon$2.getNext(Serializer.scala:186)
...
I assume this is because our abstract class only has a cosntructor with 1 argument, and no no-args constructor. Any idea how I can solve this?
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
java.io.InvalidClassException: no valid constructor
An object is serializable (itself implements the Serializable interface) even if its superclass is not. However, the first superclass in the ...
Read more >java.io.InvalidClassException: no valid constructor
When this InvalidClassException:no valid constructor is thrown? This type of exception is thrown when inheritance is involved in the program.
Read more >Getting java.io.InvalidClassException (no valid constructor ...
Hi,. case objects are still objects (i.e. not static), so they will be serialized. Are you sure that java.awt.Color is serializable? If not...
Read more >No Valid constructor error, even with default constuctor
Hi all, The following code is giving me the error: java.io.InValidClassException: test; test; no valid constructor.
Read more >Sporadic java.io.InvalidClassException: no valid constructor ...
Version 7.1.2 corrects an issue in PingFederate v7.1.1 with artifact binding in clustered deployments that resulted in sporadic failed transactions.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve added this in the sealed abstract class instead, which I find less verbose and seems to work fine too:
Yet I’m not familiar enough with this to understand why we need this no-param constructor and if it could be fixed directly in the EnumEntry…
I think
case object
s already extendSerializable
by default, so the problem might be as you said; the lack of a no-args constructor on the parent.Perhaps something like this could work?