Showing posts with label Tomcat. Show all posts
Showing posts with label Tomcat. Show all posts

Sunday, September 1, 2013

Restart Tomcat Service

Restart Tomcat Service with cleaned webapps directory

Create power-shell script file with below script (say "serviceRestarter.ps1")



# *******************************************************************************
# Use of this script is
# path_to_script_file ServiceName="" catalinaHome="" appName=""
# SERVICE_NAME is the name of the service to restart
# CATALINA_HOME is absolute path of catalina_home
# APP_NAME is the name of the war file without extension
#
# @author Amit Nema
#
# *******************************************************************************

#parameters to pass with script
param(
[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$ServiceName,
[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$catalinaHome,
[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$appName
)

# type the name of the service in the quotes here
$service = Get-Service -Name $ServiceName

#Stoping Service
Stop-Service $ServiceName
$service.WaitForStatus('Stopped','00:10:00')
if ($service.Status -ne 'Stopped') { 
Write-Warning 'Something is fishy here...'
exit
} Else {
write-host 'Service ' $ServiceName ' is ' $service.Status ' now.'
}
sleep 10

#Delete the content of web-apps
write-host 'Removing application :' $catalinaHome'\webapps\'$appName '.'
Remove-Item -Recurse -Force $catalinaHome'\webapps\'$appName
Remove-Item -Force $catalinaHome'\webapps\'$appName'.war'
Remove-Item -Recurse -Force $catalinaHome'\work\Catalina\localhost\'$appName
Remove-Item -Recurse -Force $catalinaHome'\work\Catalina\localhost\_'
sleep 10

#Starting Service
Start-Service $ServiceName
$service.WaitForStatus('Running','00:10:00')
if ($service.Status -ne 'Running') { 
Write-Warning 'Something is fishy here...' 
} Else {
write-host 'Service ' $ServiceName ' is ' $service.Status ' now.'
}
sleep 10

Wednesday, May 5, 2010

A warning message in Tomcat console

A warning message in Tomcat console. The message is

WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:AppName' did not find a matching property.

The solution to this problem is very simple.
- Double click on your tomcat server. It will open the server configuration.
- Under server options check 'Publish module contexts to separate XML files' checkbox.
- Restart your server.

This time your page will come without any issues.