This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 168737 - NoClassDefFoundError when running project from IDE. Also wrong class path in compiled .class flile after build - cache problem after refactoring?
Summary: NoClassDefFoundError when running project from IDE. Also wrong class path in ...
Status: RESOLVED DUPLICATE of bug 147000
Alias: None
Product: java
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 6.x
Hardware: PC Windows Vista
: P2 blocker (vote)
Assignee: Jan Pokorsky
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-17 12:20 UTC by gbadoi
Modified: 2009-07-22 12:46 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description gbadoi 2009-07-17 12:20:25 UTC
After some refactoring (move and rename classes) I encountered two problems:

1. Wrong class path in compiled .class file:
   The application contains several projects, each of them having several packages.
   I moved a class from package1 to package2 (in one project), then I compiled all successfully,
   but running main project, ClassNotFound exception was raised.
   Searching project files, I found wrong reference to moved class in caller's .class compiled file:
          "package1/MyClass" instead of "package2/MyClass".

   In caller source, import is correct: 
          import package2.MyClass;

   and no other reference to "package1/MyClass" exists in other file.

   I solved this deleting project and creating it again from sources (restarting IDE didn't solve it)


2. In same circumstances as above, ClassNotFoundException exception is raised ONLY when running project from IDE.

   No exception is raised when running project's jar file.

   I solved it just reinstalling NetBeans and deleting cache manually (restarting IDE didn't solve it also).


It may be a cache problem.

GB
Comment 1 gbadoi 2009-07-17 13:03:52 UTC
I reproduced it again, with same errors.

Deleting NB cache directories solves all problems (is no need to reinstall)

GB
Comment 2 Jan Pokorsky 2009-07-21 10:21:27 UTC
If I understand it well all java files were refactored properly and you were inspecting .class files under
yourproject/build/classes folder.

Is it a standard java project or a free form project? Do you use the Compile on Save option (project
properties/Build/Compiling)? Did you perform the Clean and Build action or just the Build action to compile your project?
Comment 3 gbadoi 2009-07-22 09:44:29 UTC
- All java files are refactored properly
- Old class name appears only in .class file under .../build/classes folder
- Is a standard java project (a common library), used by other projects
- Compile on save enabled
- Action: Clean and Build (Shift-F11), with no compilation errors

NOTE:
NoClassDefFoundError is raised, not ClassNotFoundException as I wrote before (my mistake in copy/paste)
I apologize for it!

GB
Comment 4 Jan Pokorsky 2009-07-22 10:35:24 UTC
Thank you for details. It seems to be caused by the Compile on Save feature.
Comment 5 Dusan Balek 2009-07-22 12:46:27 UTC
Yes, this is a problem in Compile on Save mechanism: any file modification in a project causes recompilation of
dependent files within the same project only! Dependent files from other (dependent) projects are not recompiled.
The workaround is to switch off Compile on Save.

*** This issue has been marked as a duplicate of 147000 ***