Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xgboost: Caused by: java.lang.ClassNotFoundException: scala.Serializable #11832

Closed
toktarev opened this issue Dec 21, 2019 · 9 comments
Closed

xgboost: Caused by: java.lang.ClassNotFoundException: scala.Serializable #11832

toktarev opened this issue Dec 21, 2019 · 9 comments

Comments

@toktarev
Copy link

@toktarev toktarev commented Dec 21, 2019

Tried to switch my project on java11.

I use xgboost (https://github.com/dmlc/xgboost) and scala inside, however
it failed with

        at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: java.lang.ClassNotFoundException: scala.Serializable
        at jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) ~[?:?]
        at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[?:?]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[?:?]

Is this scala's bug or I need to add some configuration parameters for JVM args ?
i use scala 2.13.1

@toktarev toktarev mentioned this issue Dec 21, 2019
0 of 3 tasks complete
@SethTisue

This comment has been minimized.

Copy link
Member

@SethTisue SethTisue commented Dec 21, 2019

scala.Serializable doesn't exist in Scala 2.13 except as a compile-time type alias; but it did exist in earlier Scala versions:

scala 2.12.10> classOf[scala.Serializable]
res0: Class[Serializable] = interface scala.Serializable

scala 2.13.1> classOf[scala.Serializable]
res0: Class[Serializable] = interface java.io.Serializable

So this error you are getting appears to be caused by using Scala 2.13 to run code that was compiled by some earlier Scala version. Is that possible?

Also, checking: are you saying that exact same thing worked on Java 8, but then when you changed nothing except switching to JDK 11, it stopped working? Or do you just happen to be on JDK 11, and you have a general suspicion that's relevant? Offhand, I don't see any this way the JDK version could matter here (though perhaps I'll be proved wrong as we dig deeper).

@SethTisue

This comment has been minimized.

Copy link
Member

@SethTisue SethTisue commented Dec 21, 2019

at search.maven.org I see xgboost-jvm_2.11 artifacts but no xgboost-jvm_2.12 or xgboost-jvm_2.13 artifacts, so that tends to indicate that xgboost requires Scala 2.11 specifically

@toktarev

This comment has been minimized.

Copy link
Author

@toktarev toktarev commented Dec 21, 2019

What is correct replacement for such code in scala 2.13.1 ?

package ml.dmlc.xgboost4j

/**
 * Labeled training data point.
 *
 * @param label Label of this point.
 * @param indices Feature indices of this point or `null` if the data is dense.
 * @param values Feature values of this point.
 * @param weight Weight of this point.
 * @param group Group of this point (used for ranking) or -1.
 * @param baseMargin Initial prediction on this point or `Float.NaN`
 */
case class LabeledPoint(
    label: Float,
    indices: Array[Int],
    values: Array[Float],
    weight: Float = 1f,
    group: Int = -1,
    baseMargin: Float = Float.NaN) extends Serializable {
  require(indices == null || indices.length == values.length,
    "indices and values must have the same number of elements")

  def this(label: Float, indices: Array[Int], values: Array[Float]) = {
    // [[weight]] default duplicated to disambiguate the constructor call.
    this(label, indices, values, 1.0f)
  }
}

I can't use

extends Serializable

in last Scala version ?

@toktarev

This comment has been minimized.

Copy link
Author

@toktarev toktarev commented Dec 21, 2019

---So this error you are getting appears to be caused by using Scala 2.13 to run code that was compiled by some earlier Scala version. Is that possible?

I compile xgboost source code together with all project.
I don't use maven xgboost

@toktarev

This comment has been minimized.

Copy link
Author

@toktarev toktarev commented Dec 21, 2019

--- Also, checking: are you saying that exact same thing worked on Java 8,
Yes, but with previous scala verion

---- but then when you changed nothing except switching to JDK 11, it stopped working?

It stopped working after switching to JDK11
After that I changed scala version on 2.13 and obtained corresponding error.

@toktarev

This comment has been minimized.

Copy link
Author

@toktarev toktarev commented Dec 21, 2019

I see

which means that code that typechecks may incur linkage errors at runtime
Here:

JDK 11 compatibility notes
Although the table above jumps from 8 to 11, JDK 9 and 10 will probably also work wherever 11 does. But unlike 9 and 10, 11 is an LTS release, so 11 is what we actually test on and recommend.
As of Scala 2.13.0, 2.12.8 and 2.11.12, JDK 11 support is incomplete. Notably, scalac will not enforce the restrictions of the Java Platform Module System, which means that code that typechecks may incur linkage errors at runtime. Scala 2.13.x will eventually provide rudimentary support for this, but likely only in nightlies built on Java 11.
JDK 11 support requires minimum sbt version 1.1.0, or 0.13.17 in the 0.13.x series.
To track progress on JDK 11 compatibility, watch:
the "Support JDK 11" issue
the jdk11 label in scala/bug
To help with testing on JDK 11, see scala/scala-dev#559.

Do we observe described bug ?

@toktarev

This comment has been minimized.

Copy link
Author

@toktarev toktarev commented Dec 21, 2019

---that was compiled by some earlier Scala version

How can I know which scala version will be used during compilation.

I don't have scala command at all on my laptop

@SethTisue

This comment has been minimized.

Copy link
Member

@SethTisue SethTisue commented Dec 21, 2019

please use https://users.scala-lang.org for questions. I don't think we have any Scala bugs here — perhaps you'll eventually uncover one, but you're not there yet

@SethTisue SethTisue closed this Dec 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.