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

Missing Scala Classpath #2

Open
slyons opened this issue Feb 6, 2019 · 4 comments
Open

Missing Scala Classpath #2

slyons opened this issue Feb 6, 2019 · 4 comments

Comments

@slyons
Copy link

slyons commented Feb 6, 2019

Running the examples from the GitHub repo from Flink 1.7.1 results in the following error:

Starting execution of program
java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: scala/runtime/java8/JFunction1$mcVI$sp
	at io.github.streamingwithflink.chapter1.AverageSensorReadings$$anon$5.createSerializer(AverageSensorReadings.scala:50)
	at org.apache.flink.streaming.api.datastream.WindowedStream.apply(WindowedStream.java:1108)
	at org.apache.flink.streaming.api.datastream.WindowedStream.apply(WindowedStream.java:1040)
	at org.apache.flink.streaming.api.scala.WindowedStream.apply(WindowedStream.scala:582)
	at io.github.streamingwithflink.chapter1.AverageSensorReadings$.main(AverageSensorReadings.scala:57)
	at io.github.streamingwithflink.chapter1.AverageSensorReadings.main(AverageSensorReadings.scala)
	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:498)
	at org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:529)
	at org.apache.flink.client.program.PackagedProgram.invokeInteractiveModeForExecution(PackagedProgram.java:421)
	at org.apache.flink.client.program.ClusterClient.run(ClusterClient.java:427)
	at org.apache.flink.client.cli.CliFrontend.executeProgram(CliFrontend.java:813)
	at org.apache.flink.client.cli.CliFrontend.runProgram(CliFrontend.java:287)
	at org.apache.flink.client.cli.CliFrontend.run(CliFrontend.java:213)
	at org.apache.flink.client.cli.CliFrontend.parseParameters(CliFrontend.java:1050)
	at org.apache.flink.client.cli.CliFrontend.lambda$main$11(CliFrontend.java:1126)
	at java.security.AccessController.doPrivileged(Native Method)
	at javax.security.auth.Subject.doAs(Subject.java:422)
	at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1754)
	at org.apache.flink.runtime.security.HadoopSecurityContext.runSecured(HadoopSecurityContext.java:41)
	at org.apache.flink.client.cli.CliFrontend.main(CliFrontend.java:1126)
Caused by: java.lang.NoClassDefFoundError: scala/runtime/java8/JFunction1$mcVI$sp
	... 23 more
Caused by: java.lang.ClassNotFoundException: scala.runtime.java8.JFunction1$mcVI$sp
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 23 more

I've tried re-running it but adding the --classpath argument but it still doesn't work.

./bin/flink run --classpath "file:///opt/dev/learn/scala-2.11.12/lib/scala-library.jar" -c io.github.streamingwithflink.chapter1.AverageSensorReadings examples-scala.jar
@duynguyenhoang
Copy link

Complied package using Scala 1.12, please check that your Scala version to make they are the same.

@wudi24k
Copy link

wudi24k commented Mar 10, 2019

Complied package using Scala 1.12, please check that your Scala version to make they are the same.

Can you please complied package using Scala 2.12? Sorry, I'm a so much newer for flink

@St3S0f
Copy link

St3S0f commented Apr 10, 2019

I built the library example jar form master:
https://github.com/streaming-with-flink/examples-scala

When I try and execute the first book example:

flink run -C file:///home/linuxbrew/.linuxbrew/Cellar/scala/2.12.8/idea/lib/scala-library.jar -c io.github.streamingwithflink.chapter1.AverageSensorReadings target/examples-scala_2.12-1.0.jar

It fails with:

forg.apache.flink.client.program.ProgramInvocationException: Job failed. (JobID: 7cebd5ea6598ba3a0609f3b41116b27c)
	at org.apache.flink.client.program.rest.RestClusterClient.submitJob(RestClusterClient.java:268)
	at org.apache.flink.client.program.ClusterClient.run(ClusterClient.java:487)
	at org.apache.flink.streaming.api.environment.StreamContextEnvironment.execute(StreamContextEnvironment.java:66)
	at org.apache.flink.streaming.api.scala.StreamExecutionEnvironment.execute(StreamExecutionEnvironment.scala:654)
	at io.github.streamingwithflink.chapter1.AverageSensorReadings$.main(AverageSensorReadings.scala:63)
	at io.github.streamingwithflink.chapter1.AverageSensorReadings.main(AverageSensorReadings.scala)
	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:498)
	at org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:529)
	at org.apache.flink.client.program.PackagedProgram.invokeInteractiveModeForExecution(PackagedProgram.java:421)
	at org.apache.flink.client.program.ClusterClient.run(ClusterClient.java:427)
	at org.apache.flink.client.cli.CliFrontend.executeProgram(CliFrontend.java:813)
	at org.apache.flink.client.cli.CliFrontend.runProgram(CliFrontend.java:287)
	at org.apache.flink.client.cli.CliFrontend.run(CliFrontend.java:213)
	at org.apache.flink.client.cli.CliFrontend.parseParameters(CliFrontend.java:1050)
	at org.apache.flink.client.cli.CliFrontend.lambda$main$11(CliFrontend.java:1126)
	at java.security.AccessController.doPrivileged(Native Method)
	at javax.security.auth.Subject.doAs(Subject.java:422)
	at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1754)
	at org.apache.flink.runtime.security.HadoopSecurityContext.runSecured(HadoopSecurityContext.java:41)
	at org.apache.flink.client.cli.CliFrontend.main(CliFrontend.java:1126)
Caused by: org.apache.flink.runtime.client.JobExecutionException: Job execution failed.
	at org.apache.flink.runtime.jobmaster.JobResult.toJobExecutionResult(JobResult.java:146)
	at org.apache.flink.client.program.rest.RestClusterClient.submitJob(RestClusterClient.java:265)
	... 22 more
Caused by: java.lang.NoSuchMethodError: scala.Product.$init$(Lscala/Product;)V
	at io.github.streamingwithflink.util.SensorReading.(SensorReading.scala:19)
	at io.github.streamingwithflink.util.SensorSource.$anonfun$run$3(SensorSource.scala:61)
	at io.github.streamingwithflink.util.SensorSource.$anonfun$run$3$adapted(SensorSource.scala:61)
	at scala.collection.Iterator$class.foreach(Iterator.scala:891)
	at scala.collection.AbstractIterator.foreach(Iterator.scala:1334)
	at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
	at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
	at io.github.streamingwithflink.util.SensorSource.run(SensorSource.scala:61)
	at org.apache.flink.streaming.api.operators.StreamSource.run(StreamSource.java:94)
	at org.apache.flink.streaming.api.operators.StreamSource.run(StreamSource.java:58)
	at org.apache.flink.streaming.runtime.tasks.SourceStreamTask.run(SourceStreamTask.java:99)
	at org.apache.flink.streaming.runtime.tasks.StreamTask.invoke(StreamTask.java:300)
	at org.apache.flink.runtime.taskmanager.Task.run(Task.java:704)
	at java.lang.Thread.run(Thread.java:748)

@jhsbeat
Copy link

jhsbeat commented Sep 13, 2021

I've successfully ran the example by using example-java code as input jar.

  1. Cloned the project https://github.com/streaming-with-flink/examples-java.git
  2. Build & package a jar file (ref. https://www.jetbrains.com/help/idea/compiling-applications.html#package_into_jar)
  3. Run the command that points packaged jar file on step 2. (e.g. ./bin/flink run -c io.github.streamingwithflink.chapter1.AverageSensorReadings /{path}/{to}/{examples-java}/out/artifacts/examples_java_jar/examples-java.jar)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants