ging / fiware-cosmos-orion-flink-connector-examples

Code examples for getting started with Flink Orion Connector
https://fiware-cosmos-flink-examples.readthedocs.io
MIT License
1 stars 2 forks source link

Problems compiling Jar with Maven #3

Closed gedoensmax closed 4 years ago

gedoensmax commented 5 years ago

I am not able to compile my very simple test for orion flink connector with mvn package command. I haven't used maven before nor java. Below is my scala file which is located at path src/main/scala/org/fiware/cosmos/orion/flink/connector/examples/StreamProcessing.scala

package org.fiware.cosmos.orion.flink.connector.examples

import org.apache.flink.streaming.api.scala.{StreamExecutionEnvironment, _}
import org.apache.flink.streaming.api.windowing.time.Time
import org.fiware.cosmos.orion.flink.connector._

object StreamProcessing {
  final val URL_CB = "http://orion:1026/v2/entities/"
  final val CONTENT_TYPE = ContentType.JSON
  final val METHOD = HTTPMethod.POST

  def main(args: Array[String]): Unit = {
    val env = StreamExecutionEnvironment.getExecutionEnvironment

    // Create Orion Source. Receive notifications on port 9001
    val eventStream = env.addSource(new OrionSource(9001))

    // Process event stream
    val processedDataStream = eventStream
      .flatMap(event => event.entities)
      .map(entity => {
        val usage = entity.attrs("sp").value.asInstanceOf[Number].floatValue()
        val produce = entity.attrs("sgp").value.asInstanceOf[Number].floatValue() + entity.attrs("pqp").value.asInstanceOf[Number].floatValue()
        val power = usage - produce
        new Ext_Power_Node(
          entity.id,
          power)
      })
      .keyBy("id")
      .timeWindow(Time.seconds(5), Time.seconds(2))
      .min("temperature")
      .map(pwNode => {
        val url = URL_CB + pwNode.id + "/attrs"
        OrionSinkObject(pwNode.toString, url, CONTENT_TYPE, METHOD)
      })

    // Add Orion Sink
    OrionSink.addSink( processedDataStream )

    // print the results with a single thread, rather than in parallel
    processedDataStream.map(orionSinkObject => orionSinkObject.content).print().setParallelism(1)
    env.execute("FIWARE Cosmos Example")
  }

  case class Ext_Power_Node(id: String, power: Float) extends  Serializable {
    override def toString :String = { "{\"max_external_power\": { \"value\":" + power + ", \"type\": \"Float\"}}" }
  }
}

Furthermore i am using the exact same pom.xml that is used in this repository. I get this error frommaven -X package:

[INFO] /home/maxmueller/Documents/orion-flink/src/main/scala:-1: info: compiling
[INFO] Compiling 1 source files to /home/maxmueller/Documents/orion-flink/target/classes at 1574857403547
[DEBUG] use java command with args in file forced : false
[DEBUG] plugin jar to add :/home/maxmueller/.m2/repository/net/alchim31/maven/scala-maven-plugin/3.2.2/scala-maven-plugin-3.2.2.jar
[DEBUG] cmd:  /usr/lib/jvm/java-11-openjdk-amd64/bin/java -Xbootclasspath/a:/home/maxmueller/.m2/repository/org/scala-lang/scala-library/2.11.12/scala-library-2.11.12.jar:/home/maxmueller/.m2/repository/org/scala-lang/scala-compiler/2.11.12/scala-compiler-2.11.12.jar:/home/maxmueller/.m2/repository/org/scala-lang/modules/scala-xml_2.11/1.0.5/scala-xml_2.11-1.0.5.jar:/home/maxmueller/.m2/repository/org/scala-lang/scala-library/2.11.6/scala-library-2.11.6.jar:/home/maxmueller/.m2/repository/org/scala-lang/scala-reflect/2.11.12/scala-reflect-2.11.12.jar:/home/maxmueller/.m2/repository/org/scala-lang/modules/scala-parser-combinators_2.11/1.0.4/scala-parser-combinators_2.11-1.0.4.jar:/home/maxmueller/.m2/repository/org/scala-lang/scala-library/2.11.7/scala-library-2.11.7.jar -classpath /home/maxmueller/.m2/repository/net/alchim31/maven/scala-maven-plugin/3.2.2/scala-maven-plugin-3.2.2.jar scala_maven_executions.MainWithArgsInFile scala.tools.nsc.Main /tmp/scala-maven-11926024092897349869.args
[ERROR] error: java.lang.NoClassDefFoundError: javax/tools/ToolProvider
[INFO]  at scala.reflect.io.JavaToolsPlatformArchive.iterator(ZipArchive.scala:301)
[INFO]  at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
[INFO]  at scala.reflect.io.AbstractFile.foreach(AbstractFile.scala:92)
[INFO]  at scala.tools.nsc.util.DirectoryClassPath.traverse(ClassPath.scala:277)
[INFO]  at scala.tools.nsc.util.DirectoryClassPath.x$15$lzycompute(ClassPath.scala:299)
[INFO]  at scala.tools.nsc.util.DirectoryClassPath.x$15(ClassPath.scala:299)
[INFO]  at scala.tools.nsc.util.DirectoryClassPath.packages$lzycompute(ClassPath.scala:299)
[INFO]  at scala.tools.nsc.util.DirectoryClassPath.packages(ClassPath.scala:299)
[INFO]  at scala.tools.nsc.util.DirectoryClassPath.packages(ClassPath.scala:264)
[INFO]  at scala.tools.nsc.util.MergedClassPath$$anonfun$packages$1.apply(ClassPath.scala:358)
[INFO]  at scala.tools.nsc.util.MergedClassPath$$anonfun$packages$1.apply(ClassPath.scala:358)
[INFO]  at scala.collection.Iterator$class.foreach(Iterator.scala:891)
[INFO]  at scala.collection.AbstractIterator.foreach(Iterator.scala:1334)
[INFO]  at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
[INFO]  at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
[INFO]  at scala.tools.nsc.util.MergedClassPath.packages$lzycompute(ClassPath.scala:358)
[INFO]  at scala.tools.nsc.util.MergedClassPath.packages(ClassPath.scala:353)
[INFO]  at scala.tools.nsc.symtab.SymbolLoaders$PackageLoader$$anonfun$doComplete$1.apply$mcV$sp(SymbolLoaders.scala:269)
[INFO]  at scala.tools.nsc.symtab.SymbolLoaders$PackageLoader$$anonfun$doComplete$1.apply(SymbolLoaders.scala:260)
[INFO]  at scala.tools.nsc.symtab.SymbolLoaders$PackageLoader$$anonfun$doComplete$1.apply(SymbolLoaders.scala:260)
[INFO]  at scala.reflect.internal.SymbolTable.enteringPhase(SymbolTable.scala:235)
[INFO]  at scala.tools.nsc.symtab.SymbolLoaders$PackageLoader.doComplete(SymbolLoaders.scala:260)
[INFO]  at scala.tools.nsc.symtab.SymbolLoaders$SymbolLoader.complete(SymbolLoaders.scala:211)
[INFO]  at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1535)
[INFO]  at scala.reflect.internal.Mirrors$RootsBase.init(Mirrors.scala:256)
[INFO]  at scala.tools.nsc.Global.rootMirror$lzycompute(Global.scala:73)
[INFO]  at scala.tools.nsc.Global.rootMirror(Global.scala:71)
[INFO]  at scala.tools.nsc.Global.rootMirror(Global.scala:39)
[INFO]  at scala.reflect.internal.Definitions$DefinitionsClass.ObjectClass$lzycompute(Definitions.scala:257)
[INFO]  at scala.reflect.internal.Definitions$DefinitionsClass.ObjectClass(Definitions.scala:257)
[INFO]  at scala.reflect.internal.Definitions$DefinitionsClass.init(Definitions.scala:1390)
[INFO]  at scala.tools.nsc.Global$Run.<init>(Global.scala:1242)
[INFO]  at scala.tools.nsc.Driver.doCompile(Driver.scala:31)
[INFO]  at scala.tools.nsc.MainClass.doCompile(Main.scala:23)
[INFO]  at scala.tools.nsc.Driver.process(Driver.scala:51)
[INFO]  at scala.tools.nsc.Driver.main(Driver.scala:64)
[INFO]  at scala.tools.nsc.Main.main(Main.scala)
[INFO]  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO]  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[INFO]  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO]  at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[INFO]  at scala_maven_executions.MainHelper.runMain(MainHelper.java:164)
[INFO]  at scala_maven_executions.MainWithArgsInFile.main(MainWithArgsInFile.java:26)
[INFO] java.lang.reflect.InvocationTargetException
[INFO]  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO]  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[INFO]  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO]  at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[INFO]  at scala_maven_executions.MainHelper.runMain(MainHelper.java:164)
[INFO]  at scala_maven_executions.MainWithArgsInFile.main(MainWithArgsInFile.java:26)
[ERROR] Caused by: java.lang.NoClassDefFoundError: javax/tools/ToolProvider
[INFO]  at scala.reflect.io.JavaToolsPlatformArchive.iterator(ZipArchive.scala:301)
[INFO]  at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
[INFO]  at scala.reflect.io.AbstractFile.foreach(AbstractFile.scala:92)
[INFO]  at scala.tools.nsc.util.DirectoryClassPath.traverse(ClassPath.scala:277)
[INFO]  at scala.tools.nsc.util.DirectoryClassPath.x$15$lzycompute(ClassPath.scala:299)
[INFO]  at scala.tools.nsc.util.DirectoryClassPath.x$15(ClassPath.scala:299)
[INFO]  at scala.tools.nsc.util.DirectoryClassPath.packages$lzycompute(ClassPath.scala:299)
[INFO]  at scala.tools.nsc.util.DirectoryClassPath.packages(ClassPath.scala:299)
[INFO]  at scala.tools.nsc.util.DirectoryClassPath.packages(ClassPath.scala:264)
[INFO]  at scala.tools.nsc.util.MergedClassPath$$anonfun$packages$1.apply(ClassPath.scala:358)
[INFO]  at scala.tools.nsc.util.MergedClassPath$$anonfun$packages$1.apply(ClassPath.scala:358)
[INFO]  at scala.collection.Iterator$class.foreach(Iterator.scala:891)
[INFO]  at scala.collection.AbstractIterator.foreach(Iterator.scala:1334)
[INFO]  at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
[INFO]  at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
[INFO]  at scala.tools.nsc.util.MergedClassPath.packages$lzycompute(ClassPath.scala:358)
[INFO]  at scala.tools.nsc.util.MergedClassPath.packages(ClassPath.scala:353)
[INFO]  at scala.tools.nsc.symtab.SymbolLoaders$PackageLoader$$anonfun$doComplete$1.apply$mcV$sp(SymbolLoaders.scala:269)
[INFO]  at scala.tools.nsc.symtab.SymbolLoaders$PackageLoader$$anonfun$doComplete$1.apply(SymbolLoaders.scala:260)
[INFO]  at scala.tools.nsc.symtab.SymbolLoaders$PackageLoader$$anonfun$doComplete$1.apply(SymbolLoaders.scala:260)
[INFO]  at scala.reflect.internal.SymbolTable.enteringPhase(SymbolTable.scala:235)
[INFO]  at scala.tools.nsc.symtab.SymbolLoaders$PackageLoader.doComplete(SymbolLoaders.scala:260)
[INFO]  at scala.tools.nsc.symtab.SymbolLoaders$SymbolLoader.complete(SymbolLoaders.scala:211)
[INFO]  at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1535)
[INFO]  at scala.reflect.internal.Mirrors$RootsBase.init(Mirrors.scala:256)
[INFO]  at scala.tools.nsc.Global.rootMirror$lzycompute(Global.scala:73)
[INFO]  at scala.tools.nsc.Global.rootMirror(Global.scala:71)
[INFO]  at scala.tools.nsc.Global.rootMirror(Global.scala:39)
[INFO]  at scala.reflect.internal.Definitions$DefinitionsClass.ObjectClass$lzycompute(Definitions.scala:257)
[INFO]  at scala.reflect.internal.Definitions$DefinitionsClass.ObjectClass(Definitions.scala:257)
[INFO]  at scala.reflect.internal.Definitions$DefinitionsClass.init(Definitions.scala:1390)
[INFO]  at scala.tools.nsc.Global$Run.<init>(Global.scala:1242)
[INFO]  at scala.tools.nsc.Driver.doCompile(Driver.scala:31)
[INFO]  at scala.tools.nsc.MainClass.doCompile(Main.scala:23)
[INFO]  at scala.tools.nsc.Driver.process(Driver.scala:51)
[INFO]  at scala.tools.nsc.Driver.main(Driver.scala:64)
[INFO]  at scala.tools.nsc.Main.main(Main.scala)
[INFO]  ... 6 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.110 s
[INFO] Finished at: 2019-11-27T14:23:23+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal net.alchim31.maven:scala-maven-plugin:3.2.2:compile (default) on project orion.flink.connector.examples: wrap: org.apache.commons.exec.ExecuteException: Process exited with an error: 240 (Exit value: 240) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal net.alchim31.maven:scala-maven-plugin:3.2.2:compile (default) on project orion.flink.connector.examples: wrap: org.apache.commons.exec.ExecuteException: Process exited with an error: 240 (Exit value: 240)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: wrap: org.apache.commons.exec.ExecuteException: Process exited with an error: 240 (Exit value: 240)
    at scala_maven.ScalaMojoSupport.execute (ScalaMojoSupport.java:490)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.commons.exec.ExecuteException: Process exited with an error: 240 (Exit value: 240)
    at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:377)
    at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:160)
    at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:147)
    at scala_maven_executions.JavaMainCallerByFork.run (JavaMainCallerByFork.java:100)
    at scala_maven.ScalaCompilerSupport.compile (ScalaCompilerSupport.java:161)
    at scala_maven.ScalaCompilerSupport.doExecute (ScalaCompilerSupport.java:99)
    at scala_maven.ScalaMojoSupport.execute (ScalaMojoSupport.java:482)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

I have tried some things i found to change the compiler version to java 8 as one of the first lines still says that i is 11.

sonsoleslp commented 4 years ago

Hi, Make sure you are using Java 1.8, Scala 2.11 and that you have correctly installed the Orion Flink Connector using the provided mvn install command.

gedoensmax commented 4 years ago

I think i made sure that i met these requirements but i do not need the support anymore so feel free to close this issue for now.