2

I am periodically experiencing the "type [blah] cannot be resolved. It is indirectly referenced from required .class files" error, and reaching out for help.

I've searched this site and the web, and all of the many similar-sounding questions seem to be resolved by adding classes to the classpath. But in this case, I'm pretty sure they already are on the classpath.

Here's the situation, pared down from an extremely large metaproject. There are two eclipse projects ProjectOne and ProjectTwo.

Both projects are published by a build server to an Ivy repository, and ProjectTwo's ivy.xml refers to that version of ProjectOne. However, I keep the ivy "resolve dependencies in workspace" preference turned on, so that I can work in both projects, and resolve to my modified classes instead of the published ones.

ProjectOne compiles in my workspace (as does ProjectTwo, except (occasionally) for the "indirectly referenced from required .class files" problem.

The structure looks basically like this:

// ProjectOne
   class Enum { **// I now suspect this name is the problem**
      public static class EnumObjectCache {
      }

// ProjectTwo
   class Bar { **// Occasionally gets error about Enum$EnumObjectcache being unresolvable**
   }

This is despite the facts that:

  1. This only affects Eclipse. The real compiler handles this all with no problem
  2. ProjectTwo's ivy.xml file does contain a transitive dependency on ProjectOne.
  3. ProjectOne is present in the workspace, and successfully compiles.
  4. I always have "resolve dependencies in workspace" turned on.
  5. Regardless of how things are resolved, it should work class Enum (and EnumObjectCache) have been unchanged for more than a year.
  6. As an experiment, I've tried directly adding ProjectOne to ProjectTwo's classpath (by defining it as a required project). No change.
  7. To make this more interesting, this problem doesn't happen all the time, and it only happens to a few classes in this very large codebase. Oh, and when it does happen, it's always on Enum$EnumObjectCache.
  8. It doesn't happen to every one of the developers on the team at a time.
  9. The problem, when it happens, persists over multiple 'clean' and restarts of eclipse, and IVY re-resolves. (though I wasn't doing Ivy clean-all-caches).

    10. I can "fix" the problem by introducing an otherwise unneccssary import of Enum from ProjectOne

Note: I had not previously tried cleaning the cache, as it's painfully slow to do (remote cache is transatlantic, and it's a very large project): 55 minutes to clean all caches and re-resolve, then another 20 or so to rebuild.

However, following a clean-all-cache, re-resolve, and rebuild, I still have the same problem.

Community
  • 1
  • 1
CPerkins
  • 8,968
  • 3
  • 34
  • 47
  • Not enough information to investigate your problem. Are you publishing the artifact from one project before attempting to reference it from the other? – Mark O'Connor Jun 11 '12 at 23:43
  • Have you tried to clean the local Ivy cache on each of the user's computers? Also, if you have your own remote repository, clean the ivy cache there. – tjg184 Jun 11 '12 at 23:48
  • 1
    Other thing to validate if you're using IvyDE is to turn on verbose trace in the Ivy console. – tjg184 Jun 11 '12 at 23:50
  • Am addressing the above comments. Will update again shortly. – CPerkins Jun 13 '12 at 13:06
  • @MarkO'Connor: thanks for your comments. I hope the aditional info helps. I now suspect that the problem is caused by name collision: the codebase is old enough that we have our own Enum class. I suspect that in the absence of an explicit import, Eclipse was resolving the transitive dependency on "Enum" from java.lang, which lacks EnumObjectCache. – CPerkins Jun 13 '12 at 14:26
  • @tjg184 see previous comment (they only let us notify one person per comment). – CPerkins Jun 13 '12 at 14:26
  • To all: my apologies: I seem to have lost the formatting on the code, and cannot get it back despite several attempts. – CPerkins Jun 13 '12 at 14:33

0 Answers0