i have deployed a java server using my eclipse.
I extract the war file.
i installed the apache-tomcat-7.0.47 on my windows server 2003
i installed the Apache Tomcat 7 service on my windows server 2003 and made it run automatically.
i want to run the war file on my windows server 2003
what i have tried
i put the war file on my webapps on the apache-tomcat folder and then run the startup.bat which locates on the bin folder.
i test the server and it works perfectly
my problem
when i log of from my windows server. the war file stop working.
my question
how can i keep the server working ever when i log of. note that i installed the service and restart the server many times.
One way to do this is to use a Java Server Wrapper or http://support.microsoft.com/kb/137890
SO Link
There seems to be a way in java itself to do this, add -Xrs to your java.exe call in server startup (bat file I suppose), from Oracle Documentation . Beware of the consequences in using this!
-Xrs Reduces use of operating-system signals by the Java VM.
In an earlier release, the Shutdown Hooks facility was added to enable
orderly shutdown of a Java application. The intent was to enable user
cleanup code (such as closing database connections) to run at
shutdown, even if the Java VM terminates abruptly.
The Java VM watches for console control events to implement shutdown
hooks for unexpected Java VM termination. Specifically, the Java VM
registers a console control handler which begins shutdown-hook
processing and returns TRUE for CTRL_C_EVENT, CTRL_CLOSE_EVENT,
CTRL_LOGOFF_EVENT, and CTRL_SHUTDOWN_EVENT.
The JVM uses a similar mechanism to implement the feature of dumping
thread stacks for debugging purposes. The JVM uses CTRL_BREAK_EVENT to
perform thread dumps.
If the Java VM is run as a service (for example, the servlet engine
for a web server), then it can receive CTRL_LOGOFF_EVENT but should
not initiate shutdown because the operating system will not actually
terminate the process. To avoid possible interference such as this,
the -Xrs command-line option was added beginning with J2SE 1.3.1. When
the -Xrs option is used on the Java VM, the Java VM does not install a
console control handler, implying that it does not watch for or
process CTRL_C_EVENT, CTRL_CLOSE_EVENT, CTRL_LOGOFF_EVENT, or
CTRL_SHUTDOWN_EVENT.
There are two consequences of specifying -Xrs:
Ctrl-Break thread dumps are not available.
User code is responsible for causing shutdown hooks to run, for
example by calling System.exit() when the Java VM is to be terminated.
After reading aksappy's answer. I discovered that the jvm is making that problem. i went to the bin folder of the apache-tomcat and run the tomcat7w.exe and then I went to the shutdown tab and changed the jvm to java.
this is the facinate solution that helped me
You can set the “deployIgnore” attribute for your web application in server.xml ; this attribute will ignore the war file name from deployment. Later you can deployment the application manually
Related
As the title says - when launching Spring app (STS) with embedded Tomcat, both java.exe and javaw.exe processes are created on the same port.
That means I have troubles with busy port, even when using the Relaunch option (which typically shuts Tomcat down and then restarts it). Indeed, relaunching does stop one of the two processes but then I get an error stating that the port must be busy. Killing the remaining one does solve the issue but I life is too short to both develop in Java AND kill the process manually.
Is there a convenient way to overcome this? I see that is STS (and Eclipse too, of course) there's a way to specify project specific JRE but I'm unsure on how to proceed.
Note: I have both 32- and 64-bit java8 instances installed.
Try running it as a java application (ie, just run main).
It sounds like you are deploying it on Tomcat, while at the same time there is an embedded Tomcat being started... :)
I've got a Talend process, deployed inside a .war file in a Tomcat app server. The .war has several jobs inside it, that are called using a get request pretty much like "http://server:port/TalendProject/method=runJob".
Not having the commercial license of Talend (using Open Studio at the moment) I don't have any way to control whether a job has failed or not in the middle of the execution.
I know I can check logs but not knowing the system I'm operating with, I can't be sure if a job has failed or is still running (after an exception for example).
My question is if there is any way to monitor the job that is running inside the Tomcat, this is, if there is any way to show the process that is being running.
My guess, but I'm not sure is that there is no way since the Talend Job is running encapsulated by the Talend .war, so the only thing I will see is the java calling this .war and everything below will be hidden.
I don't know anything about Talend, but I think you can use JConsole or better VisualVm to monitor your Tomcat server via JMX Agent. In order to monitor any Java application (as Tomcat) you have to invoke it with -Dcom.sun.management.jmxremote if tomcat is running in localhost.
If Tomcat is running in another host, you need to configure at least port JMX property -Dcom.sun.management.jmxremote.port=XXXX.
In order to add these properties to run tomcat, you have to change CATALINA_OPTS variable located into $TOMACT_HOME\bin\catalina.sh or $TOMACT_HOME\bin\catalina.bat file.
You have full documentation about Java JMX Agent monitoring here
This way you can monitor threads, memory consumption, gc activity, do profiling, thread dump, ... maybe it helps you to understand .
I'm developing a web application with Eclipse and Tomcat on windows. When testing my efforts I sometimes crash Tomcat, and the only option left is to kill the jvm hosting Tomcat, but that can only be done with windows' task manager.
The process to kill is a java process but eclipse is also on a java process and basically the only thing I can do determine which java process to kill is toss a coin and hope for the best. It seems that I choose the wrong (eclipse) java process more often than the tomcat java process. Of course I can and should write down the id of the only java before starting Tomcat but that is sometimes forgotten
Is there a way to determine which java process is for eclipse and which for Tomcat? when eclipse is up an running for a long time I can discriminate on the cpu time, but for short running instances this is no candidate for heurstics.
I use Process Explorer which is free and I can easily see in its GUI (in process tree view) that eclipse is a super node of Tomcat's JVM.
Use the Process Explorer from Sysinternals. It shows the hirarchy of processes, and since the Tomcat got started by Eclipse, you can see it as a “subprocess”.
You could start jvisualvm from the bin of your JDK directory. There each MainClass is listed with the corresponding pid.
I have a console Java application, which runs all the time on a remote server (nohup java -jar myapp.jar &).
Frequently (every other day) I need to replace the JAR file by a newer one (whenever I fix a defect).
At the moment I do this by connecting to the server using ssh (WinSCP).
How can I create a mechanism, using which I could upgrade the application via the http protocol? Can I use JMX for that?
That mechanism should do following things:
a) Stop the currently running application.
b) Upload the new JAR file to the server.
c) Launch the new JAR file.
Basically you need to break down the program into two parts:
the monitor component which fetches the new jar, stops the program, replaces the jar, restarts the program
the actual program, the console java application
Theoretically you can do all of this in a single java process but the additional complexity is not worth the trouble in my opinion.
You might check out install4j or this similar StackOverflow question.
In LiveRebel, there's native support for standalone applications (i.e. daemons). So the main application is running with the watchdog agent which communicates to the command center. From command center it is possible then to manage the updates.
I'm looking for a tool (in linux) that can montior a tomcat/jboss process and if the process fails, I can respawn either or both without having to manually ssh into the box, do any house keeping and then start them up again. I'm not too sure if there is a good tool out there that can monitor the health of jboss/tomcat and report on it's performance. I know jvisualvm gives you various tools, but I'm looking for a disaster recovery solution that is a bit higher level than jvisualvm.
Java Service Wrapper is an application that wraps your Java process and installs it in the system using service (Windows) or daemon (Linux). It pings the VM periodically and restarts it when it does not respond. Worked for us in production with several application, including Tomcat, JBoss, Mule, etc. Actually Mule ESB is even bundled with this application in the distribution.
Also you don't have to run the application manually when the system starts.
I'm currently working on a daemon to do this and more, since JOPR nor naggios didn't do what we needed, but those are good tools you could use. I'm not sure but JOPR (or whatever is called today) can restart your servers in case something goes wrong.
A custom made solution as we're working on shouldn't take you more than a week. The main problem, is that to start either JBoss or Tomcat you have to call the startup scripts. But the startup script will restart the service if the exit code is 10, something like this:
while $? -ne 10; do
start_jboss
done
So, this daemon which is made in Java uses JMX to connect to the JBoss server and tells JBoss to go down and exit with status code 10 using a method in a MBean. I'm at home, so I'm not sure the exact name of the MBean you have to call for this but I'll provide more info tomorrow.
I am using monit to control the launch of Tomcat/JBoss.