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.
Related
I know Wildfly can't do hot deployment, but its able to do (at least) auto deployment.
I'm using Eclipse, and Maven.
I'd like that when I Run (or Debug) the project, it will compile the whole, copy the target .war to standalone\deployments's wildfly folder, and than Wildfly must be able to catch the change without restart the server, of course. So, once compiled, I can immediatly use the changes in the project.
How can I do it? I can't find any tutorial or tips online. Fancy help?
You could use the exploded content and jboss-cli or whatever client you want to overwrite your class file. But you will need to redeploy your deployment since hot-deploy through jpda only works if the code signature doesn't change. JBoss Tools should do that for you.
As far as I know, eclipse debug mode can make hot deploy to wildfly. But sometimes it would not work.
And Intellij debug mode can make hot deploy to wildfly, it works really well. But for add new class, new annotations, new method, new attributes still needs restart. Changing logic within method is fine.
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
Has anyone achieved hot-deployment of Java libraries (or even compiled Java classes) when using Trinidad?
My Rails application runs on Trinidad and depends on a Java backend that is packed as many jars under my-rails/lib/java. When one of these jars changes, Trinidad server doesn't reload it. touch tmp/restart.txt only reloads the app context.
Please note that my question is not related to config.autoload_paths, because as far as I know this option is used only to reload Ruby files.
UPDATED
I failed to achieve hot-deployment of my java dependencies and gave up. The only help for me were unit tests which I was launching locally every time to check my code.
I think if the .jar does not get reloaded than it's probably a Trinidad bug (since during context restarts jars should be re-added - assuming Tomcat does this by default - I'm not sure) ... would be great to know details (in Trinidad's tracker) e.g. if the jar is named the same, how does the configuration look like (if any).
The other option would be to try out a rolling restart since than a brand new context is created - thus it should pick up anything that the context depends on from the file-system.
Please note that auto-reloading on file changes such as changing a .jar file even though might work with Tomcat is on purpose disabled in Trinidad - you need to "explicitly" (touch ...) to request a restart.
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.
OMG - what is going on with Eclipse (3.3 Europa) - has anyone come accross this problem (bearing in mind I have been messing about with uninstalling different Tomat containers and installing others - but anyway thats another story)
When I change a line of code or remove a class within my project - when I come to debug - it actually goes to a line that is commented out and runs that line regardless!!!! e.g.
//System.out.println("you should not be able to read this!");
UPDATE: This can be solved by setting Project -> Build Automatically (see answer below).
REMAINING PROBLEM:
Eclipse is not keeping my hot deploy folder current with the latest changes to my project:
I found out to my horror that some old remenants of my project are 'hanging around' in the folder that I think Eclipse uses for hot deploys or something
C:\myJavaCode.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\myWebApp
basically it is not actually copying accross any changes made in the classes of my working dir!?!??
...anyway - in order to keep my project up to date - I have to modify this folder too - TOTALLY UNACCEPTABLE - as you can't develop in this way - it would take you eons! Anyway, if anyone can help explain to me what stupid thing I have done to get me in this mess and how I can get out of this mess - I would really appreciate it.
Have a look at:
Windows>Preferences>Server>Launching...
and:
Project>Build Automatically
maybe you accidentally disabled the auto-deploy features.
I had a similar problem, only without the added complexities of a web app. I'm just running a JUnit test and it's running the old code. I went into Configure Build Path, on the bottom of the Source tab, and looked at Default Output Folder, which said myproject/bin. The Package Explorer doesn't even show a bin folder, but when looking at the file system there's a bin folder there. I deleted the bin folder, refreshed the package explorer tree, and it worked. This behavior was in Helios and occurred with AND without Build Automatically selected...looks like a bug to me.
Dave
A super-silly question: Does all your webproject and related projects compile correctly?
Also check your output folder for classes (Project Properties -> Java Build Path -> Source Tab) then go to your filesystem and check permissions and modification dates.
Hope this will help you.
Probably the easiest way to get past this is to define a new server.
Right-click in the Servers window and select New, or when you do 'Run On Server' select Manually define a new server. You can have multiple servers defined using the same Tomcat runtime (they'll all have separate configs and deployment directories defined by -Dcatalina.base=...), but don't run them at the same time unless you change the ports they're listening on.
The new server will use a path like
<<yourEclipseWorkspace>>\.metadata\.plugins\org.eclipse.wst.server.core\tmp1
for the Tomcat conf and webapps directory.
Try running on this server. If it works, you can compare settings with the old one,
maybe try deleting the app from it and re-deploying, and figure out what you might have done to cause the problem. Or just delete the original server config.
As far as your second problem, I'm not sure. I'd try a new server config first, get it working, stop the server, do a 'Clean' on your project, delete anything in the tmp1\work\Catalina directory, and restart the server (you could remove and add your project to the server again too to be really clean).
Check the console messages too to make sure there were no errors related to this.