tomcat eclipse java spring not possible for debugging - java

Since two days it is not possible to debug my application, normally I use tomcat 8.0.27 for my project. When I use 8.0.39 it also does not work for the same project. I cleaned it, cleaned working space, delete it, installed it again and still it does not work.
When I try it with another project in another workspace, it works well ...
screen print error message tomcat eclipse

Related

IntelliJ IDEA doesn't redeploy changes

I have a Spring Web application and when I debug with IDEA's debbuger in Tomcat and redeploy the project after some changes, the changes are not deployed and debugger "sees" the old code (stepping through wrong or empty lines). Only thing that helps is to run maven clean install and then start the Tomcat again.
I tried clearing IDEA caches but it didn't help.
Hotswap also doesn't work, although I have correct options selected in settings, but I can live with that.
Note that I use redeploy not hotswap, so the whole application is started again, it should reload all classes but it doesn't. Only after maven build it works.
Note 2: I think it work ok one month ago, but no changes I can think of could do this (project- or IDEA-wise)
EDIT: So hotswap is now working OK (magically, I didn't do anything). But when I make larger modifications (eg. method signature change, etc), they are not picked up during REDEPLOY to the server. So I neeed to run maven clean install and start the server again to see the changes and for hotswap to work properly after method body modifications on this new code. Any idea why?
You need to check your run configurations of tomcat, in "Before launch" there should be Make and Build artifact steps, also be sure that all you changed classes are really compiling during redeploy - this is the place I would start from.
Also I don't get why you use redeploy instead of hot-swap? Redeploy is usually same time-consuming as restart server, but hot-swap is nearly instant. Though it allows only to change method bodies and constants, usually it's much prefferable then redeploy in development. Personally I'm using JRebel which is free for non-commercial projects now and restart server very rare.
EDIT:
I don't know why your classes are old even after redeploy, but the reason is 99% that they do not compile after changes into exploded folder. Doing maven clean install after each code change is too much (IDE compilation should be enough).
What I can suggest you is not to redeploy but to restart server after big changes. So that IDE perform Make, Build artifact and Deploy artifact tasks.
In addition to david.lucky hints, make sure that on your Tomcat configuration in the deployment section you're using an exploded artifact
I had exactly the same problem! I've spent hours in solving this issue.
I don't know why, but the solution for me was that (I'm working on MacOS High Sierra):
First, I had some of my tutorial projects, I was working on, on my Desktop in a folder /Desktop/tutorial/... These project were working fine. I could redeploy and Tomcat was recognizing the changes in my java files.
Then I started some new, own projects, and I placed them in my home directory, something like /Users/myHomeDirectory/WebApps/.
I could build and run these objects, but when I made changes, I had the same exact problem, that Tomcat was not recognizing the result. Only thing that helped out, when I clicked Maven-Button "Reimport all Maven Projects".
I tried really lots of different things. Nothing worked.
Then I thought, maybe, theres something wrong with my project. So I took one of my projects from Desktop and copied them into my home directory. But suddenly, I had again the same problem.
So here's my solution: I created a new project on Desktop again. And I don't know why, but now it's working fine. I really have no clue why. And believe me, I did not change any settings. I did exactly the same!
And regarding the life reload without redeploying. This works really fine for me (without any plugins like JREbel):
Go Run –> Edit Configurations –> “Deployment” tab, clicks + icon –> select an “exploded artifact”
Select “Server” tab, update the following options :
On ‘Update’ action -> Update classes and resources
On frame deactivation -> Update classes and resources
Run web application in Debug mode. Try to modify some codes or resources (Java files, ...), the modified classes and resources will be reloaded automatically.
This has been happening me for some time now Ultimate Edition after switching from eclipse to Intellij a few months ago.
Standard tomcat config and debug settings mentioned above used.
Intellij will show green popup after nothing to reload or reloaded one class.
Yet the debuggers bytecode is not the same reloaded/updated code.
You can force a recompile which will work for small changes ctr shift F9.
Other than that a clean install seems to work for annotation, method definition changes etc. If you try a recompile the debugger will fail the server.
So the answer is ctrl shift F9 on the file you change

Hot code swap is not working, why?

When I'm trying to write a simple one class console app - there is no problem. I can change code in a method when debugging.
The problem is with my web apps on Jetty. It's not working nor just in usual debug mode(pressing a debug button in eclipse) nor in remote debug mode described here. I can debug but can't change even usual not static methods, like adding sysout for example, I mean I can change it but after saving it's not updated and it works the same as before.
Also, I talked to my colleagues, it works for them but they use Spring Tool Suite version of eclipse, I tried and concluded that it works in the latest version STS out of the box in usual debug mode and it doesn't work in the latest version of Eclipse.
What can be a reason?
Answer based on my comments to the question (as suggested by OP):
Strange Eclipse behaviour can happen when your workspace or project metadata are corrupted. This can happen for example when you upgrade Eclipse version and use workspace created by the old version.
You should try to re-create your workspace and setup fresh project checkout. If the problem goes away, you know there was something fishy in the workspace metadata.
You would have to use hot swap proxy for swapping classes in EE container like jRebel.
Check it out.

Tomcat inside of eclipse doesnt take into account my modifications

I'm using a Eclipse and have embedded Tomcat. My issue is that sometimes when I edit my servlet, even when restarting tomcat inside of eclipse, the deployed project doesn't update, and seems to me that it's using a cached version of the files compiled.
How do I do efficiently to make eclipse & tomcat take my modifications into consideration? What folder do I need to clean?
I have found a good solution that doesnt need me to clean project each time. With it the context is reloaded whenever I modify my servlet.
In eclipse, Goto Project and activate the checkbox Build Automatically.

Problems with running a Java project under Tomcat after an Eclipse crash

This might be the ultimate newbie question, but I am really in a hurry and need a quick fix.
I have a Java project which I develop under Eclipse, and run under Tomcat, using the Eclipse plugin. Until last night everything was sound and fine. Then, I got an Eclipse error, which made me kill the Eclipse process ... and this morning, the project does not want to run.
It compiles, but as if Tomcat has no idea of my project library folder. When I run it, it starts screaming "class not found" exceptions. I did a little experiment of moving my project libs directly into Tomcat's library folder - it works, so clearly the problem lies in Tomcat, not recognizing my project lib folder any longer.
I tried cleaning the project, refreshing it and whatnot, but still the problem persists. I don't want libs t remain a direct possession Tomcat, because that makes a series of other problems and complications. I just want things back as they were last night before the crash.
A solution that seems to have worked - go to the Server view, right-click, then "Clean Tomcat working directory". It has always been there, I must have just been too hectic before to notice it.

Eclipse and JBoss not refreshing or rebuilding

I'm having this problem in eclipse (EE) when I change things in my code (even something as simple as the text I'm printing using println) it doesn't get applied. I'm using JBoss and when I rerun the servlet, nothing happens.
Any idea how I can force JBoss/Eclipse to do this? I can't preview anything so it's really annoying if I want to test some new code.
Thanks!
Eclipse publishes the newer versions of your application periodically (its called the automatic publish feature). Either the interval is too large, or you're not waiting sufficiently long enough for re-deployment, or automatic publishing of the application has been disabled.
Sometimes, despite ensuring the above, Eclipse might still not publish the newer classes, in which case you might want to perform a clean build, which causes the newly built classes to be loaded into JBoss.
Sorry to ask such a basic question: Do you save your changes before testing?
Eclipse uses its own compiler to check for syntax errors while you are editing, but you have to save the file before the edits take effect in the application.
I only ask because this could be confusing if you are new to Eclipse, having changed from a different IDE. File permission settings can also prevent your files from being saved or built.
Working on EJB deployed in JBoss with Eclipse IDE.
We have ANT build file, in which first old project is deleted from JBoss,
then compiling classes, & building proper directory structure & deploy as .ear - .sar again in JBoss directory.
Stop JBoss, run build file, start JBoss.
Its a good practice to have a build file to deploy project.

Categories

Resources