I’ve shrunk the problem down to a minimal size. The code
package org.example
import org.apache.flink.table.api._
import org.apache.http.HttpHost
import java.util.ArrayList
object foo {
val httpHosts = new ArrayList[HttpHost]
httpHosts.add(new HttpHost("samwise.local", 9200, "http"))
}
will not compile, but remove the import org.apache.flink.table.api._ and all is
well
Nick
> On 26 Sep 2019, at 12:53, Nicholas Walton <[email protected]> wrote:
>
> I’m having a problem using ArrayList in Scala . The code is below
>
> import org.apache.flink.core.fs._
> import org.apache.flink.streaming.api._
> import org.apache.flink.streaming.api.scala._
> import org.apache.flink.table.api._
> import org.apache.flink.table.api.scala._
> import org.apache.flink.table.sinks._
> import org.apache.http.HttpHost
> import org.slf4j.LoggerFactory
>
> import java.util.ArrayList
>
> object Job {
>
> val httpHosts = new ArrayList[HttpHost]
> httpHosts.add(new HttpHost("samwise.local", 9200, "http"))
> …..
>
> }
>
> Scala refuses to recognise ArrayList. The IDE InteliJ likewise flags
> java.util as not existing, even though it recognises ArrayList and suggest
> auto-insertion of the import java.utils.ArrayList statement. The compilation
> errors are
>
> [error] ………………/src/main/scala/org/example/Job.scala:30:13: object util is not
> a member of package org.apache.flink.table.api.java
> [error] import java.util.ArrayList
> [error] ^
> [error] ………………/src/main/scala/org/example/Job.scala:34:23: not found: type
> ArrayList
> [error] val httpHosts = new ArrayList[HttpHost]
> [error] ^
> [error] two errors found
> [error] (Compile / compileIncremental) Compilation failed
>
> Without the ArrayList reference the code compiles with no errors.
>
> The sbt build file, if it helps is,
>
> resolvers in ThisBuild ++= Seq("Apache Development Snapshot Repository" at
> "https://repository.apache.org/content/repositories/snapshots/
> <https://repository.apache.org/content/repositories/snapshots/>",
> Resolver.mavenLocal)
>
> name := "Flink MultiChannel Project"
>
> version := "0.1-SNAPSHOT"
>
> organization := "org.example"
>
> scalaVersion in ThisBuild := "2.11.0"
>
> val flinkVersion = "1.8.1"
>
> val flinkDependencies = Seq(
> "org.apache.flink" %% "flink-scala" % flinkVersion ,
> "org.apache.flink" %% "flink-table" % "1.7.2" ,
> "org.apache.flink" %% "flink-connector-elasticsearch" % flinkVersion,
> "org.apache.flink" %% "flink-streaming-scala" % flinkVersion,
> "org.apache.httpcomponents" % "httpclient" % "4.5.10",
> "org.apache.httpcomponents" % "httpcore" % "4.4.11")
> // https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore
> <https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore>
>
> lazy val root = (project in file(".")).
> settings(
> libraryDependencies ++= flinkDependencies)
>
> mainClass in assembly := Some("org.example.Job")
>
> // make run command include the provided dependencies
> run in Compile := Defaults.runTask(fullClasspath in Compile, mainClass in
> (Compile, run), runner in (Compile, run))
>
> // exclude Scala library from assembly
> assemblyOption in assembly := (assemblyOption in
> assembly).value.copy(includeScala = false)
>
>
> TIA
>
> Nick