I have TomCat deployed on a Windows server for the purpose of hosting a Java application. I just modified TomCat within the properties tab such that it will try to restart automatically if Tomcat fails. How can I test this? I want to make TomCat fail so I can see if the automatic restart works properly.
One such way is to cause it to run out of memory. But I don't know how to do that. Is there another way, or would someone be able to explain how to make Tomcat run out of memory?
Related
Jetty server was running fine. I made little changes in my code and now I want to restart it. With Tomcat it was easy because you have GUI interface to restart it. Any help will be appreciated.
There are a number of ways you can accomplish this, we have a page in the docs on Hot Deployment: https://www.eclipse.org/jetty/documentation/current/hot-deployment.html
Basically if you are using a webapp you can set it up to restart by touching a deployment descriptor or through jmx.
I have a java codebase in form a war hosted on Apache tomcat server(Production server). Now let us say i make changes in my class and i want the same to reflect on my hosted codebase. Do i have to re-start the server every time after updating the class, or is there some better way to do it
You can use auto-deploy feature of tomcat. Read the documentation here.
If it is a development testing server, you can enable debugging, and reload your changed classes without having to restart the server or redeploying your webapp.
You can enable debugging by setting the following and restarting tomcat. (you can use a desired port):
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8787
In your IDE, create a debug configuration specifying server ip and the debug port you specified.
After connecting debugger, your IDE will usually prompt you to reload changed classes whenever you compile a class.
There is also a menu item also if you want to manually reload changed classes. Once you reload classes, your changes will be immediately effective.
I have two fairly simple maven project on my netbeans. Both are configured to run on a remote glassfish server.
I can easily deploy the first one using the "run" button, however, if I try to "run" the second, the deploying action hangs indefinitely and doesn't do anything. No error, even on the remote glassfish logs.
Both have the same dependancies and the same configuration on Netbean. The second just have more web page and Java classes.
Any idea what would be causing this ? I can't make any sense of that.
Thanks !
Edit : If I delete all the Java classes, the deployment is working, this doesn't make any sense.
Edit² : If I manually deploy both application using the Glassfish web interface, it's working fine.
I export my maven java project in Eclipse to War file.
On the server, I open the manager of tomact and add the war application, but when I run the application it seems the application isn't running (or some problem with the resources).
From the other hand, when I start the tomcat by the startup.bat in the tomcat folder and add the War to the webapps folder, it is working. But if I logoff the server , I cannot connect the application remotly. The server is shut down. Why?
What can be the problems?
Thanks!
Me
Why is your application not running? Well - if there's a specific reason for it (and the manager application works) you will see it in the logfile - e.g. tomcat's log/catalina.out. Check it or give us a snippet of the error messages in there if you don't understand them.
I like to recommend not to use the manager application, rather deploy through the OS or any other maintenance tool (e.g. scripted). This typically results in a better maintainable system. As it already works well for you when you just add your WAR file to the webapps directory, everything seems well. Introducing a manager application in production just provides another means to attack your site - and I frequently see those applications poorly maintained (and the passwords poorly chosen & protected)
When you start tomcat with startup.bat, it will run the server process in a console window. This console process will be shut down when you log out. In order to have tomcat running even when you're not logged in (and in order for it to start automatically), you'll have to install it as a service. There's plenty of information on the internet on how to do this - should be extremely easy to find.
I know I can prevent the server restart, when I publish my app to Tomcat.
But, each time, I have to restart my application. and This is also take a long time,
Can I prevent restart my application, just like PHP does?
ps:
after run tomcat in debug mode, now, I can modify java file without a redeploy! but it doesn't apply to jsp pages! How can I submit jsp without the "publish"?
Tomcat makes the very reasonable assumption that you may have done something quite drastic since the last deploy. You can fiddle with minor JSP changes in the work directory, but eventually you will need to redeploy.