Scala + Playframework 2.3.X importing dependencies - scala

I am having problems importing two dependencies here is the import
import io.GooglePlayClient
import io.GooglePlayError
and I get this error
object GooglePlayError is not a member of package akka.io
[error] import io.GooglePlayError
object GooglePlayClient is not a member of package akka.io
[error] import io.GooglePlayClient
It seems it is prefixing the package where I am trying to import (akka) to this imports, and the is not able to import.
Thank you

You already have akka.io imported in scope. So, akka.io.GooglePlayError is tried. Instead use import _root_.io.GooglePlayError.

Another option is to import using the fully qualified name of the dependencies if available, that is
import com.yourcompany.io.GooglePlayClient
import com.yourcompany.io.GooglePlayError
If the io package is really a root package, you could consider refactoring your package structure to something like the above.

Related

Scala/Spark/Databricks: How to import code from user-created JAR?

I have a JAR that I created with intellij and sbt, that defines a case class and Object. I've uploaded it to my databricks workspace, and attached it to a cluster as a library.
How do I actually import code from it/reference it in my notebook? So far all I can think of is to try
import NameOfJar._
which gives
java.lang.NoClassDefFoundError: DataFrameComparison$
Do I need to have built the jar differently somehow? (Package statement or something?)
you should import import packageName._, jar name is not used in import statement. It should work the same as in usual local java/scala code.
You can check this article for details - https://docs.databricks.com/libraries.html
Btw, does your notebook fail on import itself, or later, when you're trying to use class, that exists inside jar?

Building Hbase on eclipse using Maven (The import org.apache.hadoop.hbase.tmpl cannot be resolved)

I use the maven to import Hbase source on eclipse.
But there has a error that is "The import org.apache.hadoop.hbase.tmpl cannot be resolved)".
I had find the tmpl package , but its "jamon".
How to find the tmpl package, and its "java"?
Can find the tmpl package on Hbase.bin.tar, and import the extend tmpl.jar
It will work.

cannot find jars for the imported Giraph packages

I was trying to run the SSSP giraph program from Eclipse. But I couldnt get the following packages imported
import org.apache.giraph.graph.BasicVertex;
import org.apache.giraph.graph.BspUtils;
import org.apache.giraph.graph.GiraphJob;
import org.apache.giraph.graph.EdgeListVertex;
import org.apache.giraph.graph.VertexReader;
import org.apache.giraph.graph.VertexWriter;
import org.apache.giraph.lib.TextVertexInputFormat;
import org.apache.giraph.lib.TextVertexInputFormat.TextVertexReader;
import org.apache.giraph.lib.TextVertexOutputFormat;
import org.apache.giraph.lib.TextVertexOutputFormat.TextVertexWriter;
I have followed the instruction in the giraph site to build Giraph and Hadoop.
Which jar should be imported to get the above packages?
Are you running the code for the correct version of Giraph? I think the imports you mention are for versions before 1.0.0, if you include a jar for a newer version it won't find them.

Can't find some Akka libs in Eclips

I have recently started exploring Scala.
I have installed Eclips and I integrated Akka-Actors Libs in the Build-Path Project.
But whenever I try compiling the project, I got an erorr. I can't resolve such libraries.
import akka.routing.{Routing, CyclicIterator}
import Routing._
Any idea how to configure Akka to work perfectly with Eclips ?
AFAICT, there's no such class in Akka.
Router, yes - Routing, no.
I have the same problem, I have Added the akka-actor_2.10-2.3.0.jar and the config-1.0.2.jar libraries but the error persists.
In the webpage of akka (akka.io) they use both imports in a example proyect.
http://doc.akka.io/docs/akka/1.3/intro/getting-started-first-scala.html
package akka.tutorial.first.scala
import akka.actor.{Actor, PoisonPill}
import Actor._
import akka.routing.{Routing, CyclicIterator}
import Routing._
.....
.....
....
ANSWER: You should use spray and the spray's library, it has a routing method you can use aswell.
import spray.routing._
You have to download the spray-routing-1.2.0.jar if you want to use it (http://repo.spray.io/io/spray/spray-routing/)

Importing anorm.SQL in IntelliJ IDEA 13

IntelliJ 13 Community Edition
Play Framework 2.2
Scala 2.10.2
I am importing anorm._ and using SQL in my object. The object starts off as follows:
package controllers
import play.api.mvc._
import play.api.db.DB
import play.api.Play.current
import anorm._
object Walks extends Controller {
val futureWalksSql = SQL("SELECT * FROM walks where evt_date > now()")
IntelliJ cannot resolve symbol SQL. If I ctrl+Enter, after anorm. there is no SQL option, although there is a .Sql trait, object and class.
When I run the play project, it all works just fine, with no compilation errors so this Scala is syntactically correct but IntelliJ isn't picking this up. I have created the idea files by calling idea from within the play console and I've also tried idea with-sources=yes.
How do I get IntelliJ Community Editon to pick up anorm.SQL? What is so special about this object? I'm still learning Scala and so this might be a Scala issue.
SQL is a method defined in a package object anorm. So when you import anorm._ you import the entire package with the package object as well. I have actually no clue why Idea does not pick this up. But if you look into the package object sources you can see that the SQL method is just a wrapper on anorm.Sql.sql(inSql: String).
As a workaround you may try to import anorm.Sql._ and use sql("select 1") instead of SQL("select 1")