Last updated by graemerocher 3 years ago
grails install-plugin tomcat
Last updated by graemerocher 3 months ago
This plugin replaces Jetty with Tomcat as the default development time server for Grails. To install simply type:
grails install-plugin tomcat
The regular Grails commands like run-app etc. will operate against Tomcat instead of Jetty. No other installation of an external Tomcat distribution is required.
The following two features (JNDI/remote deployment) require the latest 1.2-SNAPSHOT version of the plugin:
grails install-plugin tomcat 1.2-SNAPSHOT
Configuration Options
- tomcat.deploy.username - The username of the remote tomcat to deploy to
- tomcat.deploy.password - The password for the remote tomcat to deploy to
- tomcat.deploy.url - The remote tomcat deploy URL
- tomcat.scan.enabled (since 2.0.1) - Where Servlet 3.0 annotation classpath scanning is enabled (false by default). Note that enabling this setting will require you to significantly increase your memory settings as the Servlet 3.0 scanning feature consumes a large amount of memory.
- tomcat.scan.excludes (since 2.0.1) - If class path scanning is enabled, what jars to limit
- tomcat.nio - Whether to enable the Tomcat New IO connector
- tomcat.keystorePath - The path to the Tomcat keystore for HTTPS
- tomcat.keystorePassword - The password for the keystore for HTTPS
- tomcat.jvmArgs - Any JVM arguments to pass to the isolated Tomcat instance used for run-war
- tomcat.startupTimeoutSecs - The time to wait for startup for the isolated Tomcat instance
JNDI
You can specify JNDI naming entries to be used by the embedded Tomcat in your
grails-app/conf/Config.groovy file:
grails.naming.entries = ['jdbc/mydb': [
type: "javax.sql.DataSource", //required
auth: "Container", // optional
description: "Data source for ...", //optional
//properties for particular type of resource
url: "jdbc:oracle:thin:@dbserver:1521:DBNAME",
username: "dbuser",
password: "secret",
driverClassName: "oracle.jdbc.driver.OracleDriver",
maxActive: "8", //and so on
maxIdle: "4"
]
]These can then be looked up by configuring an appropriate Spring bean in @grails-app/conf/resources.groovy@:
beans = {
xmlns jee:"http://www.springframework.org/schema/jee"
jee.'jndi-lookup'(id:"myDbDataSource", 'jndi-name':"java:comp/env/jdbc/mydb")
}Note if you deploy to a standalone Tomcat instance then these with need to be configured in your Tomcat context.xml file as per the Tomcat documentation
Remote Deployment
The plugin features remote deployment Gant scripts. To deploy the current Grails application simply run:
To undeploy run:
Note you will need to configure permissions in your tomcat-users.xml directory such as:
<role rolename="manager"/>
<user username="manager" password="secret" roles="standard,manager"/>
You can then need to specify the username/password (and potentially url) in your Config.groovy file:
tomcat.deploy.username="manager"
tomcat.deploy.password="secret"
tomcat.deploy.url="http://myserver.com/manager"
Tomcat 7
If you are using Tomcat 7, ensure the user has the manager-script role
<user name="manager" password="secret" roles="manager-script" />
And the configuration in Config.groovy looks like
tomcat.deploy.username="manager"
tomcat.deploy.password="secret"
tomcat.deploy.url="http://myserver.com/manager/text"
Last updated by esumerfd 1 year ago
Q: How do I deploy to the root context of a Tomcat installation?
A: In your application.properties, set your app.name=ROOT
Q: Error executing script Tomcat: : java.io.IOException: Server returned HTTP response code: 403 for URL: http://localhost:8080/manager/deploy?path=/myapp
A: Depends on the version of Tomcat you are using:
In Tomcat 6.x and earlier versions the manager URL for deploying was:
http://localhost:8080/manager
And the username/password in tomcat-users.xml must be in the "manager" role.
But in Tomcat 7 it changed and now looks like
environments {
development {
tomcat.deploy.username="tomcat"
tomcat.deploy.password="tomcat"
tomcat.deploy.url="http://localhost:8080/manager/text"
}
}
And the role required for scripts to deploy should be "manager-script" instead of just manager as in previous versions.
<role rolename="manager-script"/>
<user username="tomcat" password="tomcat" roles="manager-script"/>
Last updated by admin 3 years ago