Could anyone please tell me, what the meaning of the word "Deploy" and "Redeploy" in context of Tomcat in the following line:
ServletConfig parameters won't change
for as long as this servlet is
deployed an running. To change them,
you'll have to redeploy the servlet
Thanks very much in advance.
When it says "deployed" that means Tomcat read the Servlet definition (usually a web.xml inside a war) and started the Servlet, which is now available for use. This is when ServletConfig parameters are passed to the Servlet.
When it says "redeploy", it means any way you force it to re-read the Servlet definition (which will re-read the ServletConfig parameters).
The easiest way to redeploy a Servlet is to stop Tomcat and start it again. When Tomcat stops, it undeploys everything that was deployed. When Tomcat starts, it deploys everything again.
Restarting the server may be overkill for you if all you want is to have one Servlet re-read its configuration. A faster way (in server time, not necessarily the time it takes you to figure out how to do it) to redeploy a Servlet is called hot deploy. Hot deploying is when you redeploy a Servlet when Tomcat is still running. See the Tomcat documentation for more info on how to do it in Tomcat.
This means that if your server is deployed and running (i.e. working) then your changes will not show up until you redeploy (i.e. stop the server and deploy the code and start again).
Related
I am new to servlets and using Tomcat version 7.0.34 (we were instructed to use this version only). My problem is that the Tomcat seems to restart at some point of time, this occurs when I don't interact with the servlet for some time. I see the following:
.
Further when I tried debugging through eclipse I see the following entries in the debug window:
Daemon Thread [http-bio-80-exec-1] (Suspended (exception RuntimeException))
ThreadPoolExecutor(ThreadPoolExecutor).runWorker(ThreadPoolExecutor$Worker) line: not available
ThreadPoolExecutor$Worker.run() line: not available
TaskThread(Thread).run() line: not available
And this in console:
SEVERE: The web application [/csj] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation.
Okt 03, 2016 1:39:39 AM org.apache.catalina.core.StandardContext reload
INFO: Reloading Context with name [/csj] is completed
I want to know the reason why Tomcat is restarting. If I keep clicking the buttons with no delays, then this problem is not seen.
I tried looking here: Tomcat showing this error "This is very likely to create a memory leak". How to resolve this issue? and here: The web application [ROOT] is still processing a request that has yet to finish. [Tomcat] but I am at loss to understand.
It seems this problem is solved in newer version of Tomcat as per this:http://wiki.apache.org/tomcat/MemoryLeakProtection . Nevertheless I would like to understand what is this problem about.
Edit: Using eclipse-mars
Your tomcat is configured for "hot deploy" i.e. if you change code, tomcat will incorporate new code without a server restart. This can be configured on tomcat, or in eclipse. You can go there and disable this as it is actually a headache and consumes more time, and sometimes doesn't work correctly.
Tomcat loads each webapp using a separate classloader. It monitors your files for changes, and if a change happens, it unloads your webapp by destroying the classloader, and loads again using a new class loader. When this is happening, you will see all kinds of logs as you mentioned.
For eclipse configuration, see here
For tomcat configuration, see here
Also, from Tomcat docs, read this
In server.xml, set reloadable="false".
From https://tomcat.apache.org/tomcat-5.5-doc/config/context.html
Set to true if you want Catalina to monitor classes in /WEB-INF/classes/ and /WEB-INF/lib for changes, and automatically reload the web application if a change is detected. This feature is very useful during application development, but it requires significant runtime overhead and is not recommended for use on deployed production applications. That's why the default setting for this attribute is false. You can use the Manager web application, however, to trigger reloads of deployed applications on demand.
Is there anyway to change certain web.xml parameters of an already deployed application in the glassfish?
If you change directly in the file-system, no one will understand later, why and when the changes have been done. So this is bad!
But it's easy: Just change the web.xml of the deployed application and restart the glassfish domain. You will find the web.xml somewhere near
/PATH/TO/glassfish3/glassfish/domains/DOMAIN/applications/APP-NAME/WAR-NAME/WEB-INF/web.xml
if deployed in a standalone instance. Otherwise it is somewhere below the ..../nodes folder.
Edit: In a cluster environment, a sync from the deployment manager will override your changes.
I just packaged my maven web application into a war file, upload it to remote server which has installed the tomcat environment. After I unpacked my war file and put all files in the /webapps/ROOT directory, I run bin/startup.sh to fire up the tomcat.
This just works fine, but when I intend to change my web application and redeploy it on the server, I don't know how to do that seamlessly, that is to say, not letting the users who is using my website lose any request.
Could anyone give me some idea? Thanks a lot!
You can always use manager app coming with tomcat to deploy a war without bringing the website down, even from a remote machine using browser.
http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html#Deploy_A_New_Application_Remotely
You may use reverse proxy as door of you site. After deploying your "second" war into Tomcat, you can change the configuration of reverse proxy and reload it. The reloading of reverse proxy is very speedy, so that it likes "seamless" re-deployment of Java web application. After the reloading of reverse proxy, you could un-deploy "first" war of application safely.
This way to re-deploy is especially useful if the application needs time for initialization(for example: including ORM, Spring Framework...).
There are few concerns about using multiple-war-at-the-same-time:
1) There will be two applications(although, temporary) running on your Tomcat concurrently, make sure there is nothing hazard about concurrent executing. For example: scheduled jobs
2) You need to confirm that there is enough memory on Tomcat to live with two web applications, or Tomcat may hang.
3) Be meticulous about Java.lang.OutOfMemory: PermGen Space problem
Using jboss-esb 5.1.0.GA
I have a web service that an EJB that I have makes calls on when it is started. This EJB may be installed in the same JBoss instance as the web service. If I start JBoss, let it come up completely, then deploy my EJB into the same instance, all is well. However, if I leave it deployed and restart JBoss, when the EJB gets to the point where it makes a call on the web service, the Application Server start-up process hangs. Now the WebService was deployed prior to the EJB according to the logs. It acts like the web server that is serving the WS calls is not yet up either. I can try to access the WSDL via a web browser and that fails until the JBoss instance is fully started. i can see if I have my dependencies wrong and it would error out on deployment, but I get no error, it just hangs indefinitely. Any ideas where to go from here. Any more information you need?
Thanks,
-Rob
You can ensure the order of deployment if you bundle your webservice war and ejb jar into one single ear file. In this case the ejb jar is always deployed first.
Appears there is a bug in the version of JBoss that we are using. We were required to register for an event to notify us when JBoss was up, then we made our WS calls and things work fine now.
i'm about to deploy two different but dependent war-files into a single jboss (AS 4.2.x GA)
One implements some webservices (jax-ws) exposing their interfaces through
a wsdl. The other one is a (say) web frontend using the aformentioned webservices. When I drop both warfiles to $JBOSS_HOME/server/default/deploy at the same time I can see that the first gets deployed (somehow) but the second one gets stuck and the entire jboss is not responding.
When I deploy them one after another, everything is fine (it just works:)
Is there a way to tell jboss that deployment of warfile2.war has to wait
for warfile1.war to finish deployment before starting deployment of warfile2.war?
Is there a way to determine programatically wheter a given 'service' is deployed
and ready?
I'm wonder what happens when both wars are present and jboss is restarted?
Kind regards,
Jay Wee.
To answer your last question first, JBoss will deploy the contents of its deploy directory in alphabetical order. If you drop two WAR files into a running server's deploy directory, the results are unpredictable, but should be safe, so I'm not sure what's going on there.
By the way you describe the dependency, it sounds like when a user uses the frontend WAR, it calls the web service WAR, and that on startup there's no link between the two? Could anyone be trying to use the frontend WAR while the web service WAR is still deploying? Which WAR comes first alphabetically?
As a possible solution, when you have two WAR files that depend on each other, you should consider packing them both into a single EAR file. That way JBoss will deploy them together in a controlled way.
What about implementing a listener in the web frontend waiting for a successfull head request to the wsdl on localhost?
Thats right. backend.war is deployed before frontend.war.
I deployed it on my local jboss and nobody else has acces to it.
What I can see when i debug into jboss is that the frontend accesses the backend wsdl (https://localhost:9999/app/svc?wsdl ) hangs while jboss is not ready.
\at Arne Burmeister: the listener approach doesen't help. the listener is called to early in the process: I can connect to the backendWsdlUrl but backenWsdlUrl.getConnection().getOutputstream() hangs
I think I'll give the ear a try. Is there a good documentation on how
to pack things together in an ear? (skaffman already pointed me into the right direction)
Thanks a lot to all who help so far,
Jan