NetBeans debugger doesn't stop at breakpoint - java

I'm running a test case in debug mode on a new installation of Netbeans 8.2 with a break point on a myId field.
#Test
public void testCreateDocumentSecurityNullRequest() throws Exception {
final Integer myId = 1;
myRequest request = null;
mockMvc.perform(post("/pathTo/apply/" + myId).contentType(contentType).content(json(request)))
.andExpect(jsonPath("$.code", is("400")));
}
I know the test is executed because I see the test results, but the debugger doesn't stop on my break point.
The Debugger Console shows:
Listening on 23206
User program running
LineBreakpoint myTest.java : 'line #' successfully submitted.
User program finished
I don't understand why it's not stopping and just continuing? I tried it in Eclipse and it stops and let's me continue as I would expect. I'm sure I'm just misunderstanding something simple but I read documentation and nothing sticks out to me. I also looked at some other Stack Overflow posts that were similar but those didn't seem to fit my issue.

I had a similar issue. NetBeans 6.5 won't stop on a breakpoint in my code.
I figured that while working with a project I changed source location (was: "project.6.5", I changed it to just "project").
NetBeans remembered the old source location ("project.6.5") which became non-matching as I ran code from "project". A breakpoint was displayed correctly (red square), but won't stop.
I opened Window > Debug > Sources and checked current code ("project"). Breakpoint became a broken square and it wrote in logs about source not matching.
After I unchecked old source ("project.5.6") it started working fine again.

...\AppData\Roaming\NetBeans\8.2\config\Services\org-netbeans-modules-debugger-Settings.properties - remove all 'breakpoint' lines from this file.

Related

Jsoup connection appears does not work and does not time out

I am working with the following line of code on a project:
Document d = Jsoup.connect(url).timeout(3000).get();
I'm using an IntelliJ debugger and when I get to this line of code, the debugger disables all of it's buttons and just says "the application is running." It does not timeout and it never throws an exception or continue. Does anyone know why this might be happening? If I take the following code
String url = "https://www.cs.purdue.edu/homes/bxd/";
Document d = Jsoup.connect(url).timeout(3000).get();
System.out.println(d);
and run it in the main method of a seperate class it works just fine.

Java, Eclipse, "Source Not Found" [duplicate]

This question already has answers here:
Eclipse java debugging: source not found
(33 answers)
Closed 9 years ago.
While debugging a relatively small program in Eclipse, I am seeing "Source not found" errors as I step through. Other questions state that this is usually an import/jar problem. In this case, I have no imported jar files, nothing fancy, just classes in the src/default package.
The specific behavior is this:
If the debugger is pointed at a line which instantiates a new object (e.g., "Foo foo = new Foo();") where the class, Foo, in question is in the same source directory and has a valid constructor, one of two things happens:
1) Either: Hitting F5 will take me into the class and onto the constructor signature; a subsequent F5 will take me to the dreaded "Source Not Found" error;
2) Or: Hitting F5 will take me immediately to the "Source Not Found" error
In either case, I can continue the debugging.... sort of. E.g., the debug session continues and stepping forward results in further steps through the program. (If I run this program without the debugger, or if there are no breakpoints at those locations, I see no problems. Hitting F8 and going to the next breakpoint will usually get me free of the problem.)
The Java Build Path source is set correctly (the src subdirectory of the project, which is where the default package is sitting.) The Java Build Path libraries has nothing but the JRE System Library, and as far as I know there are no name clashes. I can't think of anything else I'd need to do to the Java Build Path.
This is probably not related to the bug I am hunting with the debugger (NaN proliferation in numerical application) but it is distracting, and it is hampering my ability to get to the root of the problem.
Specific question: What is causing this behavior? Or is it expected behavior that I have not noticed before?
EDIT: Including Code
Loop2: for (int depth = 0; depth < maxDepth; depth++) {
for (int node = 0; node < policy.numMemory; node++) {
Belief belief = new Belief(messages, node);
nodeTraces[node] = new nodeTrace(policy, pomdp, messages, belief, depth);
if (nodeTraces[node].bestGain > bestGain) {bestTrace = node; bestGain = nodeTraces[node].bestGain; }
}
if (bestGain > 0.01) { System.out.println("breaking"); break Loop2; }
}
Setting a breakpoint at Belief belief = new Belief(messages, node); above, and hitting F5 will yield the Source Not Found message in the debugger. A code snippet from that class is:
public class Belief {
int numStates;
double[] belief;
public Belief(Messages messages, int node) {
// do some stuff
}
I stress again that there are no included packages anywhere in this project. All classes are mine and reside in the project's own source directory, which is included in the Java Build Path's source tab. If the suggested link above explains what it going on here, I am just not seeing it even after reading it three times, and I will be grateful if someone explains it to me in small words.
Eclipse may be missing the source of the standard library, i.e. the JDK.
This can be set via Preferences -> Java -> Installed JRE .

Java/Android - Crash - Apache commons-io-2.4.jar

I am trying to save values in a string to a file on my local system by using the org.apache.commons.io.FileUtils static method writeStringToFile.
So, first I downloaded the commons-io-2.4.jar, along with its javadocs and source and imported it into my Eclipse project through the Java Build Path. Everything compiles just fine.
However, when I add the simple line:
org.apache.commons.io.FileUtils.writeStringToFile(new java.io.File(Environment.getExternalStorageDirectory().toString() + "/logt.txt"), rslt.toString());
The program crashes. But, it doesn't crash anywhere near that statement. Instead, it crashes at the constructor of the Object which contains the method which calls this function.
In other words
Earlier in my code I create an object TranslateTask,
Which happens to contain a function call doTranslate().
The writeStringToFile call is made within the doTranslate() call,
However the actual crash takes place when I instantiate a TranslateTask object.
But, when I comment out the call to writeStringToFile(), the crash never happens
Even though the crash doesn't take place in the doTranslate() call...
So, just the mere mention of writeStringToFile() makes my program crash when I instantiate an object which contains it.
To make it more eary, I instantiate the object within a Try, catch (RejectedExecutionException e) block but instead the program crashes at this part:
PathClassLoader.findClass(String) line: 243 **Last call in the stack**
PathClassLoader(ClassLoader).loadClass(String, boolean) line: 573
PathClassLoader(ClassLoader).loadClass(String) line: 532
Translate$4.run() line: 159 **Crash happens here where I instantiate a TranslateTask object**
So PathClassLoader... Not sure how to approach debugging this. All I know is that if I commend out the org.apache.commons.io.FileUtils.writeStringToFile() call, the error never happens and the code runs fine everywhere.
Running this on the API8/10 of Android, using Eclipse Indigo.
EDIT- Logcat:
08-07 18:40:11.409: I/System.out(1395): debugger has settled (1363)
08-07 18:40:14.399: W/KeyCharacterMap(1395): No keyboard for id 0
08-07 18:40:14.399: W/KeyCharacterMap(1395): Using default keymap:
/system/usr/keychars/qwerty.kcm.bin
Don't think it gives any hint, but this is all that logcat gives after the debugger has settled.
EDIT2 -
For good measure, I just added
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
But still no go
EDIT3 -
I am starting to think the apache commons-io-2.4.jar doesn't work with Android inherently. Could that be it?
EDIT4 -
In case anyone wants to take a crack at it, here is my code. It is made in Windows 7, Eclipse Indigo. The code is based on the "Hello Android" translate section. All I am trying to do is extract some JSON into a string and save it into my sdcard. But, it has evolved into this mystery here...
https://dl.dropbox.com/u/10790286/Translate.zip (See TranslateTask.java line 111)
EDIT5 -
Interesting update. When I manually put FileUtils.writeStringToFile(new java.io.File("/mnt/sdcard/logt.txt"), "test"); into the eclipse expressions box during a debug, I get the following error
An exception occurred: java.lang.NoSuchMethodError
I don't understand why I would get this error because 1) the WriteStringToFile() function is in the commons-io source. 2) I can instantiate a FileUtils object 3) I imported it into my program.
Whats going on here?
Writing to the path "c:\\temp\\logt.txt" isn't going to work on Android. You can use something like Environment.getExternalStorageDirectory().toString() + "/log.txt" to write to the SD card.
EDIT:
The follow worked on my Galaxy Nexus:
try {
FileUtils.writeStringToFile(new File(Environment.getExternalStorageDirectory(),"log2.txt"), "HelloNow");
} catch (IOException e) {
Log.e(TAG,e.getMessage())
}
Though the programme runs succesfully in complier ,the programme crashes while it runs in android device .Because during the run time it checks over jar files within android dependancies only. I too had similar type of problem .I got it solved when in preferences/properties -> java build .Tick the external jar file .

how to use IConsoleLineTracker for reading console in eclipse

I have developed a plugin in which a java application is launched.In the console log of this application i want to be notified when new lines added.I have searched internet and found org.eclipse.debug.ui.consoleLineTrackers extention point.I have used it like below.
<extension point="org.eclipse.debug.ui.consoleLineTrackers">
<consoleLineTracker
id="com.plugin.util.MyConsoleTracker"
class="com.plugin.util.MyConsoleTracker"
processType="MyProcessType">
</consoleLineTracker>
</extension>
Then in my java code i have launched application like below.
config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, classpath);
config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH,false);
config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,MAIN_CLASS_NAME);
config.setAttribute(IProcess.ATTR_PROCESS_TYPE, "MyProcessType");
ILaunch launch = DebugUITools.buildAndLaunch(config, ILaunchManager.DEBUG_MODE,new NullProgressMonitor());
After these, i can launch my application successfully however my class com.plugin.util.MyConsoleTracker is never called.I cant see any error log either.
can anybody please tell me what i am missing here?
For an example you can see how it is made in m2e-core:
http://git.eclipse.org/c/m2e/m2e-core.git/tree/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenConsoleLineTracker.java
and
http://git.eclipse.org/c/m2e/m2e-core.git/tree/org.eclipse.m2e.launching/plugin.xml
Methed of YourConsoleLineTrackers should be evoked each time when a new line is showed up in console. Inside Line Tracer you have to distinguish to which process this line belongs to.
Marek

Another Netbeans issue | cannot find symbol method, but correctly declared

this has been a crappy day, besides the IDE not compiling/deploying because of this bug and waisting valuable time, I finally get it to deploy it suddenly I start getting this weird message (after compiling and running it several times):
T:\Users\Triztian\Documents\RHT System\RHTUBSDB\src\java\controllers\OrderSearch.java:64: cannot find symbol
symbol : method metadata(java.lang.Long)
location: class BO.CoverForm
OrderExtraInfoDTO foundInformation = frmCover.metadata(foundOrder.getReferenceNumber());
it is my understanding that this means that my method isn't declared, but thats not the situation as my method is clearly declared and coded.
CoverForm.java:
public OrderExtraInfoDTO metadata(Long ReferenceNumber) {
OrderExtraInfoDTO foundInformation = new OrderExtraInfoDTO();
try{
foundInformation = lnkAddInformation.fetchInformation(ReferenceNumber);
} catch (DAOException daoe) {
this.setError("additional_information", daoe.getMessage());
}
return foundInformation;
}
And the servlet that calls the CoverForm.java method.
OrderSearch.java (Extends HttpServlet):
CoverDTO foundCover = frmCover.search(foundOrder.getReferenceNumber());
OrderExtraInfoDTO foundInformation = frmCover.metadata(foundOrder.getReferenceNumber());
UpgradesDTO foundUpgrades = frmUpgrades.search(foundOrder.getReferenceNumber());
I've tried renaming the method and didn't have any success, any help is truly appreciated as I'm getting frustrated with NB 6.9.1 because of some crashes and another weird bug (might catch an entomologist's attention) which locks the editor and displays a message saying: "Refactoring cannot be done in the given context" whenever I press delete, forcing me to restart the IDE.
EDIT
Ok, so I've removed the classes that I posted and merged them in a more appropriate place, however I still get that silly symbol not found error but on a different symbol(another method) this time.
Netbeans 6.9.1 is a very robust IDE. You may run into problems like the one you mention above, if:
You run your NB without enough disk space available. Make sure that you have at least 2 GB free on your file system for the necessary temporary files.
You have a very large number of projects active in your project space. Reduce this number to just the needed projects, by deleting and reopening more often.
Hope this helps ...

Categories

Resources