views:

359

answers:

3

Dunno why this happens... Ok here is the situation: I have a nb project on my laptop. I have the same project on my desktop. I copy the sources (not the entire project) on the desktop, overwriting the desktop sources. Everything cleans and builds ok. Then I start the debugger. On the main class I can debug step by step. If it goes into an internal method here is what happens:

Listening on 37574
User program running
LineBreakpoint test.java : 45 successfully submitted.
Breakpoint hit at line 45 in class test by thread main.
Thread main stopped at test.java:45.
User program running
Not able to submit breakpoint LineBreakpoint baseControllerManager.java : 41, reason: No executable location available at line 41 in class baseClasses.JNW.baseControllerManager.
Invalid LineBreakpoint baseControllerManager.java : 41
Debugger stopped on uncompilable source code.
User program finished

As you can see until I'm in static method main it works (line 45) as I jump inside a non static method (that is an override) it comes out with that... I tried to:

  • clean and build = no effect
  • manually delete build and dist = no effect

What do you suggest?

For the sake of completeness I'm attaching the sources of the main class:

import baseClasses.JNW.baseAction;
import baseClasses.JNW.baseContResult;
import baseClasses.JNW.baseController;
import baseClasses.JNW.baseControllerManager;

public class test {

    public static class starter extends baseController {

        public static final String ACTION_START = "ACTION_START";

        @Override
        public baseContResult doAction(baseAction action) {

            if (ACTION_START.equals(action.action)) {
                manager.log("action start...");
                return new baseContResult(RESULT_OK, baseContResult.resultType.RESULT_OK);
            }
            return super.doAction(action);
        }

        @Override
        public void init() {
            super.init();
        }
    }

    public void startMe() {
        baseControllerManager manager;
        try {
            manager = new baseControllerManager();
        } catch (Exception e) {
            e.printStackTrace();
            return;
        }
        starter st = new starter();
        manager.setMainController(st);
        manager.doAction(new baseAction(starter.ACTION_START));
    }

    public static void main(String args[]) {


        test te = new test();
        te.startMe();

    }
}
+1  A: 

Generally, an uncompilable error means a symbol could not be resolved.

If you have dependencies on other projects, libraries, or jars, make sure they have built successfully / are present.

Checking "Build Projects on Classpath" (in project properties > Build > Compiling) will often fix this. If you don't have this checked, you are responsible for ensuring dependencies are already built.

Devon_C_Miller
Build projects on Classpath is already checked (even if it is on a different location - build > libraries . But I don't think this is the problem as this is a single (and simple project). Everything compiles well, even if I modify something. AND RUNS. The only problem is the debugger. I started this project and everything was working fine (in Eclipse). Then I created a project in NB (ask my boss why) and it started giving me problems like this (I created a project using the Create Project from existing sources option). I redid this a dozen of times, even after reinstalling netbeans, but no way
gotch4
Ok, it sounds like the debugger is seeing conflicting information about the class files. Are there any class files under your source directory? The NB approach is to put all the class files in build/classes. However, I see that when I use the "Create Project from existing sources" option it is adding the source directory to the class path. So, it could be there are class files from a pre-NB build that NB doesn't know to remove. Class files where line 41 does not correspond to executable code.
Devon_C_Miller
+2  A: 

Look in the file nbproject/project.properties for the property javac.debug and make sure that it's "true". If it is, grep for that property elsewhere in the nbproject directory and any local ant settings.

On a semi-related note: when I'm creating a project in NetBeans, even if the sources already exist elsewhere, I always create a new "Java Application", and let it populate the project directory as it wants. Then I can move in my sources and update the project, and NetBeans stays happy.


Edit after you tried setting javac.debug:

Looking at your question again, I see that you were able to set a breakpoint on test.java, but not able to set one on baseControllerManager.java. That indicates to me that you're getting the latter class from a JAR somewhere, not from your project directory.

So the first step is to make sure that you haven't defined a CLASSPATH environment variable. This is never a good thing to do, regardless of whether you're using an IDE or a manual build.

Next step is to look at the libraries that you've specified for the NetBeans project. You can use grep on a JARfile; the file directory is in plaintext. It should be sufficient to look for the unqualified classname.

And the final thing is to verify that you are indeed compiling the class, by looking for it in the build directory.

kdgregory
+1  A: 

The property was not present in project.properties. So I added it (at a point where there where many javac.* properties...). Then I grepped like this:

dario@dario-desktop:~/Scrivania/JNW$ grep -r javac.debug *
nbproject/project.properties:javac.debug=true
nbproject/build-impl.xml:        <property name="javac.debug" value="true"/>
nbproject/build-impl.xml:            <attribute default="${javac.debug}" name="debug"/>
nbproject/build-impl.xml:                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
nbproject/private/private.properties:javac.debug=true
nbproject/project.properties~:javac.debug=true

In fact it sees my addition on the last line.

I cleaned and rebuilt the project. The debugger is not working again........... I think I'll kick my boss ass until he agrees to use eclipse or he fires me. I'll be unemployed but happy. Apart from joking, @kdgrgory, do you have any more ideas???

gotch4
For the future, editing your question is probably the best approach to narrowing down the problem ... I have to scroll back up there anyway, so will attach the next comment there.
kdgregory
yes you're right didn't thought about it.... sorry
gotch4