3

I've set up Scala project using Maven. It does not compile however. I get strange errors like something very basic is missing. Some of them are:

[ERROR] /home/victor/Work/Projects/Own/Scraper/src/main/scala/me/crawler/Node.scala:17: error: not found: type Map
[INFO]   var attributes: Map[String, String] = null
[INFO]                   ^
[ERROR] /home/victor/Work/Projects/Own/Scraper/src/main/scala/me/crawler/CompanySiteEmailCrawlerController.scala:137: error: not found: type Set
[INFO]   private def addEmailToCompanyList(harvestedRecordsCompanyList: List[Company], company: Company, emailSet: Set[String],[INFO]                                                                                                             ^
[ERROR] /home/victor/Work/Projects/Own/Scraper/src/main/scala/me/crawler/CompanySiteEmailCrawlerController.scala:186: error: value toInt is not a member of String
[INFO]       lineFrom = args(3).toInt
[INFO]                          ^
[ERROR] /home/victor/Work/Projects/Own/Scraper/src/main/scala/me/crawler/crawler4j/Crawler4jAdaptee.scala:25: error: not found: value classOf
[INFO]   private val log: Logger = Logger.getLogger(classOf[Crawler4jAdaptee])
[INFO]                                              ^
[ERROR] /home/victor/Work/Projects/Own/Scraper/src/main/scala/me/crawler/crawler4j/Crawler4jAdaptee.scala:126: error: not found: type Map
[INFO]       val attributesMap: Map[String, String] = attributes.map(a => (a.getKey, a.getValue)).toMap
[INFO]                          ^

So Map and Set collections are not fount and toInt method doesn't work for Strings. In my pom.xml I have:

<dependencies>
    <dependency>
        <groupId>org.scala-lang</groupId>
        <artifactId>scala-library</artifactId>
        <version>2.10.2</version>
    </dependency>
</dependencies>

<build>
    <sourceDirectory>src/main/scala</sourceDirectory>
    <plugins>
        <plugin>
            <groupId>org.scala-tools</groupId>
            <artifactId>maven-scala-plugin</artifactId>
            <version>2.15.2</version>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                        <goal>testCompile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

<repositories>
    <repository>
        <id>scala</id>
        <name>Scala Tools</name>
        <url>http://scala-tools.org/repo-releases/</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>scala</id>
        <name>Scala Tools</name>
        <url>http://scala-tools.org/repo-releases/</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

The same errors I get when I run it in Idea, although the IDE does not complain about the code, only the compiler does. I am quite new to Scala. Can you please help me out here?

1
  • Something similar is with for cycles. I can't use for (i <- 1 to 10) instead I have to use for (i <- Range(0, 10)), otherwise I get the error to is not a member of Int. Commented Jul 15, 2013 at 19:45

1 Answer 1

1

Importing scala.collection.immutable solved the problems with collections, for the classOf problem I found a workaround - using getClass instead. toInt problem remains unsolved. There is a workaround though - using the exact code from that definition: java.lang.Integer.parseInt. I have a feeling that this is also a problem with imports.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.