IntelliJ IDEA stopped deploying webapp on tomcat - java

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.

Related

How to configure hot deploy in eclipse maven project

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.

What is happening when I right click JBoss Runtime Server with a web project in Eclipse and choose "Clean"?

I usually do it when I add projects to Jboss or after changing datasource connection. But I don't know what is happening 'behind the scenes'.
It removes your deployed project from the web server. It has nothing to do with JBoss. Have you ever visited the directory where your application is deployed ?? If not, then I will recommend you to visit the directory where actually your web-app is deployed in JBosss. There you will see a folder named as your web-app something like this MyProjectEAR.ear if the project is an ear project with name MyProjectEar. Now I will ask you to click on "Clean". As soon as you do that, you will see that the folder vanishes, and later again appears when you again publish your app.
So to sum up, this action removes your deployed project and helps in re-publishing of your app. This helps in normal functioning if there is a major change in your app and the server fails to hot deploy it.

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 do you redeploy javascript in Idea when using a Tomcat configuration

I'm working on a java/javascript webapp that runs on tomcat.
We're working with IDEA and I've managed to get debugging set up for both the client and server code at the same time, which is great. I did have hot redeployment of the javascript set up when running Tomcat manually, however I find when running Tomcat through IDEA this doesnt work as it's setting stuff up somewhere in my users folder.
I was going to just set up a deployment configuration to go to that folder but I can't see any of the javascript files in there.
Is it possible to get the best of both worlds and have debugging and automatic deployment working together?
Update
Here's my config:
I'm using maven to build a specific profile rather than using 'build war exploded'. I suspect the latter wont work to build as quite a lot of custom properties need supplying by maven at compile time.
I also now have war exploded set in start up in deployment.
In Run - >Edit Configurations -> select tomcat instance.
then on update action : restart option
and in deployment tab instead of war use war exploded.
Now click on green button for run project it will ask option then select update resources and ok then refresh your page it will show change.
Keep one thing in mind that clear the cache.
Here is a screenshot :
It turns out I was having problems because I had antiResourceLocking=true in my tomcat context.xml config file.
I had switched this on as I was having problems with things hanging onto the war files and stopping recompilation.
changing to use antiJARLocking="true" instead seems to have solved both problems. Redeployment is now working in idea and I'm not experiencing problems with things holding files open

Trying to use tomcat with eclipse

I am trying to use tomcat with eclipse. I have installed it all and got the tomcat plugin installed. I have put a .war file in the webapps folder of tomcat and have made sure autodeploy is set to true. The problem I am having is that I can't get tomcat to run this .war file. The tomcat server is started and running as it tells me under the servers tab at the bottom of eclipse. It also shows the name of my .war file under it and says synchronized meaning it at least knows its there. But I can't get it to work at all. Even when I go to the local host page it shows the title of apache tomcat but does not show the file. I want it to show me the .war file. It has the correct xml files and everything in it. Any help is much appreciated.
You may try to check whether the application is deployed or not. You can directly go to the Tomcat directory to see this.
Another possible thing could be, you might be typing the incorrect url.
http://localhost:8080/[your_application]
where 8080 is the port you have specified for tomcat.
You need to let Eclipse publish your web project for you when using the Eclipse Tomcat plugin instead of trying to manually deploy it youself.
The Tomcat plugin for Eclipe supports hot deployment whereby you can change jsp's etc without having to manually redeploy your web application.
If you have a valid web project in eclipse then you can check that it is being deployed by looking at the Server View.
Window, Show View, Other, Server
This window should contain details of your Apache server. (If no server is listed then you'll need to right click on the list and set one up.)
To check that your application is being deployed right click on your server and select Add/Remove projects. Check that your web project is listed. If it is not listed under Configured Project then add it.
If your project does not appear in the list then it probably wasn't setup as a Dynamic Web Project. You can fix this by by right clicking on the project to bring up project properties and then clicking on facets and then enabling Dynamic Web Project.
It is also worth having the Console view visible when starting/stopping Tomcat so that you can see the server output.
Start tomcat from the command line (not eclipse) and see if your webapp shows up. It should if you have indeed created a valid war file. If it doesn't work, check the logs.
You shouldn't be manually deploying the war file if you are using eclipse to launch tomcat. Running tomcat from eclipse does not necessarily use the same default workspace as the standalone tomcat. Check the configurations for the 'server': it may be that the eclipse launched server's webapp folder is empty.
If for some reason your webapp failed to initialize properly (error in the descriptor, an uncaught exception in a context listener, ...) tomcat will unload it and you won't see anything at http://localhost:8080/yourwebapp.
Is it there in the list of applications in tomcat manager?
if you havent done this...then follow the steps...
Go to http://localhost:8080/
Go to Tomcat manager and check if your application is there in the list of deployed applications. Try redeploying or starting the application if running=false. It usually tells you what is wrong when you do that.

Categories