How to configure hot deploy in eclipse maven project - java

I have a maven project on eclipse, but when i restart the tomcat server inside eclipse, changes are not reflected on my app.
I´d try to do two tests:
First - make some changes on a single javascript file and restart tomcat, and works great.
Second - make some changes on a java class and restart tomcat, and nothing has change on my browser.
Anyone could help me?

you need to configure your tomcat to hot deploy your application.
http://www.mkyong.com/eclipse/how-to-configure-hot-deploy-in-eclipse/
Follow this tut.

Related

Deploy java web application to Tomcat with Visual Studio Code

I'm trying to deploy a java web application to Tomcat using Visual Studio Code and I'm having some issues that I'd like to share.
After installing the extension Tomcat for Java, I've tried to deploy a Maven Java Web project. To do so, I've clicked over project's folder and selected "Run on Tomcat Server" option. The result is an error with this message: The folder is not a valid web app to run on Tomcat Server.
Then, I've realized that maybe I should create a war file before running it on Tomcat. Therefore, I've executed mvn clean package command and afterwards execute "Run on Tomcat Server" option over the war file. Doing this the project has been deployed correctly.
However, compared to Eclipse's way to work with Tomcat, it seems to me a bit tedious. Particularly if I'm working with static files, like css or js, because every time I modify a file I should execute mvn clean package and "Run on Tomcat Server". Whereas, in Eclipse, these files are deployed automatically on Tomcat without restarting.
I wonder if there is another way to work with VS Code and Tomcat for Java.
Thanks!
If you use Spring, there is an easy way.
The Spring Initializr extension comes with an embedded Tomcat installation, and hot reloading works out of the box.
Rely on the following guide to install it:
https://code.visualstudio.com/docs/java/java-spring-boot

IntelliJ IDEA stopped deploying webapp on tomcat

It uses tomcat to deploy. It used to run perfectly fine and when I pressed "Run" it opened a index.jsp in my web-browser which I used as starting navigation point.
But after I decided to try and run it without IDE, by copying contents into tomcat/webapps, something changed, although I'm not sure if it's connected. Now when I press "Run" inside project it just opens up a although absolutely nothing from my project got changed. And if you go into manager from there there are no applications running aside from manager itself, not even ones in /webapps in tomcat directory.
What exactly happened and how can I change it back?
UPDATE it's started working somehow. No idea why and what happened
Tomcat has a web.xml file where you can define your <welcome-file-list>
Please take a look at this
Also you can compile your webApp as a .war to deploy it on your Tomcat server.
Follow the instructions in this link if you need help.

Do I have to restart tomcat everything for every jsp or java change?

I am running tomcat v7.0 within my eclipse. I have to restart tomcat for every single jsp or java change. I am sure I have set my server wrong somehow. How can I see my changes without keep restarting tomcat?
Thanks!
When you are deploying to the tomcat from eclipse, If you are planning to work without deploying every time you to a change to the code base, you can use Jrebel.
Jrebel will sense your changes and take care of the re-deploying. Only issue is that It is a have to buy plugin and I know there are opensource or free applications like that.
If you are running the application in DEBUG mode, it will auto restart every time you make any change to ur JSP or java code.
You can try deleting the tomcat instance from eclipse and also the Servers folder that is present in the Project Explorer. Add your server to eclipse again and deploy your war file. The changes to JSP or javascript files will now reflect without a server restart.
That not necessary it's depend upon your configuration
When you configure Tomcat in eclipse then we have 3 option
never publish automatically
automatically publish when resource change
automatically publish after build event
so you can configure this as per your requirement.You get this option once you create tomcat server in eclipse ,then select the tomcat server,then either press F3 or right click and open.
i prefer point 2 to select and make sure you have uncheck build automatically in eclipse ,so that once you sure about all the changes you can build the project and tomcat get restart automaticcaly

How to deploy the war file generated by maven on tomcat using eclipse?

I have got a war file generated using Maven and it works perfectly fine when i manually deploy it on the tomcat server.
However, the war file was generated using Maven on eclipse and when i try deploying this on the server using eclipse, it just doesn't act. The tomcat server starts perfectly fine. What I do is : Right click on the Tomcat Server 7.0, then Add/Remove Project and add it to the server.
The problem is when I deploy and publish it on the server and nothing happens after that.
On trying to access it, it says - The required resource is not found
Eclipse doesn't deploy the WAR. Instead, it knows how Tomcat works and deploys the exploded WAR.
The next step is to look into the webapps/ folder of Tomcat to make sure Eclipse really has deployed something.
If that looks ok, you need to look into the Tomcat log to see why it doesn't like the deployed web app.
Most of the time, there is old code which is somehow stuck in Tomcat, so Tomcat can't undeploy the old version. If that's the case, stop Tomcat, delete the app manually and try again.
There were certain jars required in specific versions for the application to work. I was usin the maven supported versions. I have got it to work adding them directly in Tomcat's lib folder for time being and the application now works. (Anyways i need to look to get them configured now on the maven)
Also, i guess installing the plugin for m2e - eclipse.org/m2e-wtp helped as well. Thanks #Aaron Digulla for the inputs.

How to deploy Java project to Tomcat

I have downloaded a sample extjs+mysql+spring web project (link) with a java backend that I'd like to set up locally on my machine. I have installed Tomcat server, and MySQL DB but it's my first time ever with a java-based web application and I have troubles setting it up. Does it require any modifications ? I thought that .jsp files should be included there, but I can only see .java sources. Do I need to build it before it's ready for deployment ? Any help appreciated.
This is an Eclipse project so you'd need to run it from within Eclipse.
Download Eclipse
Open the project in it
Define a Tomcat container in your Servers tab
Drag and drop the project onto the newly defined Tomcat
Run it
if your are using eclipse IDE for development, create a project in eclipse,
run as "run on server" , and set the running server (eg TOMCAT 7).
and thats it,,
make sure, you correctly setup spring project in IDE with all needed jar files .

Categories