Jeff Beck
Jeff Beck

Reputation: 3938

Deploy Grails to a Sub-Context Path

I would like to deploy a grails war to a sub context path but when I try this the application will not load and an error filterStart so I'm either missing something or grails can't be deployed to a sub-context. Is there any way to load grails in a sub context?

Upvotes: 4

Views: 1452

Answers (2)

Tony Day
Tony Day

Reputation: 2170

I thought I'd leave an answer here for anyone who comes along since I've been trying to solve this problem myself.

One trick is to set use the hash/pound sign (#) in the .war file name:

api#1.2.war

Which results in the following app context:

http://localhost:8080/api/1.2/

I've tested this in Tomcat 7.

One reason why I wanted this is so that I can automatically ship different versions running side by side with the following grails BuildConfig.groovy:

grails.project.war.file = "target/api#${appVersion}.war"

This works great with Tomcat 7, I'm unsure about other versions.

However, what I would really like to do is set it up so that Tomcat uses the context from my Grails Config.groovy or application.properties files.

Update 1: I'm using Grails 1.3.7.

Update 2: Successfully tested by user miek in Tomcat 6. Thanks miek!

Upvotes: 8

Stefan Armbruster
Stefan Armbruster

Reputation: 39915

Just a shoot from the hip: add a file /web-app/META-INF/context.xml to your application with these contents:

<Context path="/ex/sub" />

I'm not sure if that works, but it's worth a try.

Upvotes: 0

Related Questions