Tomcat inside of eclipse doesnt take into account my modifications - java

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.

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

Run an application from workspace

I'm working with a big project with eclipse and WebSphere plugin. Normally, when I run or debug the project from eclipse, the workspace folders where used. But recently I changed something or maybe was an update of eclipse that broke it, I don't know. Now when I run the project it deploys it to a temporary folder and then WebSphere serves it from the temporary folder instead from the workspace.
That breaks every simlink that i have to serve content from out of the workspace.
Does any one knows why the behavior change in eclipse ?
Is there any way to change it back ?
Is there any alternative solution to
keep the simlinks in the temporary folder ?
As to why it switched, I have no idea. But for changing it back, if you're describing what I think you are, try double-clicking on the WebSphere server definition (or right-click > Open), and see the section "Publishing settings for WebSphere Application Server":

Running dynamic web projects on Eclipse brings up a 404 error in Tomcat 7

I'm not entirely sure why this happens.
Right now I'm able to build the project without running into any issues, and it deploys to the eclipse tomcat server that I have running
So with that kept in mind, the index here is hera.jsp, which I have set in my web.xml file:
to make matters worse it seems like no matter what I try I always get this same error message:
All I can think to include to make this more complete before posting is my build path and the server settings, so here's those as well.
I had similar problem. First of all:
Check if all the sources are copied to tomcat7 webapps, especially hera/WEB-INF/web.xml.
If its not there, try to create dummy folder in your project, e.g. "hera/fix", and in your
"project properties->deployment assembly" add this folder (as a result, "hera/fix -> /" mapping should be created). This worked for me when the eclipse plugin didn't want to copy web.xml.
Check in "project properties->deployment assembly" if all needed libraries are there, if not, add them.
Check why you have problems in src in your eclipse project, as that may interrupt or conflict the dynamic project deployment from eclipse.
Hope it helps.

Running JSP application using tomcat 6.0 and Eclipse

I am working on an academic project using Eclipse 3.X , jsp's, servlet's etc. The server i chosed to deploy my application is "Tomcat 6.0".
when i change any of my code in the application, i am facing problem with running the application. the changes in the code are not showing any affect even though i restart the server. the changes only get affected, if i restart my eclipse. i tried lot of ways by googling about integration of eclipse with tomcat but nothing worked?. I always have to restart the eclipse, to see my changes.
Please help me with this issue.
thanks in advance.
You should simply be able to use the "republish" feature after saving/building.
1, If the development path and deployment path is the same dictionary, make sure that the "Build Automatically" is checked, it's in "Project->Build Automatically", it can help you deploy the files which are changed.
2, If the development path and deployment path is not the same dictionary, you can write an ant task to deploy project.
if u are running in eclipse it is running the tomcat server of eclipse so for changes to be affected it should be refresh so u have to restart eclipse better way is to use outside eclipse and use localhost and tomcat manager u can restart and can see the changes or use ajax

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