I have the tomcat up and running on remote machine.
Now i need to create a batch file to restart the tomcat. I am using windows.
Stop tomcat
start tomcat
How can i write a batch file to restart it?
Thanks!
There are scripts in the bin directory of tomcat that will start and stop it called starup.bat and shutdown.bat IIRC. You will have to ssh in to remotely run them.
Also, if you're running as a Windows Service, there are ways to remote manage those service, but my Windows is rusty. You'll need to google for that.
You'll need to write a batch file either to SSH in or to restart the service.
Related
I am trying to deploy an application WAR file using Jenkins ANT to build the WAR and restart the server.
Once the WAR is built, I have written a shell script to stop the application server, deploy the WAR file and then restart the application server.
#Shutdown Tomcat
ssh tomcat#<servername> "cd /home/tomcat/app/bin/;exec bash ./shutdown.sh"
#waiting period
ssh tomcat#<servername> "sleep 10"
ssh tomcat#<servername> "cd /home/tomcat/app/webapps/;rm -r *"
#Copy the WAR file to webapps
#Start the tomcat server
ssh tomcat#<servername> "cd /home/tomcat/app/bin/;exec bash ./startup.sh"
It does shutdown the server, clear some temporary files but fails to start the tomcat server. Any idea why this would be happening?
I have tried to see if there are other processes or ports still in use guessing maybe the shutdown was not clean. However there doesnt seem to be any issue like that. When I manually start the tomcat server for the application by going to the tomcat/bin directory, Tomcat starts without any issues.
Thanks in advance.
I have stopped my Tomcat 7.0 server in Eclipse. When I go to the server view, it has confirmed that the tomcat server has stopped. Yet any time I try to run a new project on the Tomcat Server, I get the error
"Several Ports (8080, 8009) required by Tomcat v7.0 Server at localhost are already in use..." How do I get tomcat server to run my java project?
Go to localhost:8080 and see if you get a response.
If so, try going to the /bin folder and running shutdown.sh(.bat depending on your OS).
Go to the terminal and execute the command:
brew services stop tomcat
Post this.. dont start any services using "brew"
Run your application using Run on Server
If the state of the server is marked stopped then do the following:
Go to Window>Show View>Other
Select Server>Servers
In the console if you see stopped, synchronized, right click on the line where you see stopped and start the server
The purpose is to:
connect to a remote server maybe via host: ip , port: 8181
stop Tomcat that's running on that server
deploy a .war file
restart Tomcat
Underneath are few approaches I have taken so far to achieve this task:
Approaches taken so far:
I have looked at the following solutions but none of them worked for me:
http://www.linuxquestions.org/questions/linux-newbie-8/start-tomcat-server-remotely-824472/ --Not efficient
http://tomcat.apache.org/tomcat-6.0-doc/manager-howto.html#Start_an_Existing_Application
http://raibledesigns.com/wiki/Wiki.jsp?page=TomcatAntTasks
--only start/stop application not the actual tomcat itself
http://cargo.codehaus.org/Remote+Container
-- Which does't start/stop tomcat that's running on that server
If you have ssh access to the server, then you might like to consider the JSch library which you can use in combination with SSHExec Ant Task to start and stop your server:
<sshexec host="somehost"
username="dude"
password="yo"
command="/etc/init.d/tomcat restart"/>
For start/stop tomcat
In linux environment
use SSH to reach the terminal of the remote machine.
from the terminal You can start/stop the tomcat
to start startup.sh
to stop shutdown.sh
Under windows environment
Install OpenSSHD for Windows - this will allow remote "console" sessions.
If you looking for something very "unix-like" then you can install cygwin.
http://www.worldgoneweb.com/2011/installing-openssh-on-windows-7/
to start startup.bat
to stop shutdown.bat
For deployment
Simply go to tomcat manager link on the below page(on any environment)
http://your_server_ip:port_number/
user credential are specified in tomcat-users.xml inside conf di
I have a war file and I would like to deploy it to remote machine. Both on local and remote machine glassfish 3 is installed and it would be responsible for deploying the app.
How can I perform remote deploy from one machine to another? Is it possible to do it using asadmin console on one machine and deploy to the other?
In order to send ANY commands to a remote Domain Application Server (DAS) from a remote client like asadmin, you must first enable security. By default, this feature is turned off. It's simple to fix:
(1) While "on" the remote machine
(2) DAS is running
(3) asadmin enable-secure-admin
(4) asadmin restart-domain
Now you should be able to send asadmin commands from any remote machine.
The change is permanent. Run the command once and forget it.
For help on the command run this:
asadmin enable-secure-admin --help
asadmin deploy --user admin_user [--password admin_password]
[--host localhost] [--port 4848] [--passwordfile filename]
[--secure|-s] [--virtualservers virtual_servers]
[--type application|ejb|web|connector]
[--contextroot context_root] [--force=true]
[--precompilejsp=false]
[--verify=false] [--name component_name] [--upload=true]
[--retrieve local_dirpath] [--instance instance_name] filepath
Pay attention on --host and --port arguments.
Specify needed host/port and your app will be deployed on remote GF.
whats the cause of this error while running tomcat 6.0 on eclipse ide helious:
Several ports (8005, 8080, 8009) required by Tomcat v6.0 Server at localhost are already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s).
Just read the error message: Tomcat is already running.
Or:
you have tomcat running in your eclipse workspace (solution: stop the server in eclipse or the eclipse process from your task manager)
your tomcat is running in the background as a service (solution: kill the tomcat process from your task manager and disable the windows service)
the ports tomcat use are used by other programs running in the background (solution: kill the processes using these ports from your task manager)
Some application is using the ports configured in Tomcat.
Either check the applications using these ports with netstat and kill them, or configure different ports for Tomcat.
Check if there's any Java Application Server running, they generally use these ports.
Sometimes when you run Tomcat from within Eclipse, you stop Tomcat from the Servers view, and it keeps running on the background. I've found that restarting Eclipse makes it stop for good.
The problem is that the tomcat server must not start from inside the Eclipse, it should start from the cmd screen by using the files startup.dat and shutdown by using the shutdown.dat file using their pathin the cmd like this:
D:\Apache-Software-Foundation\Tomcat-8.0\bin\startup.bat
D:\Apache-Software-Foundation\Tomcat-8.0\bin\shutdown.bat