简体   繁体   中英

How to debug the error “Class file needed by X is missing. reference value Y of package Z refers to nonexisting symbol” in Scala?

I am just getting started with Scala since last week and I am having this problem that is driving me crazy.

I have some code that I want to migrate fully from Java to Scala (except libraries) but I have hit a block where I can't now proceed because of this mysterious error.

Let's say that I have a class that I have defined in org.domain.subdomain.MyClass

I have a class that seems to have no compilation problems (as suggested by Intellij) but when I build my project's modules, I would get the following

Class file needed by MyClass is missing

reference value subdomain of package org.domain refers to nonexisting symbol.

I am certain (or almost?) that I have got the classpath right as the projects were compiling before I started rewriting the code in Scala.

I have not been able to get it to compile with the verbose option on. I am using FSC compiler as the project compiler. Intellij does not show anything with verbose option!

What is going on here? How can I solve this?

I just had this problem, and reimporting the project in IntelliJ worked. I removed .idea directory and .iml file, then reimported the project as maven.

This is an IntelliJ issue - outside maven builds worked fine.

Your classpath is incomplete. The reference to org.domain.subdomain appears in a classfile referenced by one of our sources (as indicated by the error message).

If you are rewriting Java code, you may need add more of your transitive dependencies in each module's classpath. The Scala compiler is more eager when it comes to type-checking and in some situations it needs a larger classpath.

I know, the question is more than one year old, but maybe it helps someone.

I just had the same issue. One of my libraries used an newer version of org.scala-lang:scala-library than the main project. After the library update everything works fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM