My issue isn't a new one, and I found several threads about it, yet no one was helpful for me.
I hope this one will.
I can't debug with eclipse. It recognizes breakpoints, switches to debug view, but somehow it gets out of sync and I can't debug my code. Sometimes It works, but after a while It happens again.
I work with JDK 1.6.0_24, Glassfish 3.1, eclipse INDIGO (but it also happens on HELIOS).
I tried (as I found in this site) to set eclipse to use Parallel GC. I tried put it in the eclipse.ini file, I tried to put in the glassfish VM arguments itself, and I tried to put it at eclipse JDK additional VM arguments (preference -> installed JRE-> JDK -> etc). Nothing seem to work for me. I also tried them all together.
Help me please..
Thank you all from advance,
Ido
EDIT:
OK, I noticed few more things:
On the Debug view, in my stck trace, I found the exact class with the breakpoint is paused and it had this comment: "(Suspended breakpoint at line XX)". When I clicked the line, suddenly the green line appeared. Yet, as soon as I clicked F6 to continue, It went out of sync again, just the next line became suspended. Weird.
I checked the processes running on my computer and found that there are several "java.exe" processes running at the same time. (eclipse runs on javaw.exe). Maybe this is why glassfish and eclipse refuse to work together.
I checked the build path and found that this is my output folder: project-name/target/classes. Is this good?
Any thoughts?
Ido
So, I couldn't fix this but I found a workaround that completely solves this - FINALLY!.
I just stopped using glassfish WTP for debugging and set a remote debug to my local glassfish. it works perfectly with few minor annoying things - but breakpoints finally noticed.
Set remote debug
Go to your glassfish admin console and set your glassfish to work on debug mode.
Click on configuration --> server-config --> JVM settings, and check debug enabled check box.
Restart server
In eclipse - start server on normal mode (not debug - it is useless).
Go to Debug configurations and locate "Remote Java Application"
Create a new Remote java app debug config
Enter name (lets say Glassfish-Debug)
Choose project to debug
Enter your own IP address in the host section and set the port to 9009
This is optional but it is more comfortable to work with:
Go to "Common" tab, and check the Debug check box. This will make this Glassfish remote debugging configuration constant on your debug menu.
That's it. Now all you have to do is always start your Glassfish in normal mode and then go to Debug configurations and run This Glassfish remote debugging you just set.
And now I'm getting to the annoying part: After rebuild your project, sometimes you might get again out of sync. You just need to disconnect the remote debugging session and run it again. Small price to pay.
I hope it helps..
I had faced similar issues, But it turned out to be a simpler problem of multiple versions of JREs/JDKs installed.
Try Debug -> Run Configuration -> JRE -> Alternate JRE -> select JDK 1.6.0_24.
Also check for project build paths if correct Jars are been used.
Hope this helps.
Related
I'm migrating from Eclipse IDE (+ VSCode for coding Java servlets and HTML/CSS/JS webpages, respectively) to only Visual Studio Code for its lightweight.
I have several Java extensions installed for VSCode:
Language Support for Java(TM) by Red Hat
Tomcat for Java
Debugger for Java
Eclipse has a series of settings for hot reloading:
- Automatically publish when resources change
- Refresh using native hooks or polling
while VSCode doesn't seem to have any for me.
A few things I've try to reload my Java and web code:
Restart Tomcat server
Delete and re-adding Tomcat server
Delete and regenerate .war package (not sure if this does anything, it can run well without a .war package)
Good news...
It works automatically now. With Tomcat for Java Extension (And the rest of the Java Extension Pack):
https://marketplace.visualstudio.com/items?itemName=adashen.vscode-tomcat
Just make sure your settings are like this (search for "java.autobuild" to get those two in the first results):
Very important is, that you wont see any logs in the console on the HCR (Hot Code Replacement) like it happens in Eclipse ... but you in fact will see the replaced code behavior. Just debug over the piece of code you changed, and you will see it in fact changed in the running server.
UPDATE: I've found it works better with the 'manual'(default) setting. Just clicking once in the lightning icon. (Testing in Ubuntu 18.04 LTS)
[I say it works better because if I added lines to a Class' code with the 'auto' setting it will not add that code ... only if I change code in the existing lines. But with the manual setting I just save the file, and then click the lightning icon wait ~3 seconds myself and debug over the new code ... and everything goes well!!
... This solves my coding needs(lightweight Editor/IDE with Hot-Code-Replacement in Tomcat)]
Enjoy !
This article may be helpful, I migrate from other IDE to Vscode.
According to the article, if you install Debugger for Java, it enabled Hot code replacement(HCR) and then :
You can start a debugging session and change a Java file in your development environment, and the debugger will replace the code in the JVM running your code.
Hot code replacement for java comes to visual studio code
Install “Tomcat for java” extension in VScode.
Configure the Path of Tomcat in the above extension.
Now you should be able to run tomcat in usual build -> deploy mode. Now install DCEVM, By using “java -jar installer-light.jar”. (Select “Install DCEVM as altjvm”)
Place HotSwap Agent Jar in directory of your choice.
Now In VScode right-click the Tomcat server you have created. (The one from Step 3 ) And select “Customise JVM Options”.
In the file opened, Place “-XXaltjvm=dcevm
-javaagent:/[your_directory]/hotswap-agent-1.3.1-SNAPSHOT.jar” Now Right-click the tomcat server in VScode and select “Debug WAR package”, And select the WAR file.
If everything goes well, The WAR will be start in TOMCAT in debug mode with text “HOTSWAP AGENT” in the log.
Now your every save to your file will trigger Hot Reloading.
https://medium.com/#manoj_makkuboy/hot-reload-java-8-tomcat-server-in-vscode-ba6233d632e?
I'm working with a spring based project in java 1.6. I have a remote debug configuration to local tomcat server which worked without problems. Today I have encountered a problem with it. I place breakpoints in my code but they have not the valid symbol and are ignored while debugging, I have no idea why. I tried to clean/rebuild the project , invalidate cache but no effect. Any ideas?
How do you connect to tomcat procces?
From Intellij debug button, or do you start tomcat manualy, with debug keys in tomcat's proccess?
Are you 100% sure, that this line of code should execute? Maybe it makes sence to log anything on that line of code, so as too see that a problem is definatly in debug-connection?
I'm using IntelliJ IDEA 15.0.2 (Community Edition) under Windows 7 and Windows 10 Pro, Gradle 2.9, JDK 1.7.0_65. Operating systems installed as guests under VMware Workstation 11.1.3
I have created Android Gradle application with single empty activity and wanted to check how unit test support works. There is a single unit test module ApplicationTest.java created by IDE, it contains only constructor. Right-clicking on [java] folder I created 'All in Module' JUnit3 test configuration.
Tests complete successfully when I Run them, however fail if I Debug the configuration. Failure reason says 'Terminated' (screenshot, IDEA log) which explained in the documentation as 'Test terminated. This status is assigned to tests that were cancelled by clicking the Stop button'. Just want to confirm that I didn't click the Stop button.
Logcat logs don't report any failures, IDE log reports 2 tests passed too. However problem remains as IntelliJ still reports a termination.
Sometimes I also getting 'Test framework quit unexpectedly' error and no tests succeed.
I've done some research and found similar questions, no real solutions mentioned. Have strong suspicion that this is a configuration issue.
What do I do wrong?
Gabor's suggestion seemed to fix this issue for me. On a Mac (and I presume on a Windows machine, but with a different route to get there) go to Preferences:
From the menu bar at the top Android Studio → Preferences
or
Hit ⌘ and , to jump straight to it.
Then in the menu search box type "instant". Uncheck the box that says "Enable instant run..", which looks like the image below.
That fixed it for me; didn't even need to restart/kill ADB.
It seems to be enabled by default, and I use it often to hot-swap changes during development, so I didn't think to turn it off when running Espresso tests.
In my situation, the problem is solved by setting in the test's run configuration:
Shorten command line -> JAR manifest.
To get rid of unit test problems in debug mode, I deleted all test folders in android studio explorer, then I commented three test implementation lines in build.gradle(module) file. Then I changed the combobox in android studio menu (top of the IDE) from "all in app" to "app".
https://i.stack.imgur.com/alPrS.png
In our case the fix (that may not be required in newer Android-versions) was to:
Open Edit Configuration... for All tests (or what ever you renamed it into).
Switch to Debugger tab.
And finally, in Debug mode combo-box, select the Java option, because:
Although we have lots of Native codes,
Android-studio 3.2.1 (which we were using) does not seem to support debugging both (but Java only mode works fine).
I know this is a frequently asked question, but i have been searching for a solution for my problem online since yesterday and have not been able to find any!
I am using Eclipse Helios with Tomcat 6.0.2, when ever I try to debug my code using the tomcat and eclipse i am getting the error Source not found, this is the case for even the code that i have wrote myself and not just all the jar files
I have the java build path set up correctly, I am also using jdk1.6.0 and have this set up correctly as well so that is not the problem, it does show the code when i am debugging if i right click on the debug console and go to Edit Source Lookup.... Because this will show the source code just for that run of the debugger, I when into Run -> Debug Configurations and in the Java Application window i set it up to work with Tomcat and in the source tab I added my project and all the jar files but this does not work either! when i debug again and go into the Edit Source Lookup... it does not show me the project and jar files that I have saved in there
Does anybody have any ideas what might be happening?
Its actually very easy.Click on "Edit Source Look Path". You ll get the next popup where you need to click "Add"--> This gives another popup where you could click on "Java Project"---> THis leads to another popup where you can select your project which you are debugging and this is done! Hope this works fine.
I have solved my problem, well in a roundabout way. In my catalina.bat file I have added the line
set JAVA_OPTS= -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=5001,server=y,suspend=n %JAVA_OPTS%
below where the JAVA_OPTS are set, this will listen on socket 5001 for any debug requests. Then in eclipse, under Debug Configurations... i created a new Remote Java Application and set the port to 5001 so that Tomcat would pick this up. Now when i start tomcat using startup.bat, when the code hits a breakpoint it opens in eclipse and I can debug like normal
Hope this helps others that have this problem
Can you debug code in other projects?
if you don't know, create a new dummy project and try to debug it
if you still get source not found for all projects, then download a fresh copy of eclipse, link it to a fresh copy of tomcat and add your dummy project to see if this work.
Hope this helps
I'm running Eclipse Helios Service Release 1, with Tomcat 7.0.12 in Linux Ubuntu Natty Narwhal.
I've been happily hot re-deploying my webapp until it stopped working for apparently no reason. The following exception is displayed:
SEVERE: Allocate exception for servlet Index
java.lang.ClassNotFoundException: obliquid.servlet.Index
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
In Servers tab I've "Tomcat v7.0 Server at localhost [Started,Synchronized]
My project appears as a child of Tomcat v7.0 Server
In Properties, Java Build Path, Source I've Project/src Source folder
In Properties, Web Deployment Assembly, I've the following mappings: /WebContent -> /, /src -> /WEB-INF/classes, /test -> /build/classes
My src directory contains a Servlet in obliquid/servlet/Index.java
I tried already to click on Clean Module Work Directory... and Publish
I tried to stop and start the Server from within Eclipse Servers tab
What else should I check? Thank you.
UPDATE Despite now I'm working with the new project, I came back to check the old one, and mysteriously now it's working. I think I won't be able to find what has happened.
However today with the new project, I had 404 errors with no apparent reason and I found out that right clicking on the Tomcat server and selecting "Clean..." can be useful. Maybe it could have helped.
Selecting "Clean..." says: "Clean will discard all publish state and republish from scratch. Are you sure you want to clean all published resources?". Selecting yes, I solved the problem
UPDATE 2 It happened again on the new project. 404 errors, this time they don't go away.
Stop -> Clean... -> Start (404)
Stop -> Clean Tomcat Work Directory... -> Start (404)
Stop -> Clean Tomcat Work Directory... -> Clean... -> Start (404)
Stop -> Remove on the application -> Clean... -> Run As -> Run on Server -> (404)
Exit Eclipse, Start Eclipse
Start the server -> (404)
UPDATE 3 It turned out that this time I just didn't notice an exception caused by a listener-class during startup. After solving the problem, it worked. Guess I should stop working at 3 AM.
While on Tomcat 6 and Eclipse Ganymede I found out the following chain to work like charm:
1 stop server
2 project -> clean
3 project build (I had automatic build disabled)
4 delete server
5 delete Servers folder
6 restart Eclipse
7 create new server, add project and start :)
takes some time but worked like charm. My problem was a irritating Listener start problem, but this seems to be something similar: a property at tomcat. Btw: nowadays I am also a big Glassfish fan.
I found that this procedure is useful:
Click on Servers tab and Stop the server in use if it's running
Right click on the server again and select Clean...
Right click again and select Clean Tomcat Work Directory...
Hopefully the ClassNotFoundException should be gone now.
Another time I had a problem with a class launched at server startup, an exception in a listener class (ServletContextListener). When a ServletContextListener raises an exception during startup the application deployment is aborted, hence the 404 errors. In that case fixing the problem that caused the exception, made the application working again.
EDIT: This shorter procedure worked for me most of the times, but today didn't work and I had to follow Mico's extended procedure. My suggestion is, if you have a similar problem, first try this shorter procedure. If the problem persists, try with Mico's.
I'd recommend that you stop and start the Tomcat server again. Hot deploy does not work forever; there are some issues that will cause you to have to restart after a few redeploys.
I wonder when I see the accepted answer with +25 is it really accurate?
First if you are going to delete the server then whats the point in cleaning it? It will take your time unnecessarily and nothing useful will you gain.
So i will say just 5, 6, 7 steps should do the magic
5 delete Servers folder
6 restart Eclipse
7 create new server, add project and start
This could be something I learned on con-fess 2011. For me this sounds like a classloader problem.
The theory behind:
Java does not only use the type of the class but also the classloader which loaded it to identify the type of an instance. This means a simle operation could fail, e.g.
ClassA a1 = new a1;
ClassA a2 = SomeOtherClass.giveMeInstanceOfA();
a1 = a2;
This example would fail if SomeOtherClass uses a different classloader because Java would say that they are not the same.
The speaker also mentioned that some servers use per default about 45 different classloaders.
What does this mean in practice:
You deploy your webapp to the server, everything runs fine. The server caches the classes and everything he needs to load them somewhere. Now you make a hot deploymen and the server may loads new classes with a new (or different) classloader. This is the point where it starts to become dangerous because from now on you have two different classes in the memory which should be the same. Simple operations like casts (ClassA a = (ClassA) new ClassA()) fail, new Methods within the class are not found (because the server takes a cached version without this method),....
This is the point where I restart the server, clean the working directory (to get rid of the cached versions) and start thinking about hot deployment as critical thing.
If it is possible to try Mikkos procedere and this solves the problem this explanation could help you understand why.
I know this does not solve your problem but could give you some hints what maybe could have happened.
Speaking of hot deployment of Tomcat, you would indeed experience various problems, the least of which is memory leak, which is why you would have to restart the application. I would recommend to try JRebel for fast turnaround of "make and save any changes and then refresh the browser and see the changes immediately". You can find the JRebel hands-on lab, which shows how to use it with Tomcat and Eclipse. http://www.javapassion.com/rebels/jrebel_basics/
I have gained some new experience on programming and I am not anymore starving on Eclipse + Tomcat combination. Several ways here can help you out of the need of the usage of that combination:
First of all, don't use them together!
You can use other available IDEs, e.g. IntellijIdea (that is not free, but is worth of investing) has an property that when you debug a Java code, you can change code on fly and compile the Java files one by one and then it suggests if you'll want to have it updated on server. No restart needed almost never (of course it sometimes gets lost, but mainly it works).
Use standalone tomcat server, not the one inside Eclipse / your IDE. That first trick works only when you debug external server, nothing inside IDE. There comes the second tip: if you happen to change only jsp or html content, those files can be copied to the right place inside tomcat's webapp folder manually with unix cp or windows copy command and if you happen to develop files in same foulder long time, you can copy the folder content (e.g. myFolder/*.jsp) as many times as you wish and no restart is needed at all. The changes come visible when you touch or edit&save the web.xml file inside the webapps folder and then after that with refreshing the visible page on browser. Probably hard refresh with CTRL+F5 is the best way.
Thanks to #Verdan about his comment, otherwise I wouldn't have came back to answer again.
I was able to solve this by disabling the maven nature (right click on project >> maven >> disable maven nature). Then re-enabling it (right click on project >> configure >> convert to maven project). I had tried all of the other tips and tricks above, but this is the one that finally worked.
I was running into the same problem - tried all of the above, Eclipse always freezed when i tried to start the server, even after i deleted all the server configs and created a new one with a freshly downloaded tomcat instance. Anyways, problem wasnt solved until i moved to a new workspace, reimported the projects and created a new server. Seems like an Eclipse bug to me...So in case nothing else works, this is the way to go...
I'm currently struggling with the same problem, but nothing mentioned here does not help me. Anyway, I found out that if I:
stop server in eclipse
run tomcat elsewhere (in my case the xamp distribution)
stop currently running tomcat
start tomcat in eclipse
everything works just fine, of course until I change something in code and try to test it again.