jsoup compilation error

488 views
Skip to first unread message

Ian Downard

unread,
Jul 7, 2015, 1:17:25 AM7/7/15
to pdxs...@googlegroups.com
I'm trying to import the jsoup library into a scala controller class for HTML parsing, but I'm getting the compilation error, "object jsoup is not a member of package org".  If I extract the jar file, it obviously is in the org package.  Does anyone know what I might be doing wrong?

Thanks in advance.

Inline image 1

Thomas Lockney

unread,
Jul 7, 2015, 1:21:25 AM7/7/15
to pdxscala
I assume you have this lib included as a library dependency in your project, but did you reload the project after adding it (either exit and restart play or run the 'reload' command from within the sbt/play console)?

--
You received this message because you are subscribed to the Google Groups "pdxscala" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pdxscala+u...@googlegroups.com.
To post to this group, send email to pdxs...@googlegroups.com.
Visit this group at http://groups.google.com/group/pdxscala.
For more options, visit https://groups.google.com/d/optout.



--

Ian Downard

unread,
Jul 7, 2015, 6:08:17 PM7/7/15
to pdxs...@googlegroups.com
I had not correctly added my library dependency.  I fixed the problem by putting "org.jsoup" % "jsoup" % "1.8.2" in build.sbt.  Thanks.


Gary Hewett

unread,
Feb 4, 2016, 1:08:45 PM2/4/16
to pdxscala
I seem to be having a similar error. 

I say similar because the "fix" here doe into work. 

I do have the following line in my build.sbt 

  "org.jsoup" % "jsoup" % "1.8.3"


and I can see the jar gets downloaded without issue. I've tried 1.8.2 etc and same results. 

As soon as I add an import statement: 

import org.jsoup._

I get the following compile error. 

object jsoup is not a member of package org
[error] import org.jsoup._

Strange that I do the exact same thing for a mysql connector and it works without issue. (and java.mail and org.apache.commons with common-lang3)

I more curious in knowing the steps on how to fix this rather than just fixing it. (Teach this man to fish please...)

Tried the HtmlCleaner library and had same problem.  

Have done

clean

(of course) plus a complete system reboot.

Also tried

rm -Rf ~/.ivy2/

to flush the ivy cache that sbt uses. (which triggers a download of the internet as they say...) Is there perhaps a kinder/gentler way of doing that?

This was in the logs going by 

[info] downloading https://repo1.maven.org/maven2/org/jsoup/jsoup/1.8.3/jsoup-1.8.3.jar ...
[info] [SUCCESSFUL ] org.jsoup#jsoup;1.8.3!jsoup.jar (282ms)

And yet no luck - the same error at compile time. . 

What is next? 

Robert Norris

unread,
Feb 4, 2016, 1:47:18 PM2/4/16
to pdxs...@googlegroups.com

Hi Gary, this works for me. A problem with your build definition maybe?

tmp$ mkdir foo
tmp$ cd foo
foo$ sbt -sbt-create
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=1024m; support was removed in 8.0
[info] Loading global plugins from /Users/rnorris/.sbt/0.13/plugins
[info] Updating {file:/Users/rnorris/.sbt/0.13/plugins/}global-plugins...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to foo (in build file:/private/tmp/foo/)
> set libraryDependencies += "org.jsoup" % "jsoup" % "1.8.3"
[info] Defining *:libraryDependencies
[info] The new value will be used by *:allDependencies, *:dependencyPositions
[info] Reapplying settings...
[info] Set current project to foo (in build file:/private/tmp/foo/)
> console
[info] Updating {file:/private/tmp/foo/}foo...
[info] Resolving org.scala-lang#scalap;2.10.5 ...
[info] [SUCCESSFUL ] org.jsoup#jsoup;1.8.3!jsoup.jar (2332ms)
[info] Done updating.
[info] Starting scala interpreter...
[info] 
Welcome to Scala version 2.10.5 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_65).
Type in expressions to have them evaluated.
Type :help for more information.

scala> import org.jsoup._
import org.jsoup._


--
You received this message because you are subscribed to the Google Groups "pdxscala" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pdxscala+u...@googlegroups.com.
To post to this group, send email to pdxs...@googlegroups.com.

Gary Hewett

unread,
Feb 4, 2016, 2:38:12 PM2/4/16
to pdxscala
I figured it out (sigh) 

I have modules and that means multiple build.sbt files. 

I was putting the import statement into the uppermost build.sbt but not the ones in submodules. 

Of course the first file I edited, trying to add JSoup, was in a submodule. 

All good now. 
Reply all
Reply to author
Forward
0 new messages