Support Questions

Find answers, ask questions, and share your expertise

How could I import org.eclipse.jetty.client packages for spark scala program in HDP2.5

avatar
Explorer

I have following error with zeppelin in HDP2.5.

so, I have searched to know the installation and import scala packages like python.

but I failed.

How can I remove the errors.

In addition, I don't want to use eclipse for spark, but zeppelin.

Thanks.

error said: "<console>:63: error: object eclipse is not a member of package org import org.eclipse.jetty.client.ContentExchange"

import org.eclipse.jetty.client.ContentExchange
import org.eclipse.jetty.client.HttpClient


def createExchangeForSign(client: HttpClient, sign: String): (String, ContentExchange) = {
	val exchange = new ContentExchange()
	exchange.setURL(s"http://new73s.herokuapp.com/qsos/${sign}.json")
	client.send(exchange)
	(sign, exchange)
}


def readExchangeCallLog(mapper: ObjectMapper, exchange: ContentExchange): Array[CallLog] = {
	exchange.waitForDone()
	val responseJson = exchange.getResponseContent()
	val qsos = mapper.readValue(responseJson, classOf[Array[CallLog]])
	qsos
}


val contactsContactLists = validSigns.distinct().mapPartitions{
  signs =>
  val mapper = createMapper()
  // create a connection pool
  val client = new HttpClient()
  client.start()
  // create http request
  signs.map {sign =>
	createExchangeForSign(client, sign)
  // fetch responses
  }.map{ case (sign, exchange) =>
	  (sign, readExchangeCallLog(mapper, exchange))
  }.filter(x => x._2 != null) // Remove empty CallLogs
}
println(contactsContactLists.collect().toList)
1 ACCEPTED SOLUTION

avatar
Master Mentor

@Osoeng Kwon

I think the issue here is that ContentExchange is not in org.eclipse.jetty I see a similar class in org.mortbay.jetty

http://grepcode.com/file/repo1.maven.org/maven2/org.eclipse.jetty/jetty-client/8.1.14.v20131031/org/...

confirm that's what you need, then you can load it in Zeppelin with command below and whatever the new maven repo for the class ContentExchange you're looking for.

%spark.dep
z.reset()
z.load("org.eclipse.jetty:jetty-client:9.4.2.v20170220")
%spark
import org.eclipse.jetty.client.ContentExchange
import org.eclipse.jetty.client.HttpClient

View solution in original post

4 REPLIES 4

avatar
Master Mentor

@Osoeng Kwon

I think the issue here is that ContentExchange is not in org.eclipse.jetty I see a similar class in org.mortbay.jetty

http://grepcode.com/file/repo1.maven.org/maven2/org.eclipse.jetty/jetty-client/8.1.14.v20131031/org/...

confirm that's what you need, then you can load it in Zeppelin with command below and whatever the new maven repo for the class ContentExchange you're looking for.

%spark.dep
z.reset()
z.load("org.eclipse.jetty:jetty-client:9.4.2.v20170220")
%spark
import org.eclipse.jetty.client.ContentExchange
import org.eclipse.jetty.client.HttpClient

avatar
Master Mentor

@Osoeng Kwon I tested your imports and it does indeed look like ContentExchange is no longer in the package org.eclipse.jetty.client. My maven search prompted me to the following version that has both classes.

<dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-client</artifactId>
            <version>7.6.13.v20130916</version>
            <type>jar</type>
        </dependency>

you might want to reconsider using it as it's from 2013, there are many version of jetty-client available since then. Also there's something wrong with your code, I ran it in Zeppelin and it didn't work, most likely I'm missing some of the imports you did not copy/paste. I loaded the dependency using the interpreter configuration page, under Spark, click edit and add the dependency in the dependencies section (the screenshot below shows how it looks in my configuration), using z.load as I've shown earlier is deprecated. I ran all of your code in Zeppelin after that and I received the following:

import org.eclipse.jetty.client.ContentExchange
import org.eclipse.jetty.client.HttpClient
createExchangeForSign: (client: org.eclipse.jetty.client.HttpClient, sign: String)(String, org.eclipse.jetty.client.ContentExchange)
<console>:29: error: not found: type CallLog
         def readExchangeCallLog(mapper: ObjectMapper, exchange: ContentExchange): Array[CallLog] = {
                                                                                         ^
<console>:29: error: not found: type ObjectMapper
         def readExchangeCallLog(mapper: ObjectMapper, exchange: ContentExchange): Array[CallLog] = {

13005-untitled.png

avatar
Explorer

Thanks for your reply. I have success with followings:

%spark.dep
z.reset()
z.load("org.eclipse.jetty:jetty-client:7.6.13.v20130916")

%spark
import org.eclipse.jetty.client.ContentExchange
import org.eclipse.jetty.client.HttpClient

DepInterpreter(%dep) deprecated. Remove dependencies and repositories through GUI interpreter menu instead. DepInterpreter(%dep) deprecated. Load dependency through GUI interpreter menu instead. res1: org.apache.zeppelin.dep.Dependency = org.apache.zeppelin.dep.Dependency@2448cc17

import org.eclipse.jetty.client.ContentExchange

import org.eclipse.jetty.client.HttpClient

avatar
Explorer

How can see the dependency information needed to solve my error?