How do you debug Clojure in NetBeans IDE? - netbeans

I have a main function but NetBeans needs a main class in order for stepping. How do you guys debug Clojure in NetBeans?

Using the enclojure plugin, I am able to setup a breakpoint in the editor, and then start the debugger inside of Netbeans. Java breakpoints within the project are hit, however, the clojure breakpoints fail with errors like:
Not able to submit breakpoint LineBreakpoint defpackage.clj : 8,
reason: Line number information is missing in the class file com.yourcompany.defpackage.
Invalid LineBreakpoint defpackage.clj : 8
From looking at the site, it implies that debugging support may not be fully available yet.

Related

Internal exception while debugging custom classes in STS

I can't see the variables in the the variables tab in the debug mode in STS no matter the configuration settings. The only hint that STS is giving is the following message in the variable tab
com.sun.jdi.internalexception got error code in reply 35 occurred retrieving 'this' from stack frame
Also, this is only happening in my custom classes, if I place a breakpoint in any other library class variables are shown as expected. What could this be?
It seems you run into Eclipse bug 531706 which was fixed in Eclipse Photon (4.8). The current release is Eclipse 2018-12 (4.10). Please upgrade.

xdebug/netbeans won't stop at any breakpoint other than in Joomla index.php

I'm a newbie with IDEs, I used Eclipse so far but more like an fancy text editor. I now switched to Netbeans and set it up for Joomla extension development, for which I followed the steps in various tutorials.
Everything works great except debugging. I set up xdebug and it works if I have breakpoints in the Joomla index.php file, but breakpoints in the php files of my component (for example in on e of the model functions) were just ignored.
My setup:
Joomla 2.5
Netbeans 7.4
XAMPP 3.1
xdebug
In both eclipse and netbeans, a prerequisite for debugging is that the project is built.
"Building" doesn't do anything real: php code is not compiled. But it allows the IDE to build a dependency tree, validate the code, allow code completion and follow execution flow from one class to the next.
To build, in eclipse either right click on the project or choose Project/Build from the menu. I have set Build automatically so the resources stay in sync while I work:
I encountered with the same problem, but solution is rather tricky. Actually netbeans stops on breakpoints but no all lines are eligible for breaking. When you put breakpoint wait a little, if beside green square there appears black arrow pointing down then it is OK, otherwise try some other line.

Eclipse "source not found" rt.jar

I'm developing Eclipse plugin, but when I want to start debugging mode, it stops and shows this:
http://i47.tinypic.com/oicbbp.png
And I don't know what to do with it. Is there any solution?
[EDIT]
But if I start it normally (no debug mode), it starts without any warning or errors. It shows that error only in debug mode.
Note that tr.jar (what the title had) is very different to rt.jar because the rt.jar contains the core classes of the J2SE! This is basically saying that Eclipse cannot find the source for the J2SE because it was not attached to the IDE. If you start Eclipse in 'no debug' mode, the source becomes irrelevant.
When you try to reach that class it couldn't find the source code of this "ResourceBoundle" class. You can search it and add it after that you can see the codes in eclipse.

Zend Debugger Eclipse Startup Error: eclipse.php.debug.core was unable to load class debug.core.model.PHPConditionalBreakpoint

I work on Mac OSX Lion and ever since I've installed the Zend Debugger and gotten it to be able to debug php web applications, I often encounter this Eclipse startup error:
Error creation extension for extension-point
org.eclipse.php.internal.debug.daemon.communication Plug-in
org.eclipse.php.debug.core was unable to load class
org.eclipse.php.internal.debug.core.zend.communication.DebuggerCommunicationDaemon.
An error occurred while automatically activating bundle
org.eclipse.php.debug.core (258).
The error log contains the following stack trace:
org.eclipse.debug.core.DebugException: Plug-in org.eclipse.php.debug.core was unable to load class org.eclipse.php.internal.debug.core.model.PHPConditionalBreakpoint.
at org.eclipse.debug.internal.core.BreakpointManager.createBreakpoint(BreakpointManager.java:554
at org.eclipse.debug.internal.core.BreakpointManager.loadBreakpoints(BreakpointManager.java:264
at org.eclipse.debug.internal.core.BreakpointManager.initializeBreakpoints(BreakpointManager.java:449)
at org.eclipse.debug.internal.core.BreakpointManager.getBreakpoints0(BreakpointManager.java:418) at org.eclipse.debug.internal.core.BreakpointManager.start(BreakpointManager.java:408)
at org.eclipse.debug.core.DebugPlugin.start(DebugPlugin.java:682)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
... Omitted for brevity ...
This error often goes away when I just restart eclipse a few times. I've googled for solutions and tried reinstalling eclipse a couple of times. This error only seems to occur if I have both ADT (Android Development Tools) and PDT (PHP Development Tools) + Zend Debugger installed.
Please let me know if you have information about how to solve this problem. On a related note, I never really got the PDT + Zend debugger to work (as in debug) PHP apps on Windows.
I have seen this error a few times, even in the Zend Eclipse PHP version. It only seems to happen when two things are true:
1) The "breakpoints" view is visible on eclipse start (that is, you can see where breakpoints would be listed)
and
2) The file open and active in the editor is NOT a PHP file
For example, I got this repeatably with a CSS file open in the editor on the debug perspective with the breakpoints tab active.
To get around it: Start eclipse and ignore the bug about loading the plugin (for now). Make a PHP file the active document in the editor, and change from the debug perspective to the PHP perspective. Close eclipse and restart. On restart, the error should be gone and debugging should be active again.
I can't guarantee this is the solution everytime, but I can reliably replicate this failure (and solution) with the breakpoint/non-PHP conditions described above.
I had a similar issue (yours came up top of Google when I pasted my error message) after a few similar and different errors I decided to check my Eclipse workspace settings after an alternative workspace of mine worked and debugged fine.
It turns out my PHP executable pathway was empty (after having previously set it), so I added it back in. No problems so far.
(i.e. here...) Eclipse -> Window -> Preferences -> PHP -> PHP Executables -> Add/replace/reselect here.
UPDATE:
sometimes the simplest thing is to select 'Skip all breakpoints' under the 'Breakpoints' view (which opens in debug perspective). Then restart Eclipse. I have had similar error messages since first answering and that usually does the job (of course you can deselect 'Skip all breakpoints' after that from the same place.
This is a workaround instead of a solution, but so far, it's going good:
I downloaded and installed Eclipse for PHP Developers(aka Zend Eclipse PDT) version 3.0.2 from Zend website and I'm now able to debug Wordpress and Joomla, both pretty complicated projects as far as PHP goes.
I will update if I experience a problem.
I am using Eclipse Indigo on Ubuntu 12.04 and I received this error after installing Java 7. My PDT settings which used to work stop working. My solution was to uninstall PDT and reinstall it. I am not sure if this is relevant to your question but it might solve the issue.
Help -> About eclipse platform
click "Installation details" button
click php development tools (PDT) sdk feature
click uninstall
follow prompts
reinstall pdt in the normal way
My previous debug launches were deleted but my old project was left untouched. I re-ran a debug from Run -> Debug Configurations.
I've only ever gotten this after closing down an Eclipse php project that I've enabled various breakpoints in.
My workaround is once the project opens and I get the error message I select skip all breakpoints, close the project and re-open it. I then deselect the skip breakpoints and start working. The error, at least in my case happens randomly and for no other reason than I closed the project with breakpoints enabled.
Wish I had a more technical solution or fix but I decided my time was better spent working on actual work than chasing this deeper.
The problem happened when I closed Eclipse while a project was still running in debug mode.
I did more or less the same as #rahvin_t to fix it.
Run > Skip all breakpoint. Close Eclipse, start eclipse and I could start the project again.
there are a few errors that happen on start-up similar to this one. They seem to occur when there are 'unusual' files open in the editor (e.g. css or javascript)
What usually works for me:
Close all your files in Eclipse (Ctrl+Shift+W)
Restart Eclipse.

Eclipse - Unable to install breakpoint due to missing line number attributes

I am getting this strange error in Eclipse while trying to set a breakpoint.
Unable to insert breakpoint Absent Line Number Information
I ticked the checkbox from Compiler options but no luck.
I had the same error message in Eclipse 3.4.1, SUN JVM1.6.0_07 connected to Tomcat 6.0 (running in debug-mode on a different machine, Sun JVM1.6.0_16, the debug connection did work correctly).
Window --> Preferences --> Java --> Compiler --> Classfile Generation: "add line number attributes to generated class file" was checked. I did a clean, recompile. I did uncheck it, recompile, check it, recompile. I made sure the project did use the global settings. Still the same message.
I switched to ant build, using
<javac srcdir="./src/java" destdir="./bin" debug="true">
Still, same message.
I didn't find out what caused this message and why it wouldn't go away. Though it seemed to have something to do with the running Tomcat debug session: when disconnected, recompiling solves the issue. But on connecting the debugger to Tomcat or on setting new breakpoints during a connected debug session, it appeared again.
However, it turned out the message was wrong: I was indeed able to debug and set breakpoints, both before and during debugging (javap -l did show line numbers, too). So just ignore it :)
In eclipse menu, go to Window->Preferences->Java->Compiler
Unmark checkbox "Add line number attributes..."
Click Apply -> Yes
Mark checkbox "Add line number attribute..."
Apply again.
Go happy debugging
This fixed my issue:
Window -> preferences -> server -> runtime environments
Apache Tomcat -> edit
Select a JDK instead of JRE
For Spring related issues consider that in some cases it generate classes "without line numbers"; for example a #Service annotated class without an interface, add the interface and you can debug. see here for a complete example.
#Service("SkillService")
public class TestServiceWithoutInterface {
public void doSomething() {
System.out.println("Hello TestServiceWithoutInterface");
}
}
The service above will have an interface generated by spring causing "missing line numbers". Adding a real interface solve the generation problem:
public interface TestService {
void doSomething();
}
#Service("SkillService")
public class TestServiceImpl implements TestService {
public void doSomething() {
System.out.println("Hello TestServiceImpl");
}
}
I have the answer to this problem from the BlackBerry SDK side of things: For some reason, no matter how many times I changed the options in the compiler, the actual underlying settings file did not change.
Have a look in the .settings folder of your project for a file called org.eclipse.jdt.core.prefs.
In there you can modify the settings manually:
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
edit: Further to this, I have noticed that sometimes I can ignore the alert Eclipse gives, and it will still stop at the required place... curioser and curioser... I put this into the bucket of things we learn to deal with when working as dev.
I tried almost every solution here and no luck. Did you try clicking "Don't tell me again"? After doing so I restarted my program and all was well. Eclipse hit my breakpoint as if nothing was wrong.
The root cause for me was Eclipse was trying to setup debugging for auto-generated Spring CGLIB proxy objects. Unless you need to debug something at that level you should ignore the issue.
This is explained in detail here:
https://github.com/spring-projects/spring-ide/issues/78
Just for future reference, this is the relevant part of the answer (ignore the fact that refers to a Spring Boot application, behavior is the same for lot of other cases):
Whenever you set a breakpoint in Eclipse/STS, the IDE tries to set the breakpoint in the VM if you launch an app. That is what happens in your case when you run the boot app in debug mode.
For each class that gets loaded into the JVM, the IDE checks whether it needs to set a breakpoint or not. If it decides to set the breakpoint, the tries to do so (using the information from the breakpoint definition in the IDE, including its line number, since you usually set line breakpoints on a source file at a given line).
This decision (whether to set the breakpoint on a given loaded class or not) checks the types that you set the breakpoint on, enclosing types, and inner classes. This makes sure that breakpoints for inner classes (even anonymous inner classes) are set to the JVM (and are not ignored).
Spring Boot generates an inner class for your controller at runtime (this is the CGLIB generated inner class that appears in the error message). When the JVM loads that class, it tries to set the line number breakpoint of the enclosing type (for this inner class). Since the generated inner class doesn't have any line number information (it doesn't need to have line number information), setting the breakpoint fails for this inner class with the mentioned error message.
When the IDE loads the enclosing type (your controller class itself), it also tries to set the line breakpoint and succeeds with that. This is visualized with the check marker on the breakpoint marker.
Therefore you can safely ignore the error message that shows up. To avoid this error message to show up, you can go to the preferences (Java -> Debug) and disable "Warn when unable to install breakpoint due to missing line number attributes".
Dont know if this is still relevant, perhaps another sailor will find this useful.
The message appears when one has a class file compiled the debug flags turned off.
In eclipse, you can turn it on by the afore mentioned options,
Window --> Preferences --> Java --> Compiler --> Classfile Generation: "add line number attributes to generated class file"
But if you have a jar file, then you would get the compiled output. There is no easy way to fix this problem.
If you have access to the source and use ant to get the jar file, you may modify the ant task as follows.
<javac destdir="${build.destDir}" srcdir="${build.srcDir}" source="1.6" fork="true" target="${javac.target}" debug="on" debuglevel="lines,vars,source" deprecation="on" memoryInitialSize="512m" memoryMaximumSize="1024m" optimize="true" >
Happy debugging..
ref:
http://doc.sumy.ua/prog/Java/javanut/ch16_04.htm
This worked for me:
Under Window --> Preferences --> Java --> Compiler --> Classfile Generation, all options have to be to True.
Made debug="true" in the build.xml <javac> task.
Deploy application in the tomcat by the war generated by ant
Restarted the Tomcat in Debug mode
It would help if you did indicate the version of eclipse you are using and the technology (Java JDT, or AJDT for Aspect Java, or C++ CDT for instance), just to be sure.
On the Java side, I suppose your "Ticked the checkbox from Compiler options" refers to this
Under "Window --> Preferences --> Java --> Compiler --> Classfile Generation", all 'Class file' generation options are set to True:
(1) add variable attributes,
(2) addline numbers,
(3) add source file name,
(4) preserve unused local variables.
Does your project have those checked only at the global level (windows Preferences) or at project specific level?
And are you sure the class opened (on which you try to set a breakpoint):
is one of your sources (and not coming from a third party library)
is a .java, not a .class?
Try to clean everything and rebuild all, check for potential jar conflicts.
I had this problem while attempting to start Tomcat in debugging mode from Eclipse. I had an ANT build file taking care of the compile and deploy. After setting the debug flag to true (as mentioned in other answers) and redeploying the application it worked fine:
<javac srcdir="./src/java" destdir="./bin" debug="true">
NOTE: if you've just added the debug flag and recompiled you still need to redeploy your application to the server since this is where Eclipse is debugging the class files. Very obvious but easy to spend an hour or so scratching your head and wondering why it's not working (trust me).
try to change the jre you use.Set the jre in the folder of JDK instead.
Since I have 6 different versions of Java installed, I had to change my default JDK compliance to match that of the Java version I wanted to use. Eclipse by default had compiler compliance level set to Java 1.7 when everything was built/compiled using Java 1.6.
So all I did was
In eclipse menu, go to Window->Preferences->Java->Compiler
Under JDK Compliance, I changed Compiler compliance level from 1.7 to 1.6
Now Eclipse doesn't complain about the "Unable to insert breakpoint Absent Line Number Information" anymore and the debugging breakpoints actually work!!!
If nothing else works, open debug perspective, clear all existing breakpoints and then set them back again.
My situation was similar:
I was debugging a JUnit test
I was using Mockito to create a spy, as in spyTask = spy(new Task())
I put the breakpoint inside of the class that I was spying (inside Task.java)
This breakpoint generates the error in question, every time I run Debug As... > JUnit Test
To address the problem, I moved the Breakpoint 'up' into the actual test (inside TaskTest.java). Once execution stopped, I added the breakpoint back where I had it, originally (inside Task.java).
I still got the same error but after clicking "ok," the breakpoint worked just fine.
Hope that helps someone,
-gmale
I had same problem when i making on jetty server and compiling new .war file by ANT. You should make same version of jdk/jre compiler and build path (for example jdk 1.6v33, jdk 1.7, ....) after you have to set Java Compiler as was written before.
I did everything and still not working. The solution was delete the compiled .class files and target of generated war file and now its working:)
Got this message with Spring AOP (seems to be coming from the CGLIB library). Clicking Ignore seems to work fine, I can still debug.
I found yet another reason for this message. I was programming Scala. The solution was:
Open Run -> Debug configurations
In the Main tab, on the bottom, beside the "Apply" and "Revert" buttons, there is a text saying which Launcher you are using, and beside it, there is a hyperlink saying "Select other". It is a strange UI element, doesn't look actionable at first glance.
Use the "Select other" link and choose "Scala Application (new debugger) Launcher". The other one doesn't seem to work with Scala.
Now the debugging should work. Notice that I have installed the Scala IDE plugin, this option may not be available if you don't have it.
Above things didn't work for me.
Below solutions finally worked.
Debug Configurations -> Classpath -> User Entries -> (Add src folder of the project you want to debug.)
I had this same problem when debugging a WAR (constructed from multiple Eclipse project artifacts) deployed to Tomcat.
I am building everything using an ANT build script. If this is what you are doing, make sure that the debug=true flag is set on every javac ant task you've got. This was my only problem - I hope it helps your problem!
I had the same error with JBoss 7.1..
And I did the same as Zefiro. Just ignored the error and i was able to place breakpoints normally.
In my case i was building thought ant builder and this is my javac task:
<javac
srcdir="${src.dir}"
destdir="${build.classes.dir}"
includeantruntime="false"
debug="${debug}"
verbose="false"
debuglevel="lines,vars,source"
source="1.6"
target="1.6">
<!-- Sppressing warning for setting an older source without bootclasspath
(see: https://blogs.oracle.com/darcy/entry/bootclasspath_older_source) -->
<compilerarg value="-Xlint:-options"/>
<classpath>
<fileset dir="${lib.dir}" includes="*.jar" />
<fileset dir="${jboss.lib.dir}" includes="**/*.jar" />
</classpath>
</javac>
I got the same issue, I spent a lot of time to look for solution but these solutions are unuseful, So I self study all of cases, finally I found out problem it is confliction among JDK versions.
Below is steps to resolve problem:
1. Remove all of JDK and JRE version, keep only one version.
2. Set JAVA_HOME system and java compiler in Eclipse is the same.
In some cases, the error above will not disappear, but we be able to run at debug model.
Once I experienced the same error when I used junit and Mockito, I forgot to add #PrepareForTest for a static class.
Add below code fixed my problem.
#PrepareForTest({XXXXX.class})
Not sure it was the same case.
My problem was I had 2 JAR's and I was trying to override one with the other based on its order in the Java Build Path => Order & Export tab in Eclipse, because one was for debugging and the other was not (the debugging JAR being first in the order). When I did it this way, I had to manually attach a source.
I tried removing the non-debug JAR and placing the debug JAR in my \WEB-INF\lib\ directory, cleaning, building, etc., and it worked. This time (having removed the attached source), it automatically would let me navigate through the debug code, without having to attach any source manually. Breakpoints and debug also worked.
In case anyone is still having trouble, I also tried all of these particular solutions mentioned in the other answers:
Uncheck, apply, and recheck Add line number attributes...
Manually editing org.eclipse.jdt.core.prefs as mentioned in another answer: https://stackoverflow.com/a/31588700/1599699
Ensuring the JAR was being generated with debug enabled.
Changing the JDK compliance level from 1.6 to 1.7 (thereby matching the JDK I was using).
I also did the usual shutting down of the server (and making sure java.exe is actually closed...), deleting the \build\ directories in both projects, restarting Eclipse with the -clean parameter, recreating the debug JAR, refreshing, cleaning, and building the project with the debug JAR in it, starting the server in debug mode, publishing/cleaning, and breakpointing.
I was facing the same issue in my eclipse IDE. I read all answers of this question and tried almost all mentioned settings, but no luck.
So, I tried to changes the runtime lib of the project, previously it was JRE - Java SE 1.8
I tried changing the JRE to JDK and it worked for me:
Below are the steps to switch from JRE to JDK :
Right click on project
Click Properties -> Java Build Path
Select tab - "Libraries"
Click on "Add Library" button. "Add Library" window will open
Select "JRE System Library" -> Click Next button
Select "Alternate JRE"
Click on Installed JRE button
In New window click on "Add". This will open another window "Add JRE".
Select "Standard VM". Click Next.
Click on Directory button.
Choose path of your "JDK" installation directory and click ok. Then Click Finish.
Now check on newly added "JDK"
Delete all other installed JRE's from the list(Optional)
Apply-> OK
Select "JDK from alternate JRE dropdown and Click on "Finish"
Now from the list depicted below remove JRE instance
Click Apply -> OK
And you are done!!
I had the same error in my Eclipse IDE.
But it seems it is an ignorable error.
I pressed Ok on the error dialogue box & continued.
My breakpoints were reached & i was able to debug further.
Check/do the following:
1) Under "Window --> Preferences --> Java --> Compiler --> Classfile Generation", all options have to be to True:
(1) Add variable attributes...
(2) Add line number attributes...
(3) Add source file name...
(4) Preserve unused (never read) local variables
2) In .settings folder of your project, look for a file called org.eclipse.jdt.core.prefs.
Verify or set org.eclipse.jdt.core.compiler.debug.lineNumber=generate
3) If error window still appears, click the checkbox to not display the error message.
4) Clean and build the project. Start debugging.
Normally the error window is not displayed any more and the debugging informations is displayed correctly.
I ran into this problem as well. I am using an ant build script. I am working on a legacy application so I am using jdk version 1.4.2. This used to work so I started looking around. I noticed that under the Debug configuration on the JRE tab the version of Java had been set to 1.7. Once I changed it back to 1.4 it worked.
I hope this helps.
I was trying to debug the logging manager and needed to change the jre to a jdk and then to select this jdk in the "main" tab, "Java Runtime Environment" | "runtime JRE" of the debug configuration then all was well.
I saw this problem when I annotated a class with #ManagedBean (javax.annotation.ManagedBean). The warning message came up when running the newly complied app on JBoss EAP 6.2.0. Ignoring it and running anyway did not help - the breakpoint was never reached.
I was calling that bean using EL in a JSF page. Now... it's possible that #ManagedBean is no good for that (I'm new to CDI). When I changed my annotation to #Model, my bean executed but the breakpoint warning also went away and I hit the breakpoint as expected.
In summary it certainly looked as though the #ManagedBean annotation messed up the lines numbers, regardless of whether or not it was the wrong annotation to use.