4

I'm migrating an app from grails 1.3.6 to 2.0 and I need to change its context root. If I remember correctly, in 1.3.6 I installed the template plugin and changed:

<context-param>
    <param-name>webAppRootKey</param-name>
    <param-value>/newcontextroot</param-value>
</context-param>

I did the same in 2.0 with no success. Any hints ?

Thanks

david
  • 2,529
  • 1
  • 34
  • 50
xain
  • 13,159
  • 17
  • 75
  • 119

3 Answers3

9

You can configure the context in Config.groovy:

// grails-app/conf/Config.groovy
grails.app.context = '/newcontextroot'

or in application.properties:

app.context = /newcontextroot
Rob Hruska
  • 118,520
  • 32
  • 167
  • 192
  • Already tried that, but spring security core login keeps sending me to http://localhost/appname/login/auth?login_error=1, maybe it's a plugin problem – xain Jan 04 '12 at 20:52
  • Is this when you've deployed a war, or just when you're using `run-app`? Or both? – Rob Hruska Jan 04 '12 at 20:53
  • Also, do you have any of [these properties](http://grails-plugins.github.com/grails-spring-security-core/docs/manual/guide/13%20URL%20Properties.html) in `Config.groovy` using a hard-coded context? – Rob Hruska Jan 04 '12 at 20:56
  • I've just tried with run-app and none of those properties exist in Config.groovy. – xain Jan 04 '12 at 21:23
  • Interesting. Yeah, there might be something else at work here? I've never had any problems using either of these ways to configure it... – Rob Hruska Jan 04 '12 at 21:24
  • Yup, maybe I should wait for 2.0.1 and try again. – xain Jan 04 '12 at 21:35
  • Thanks for this answer - I was trying to change the base URL that the application listens on and apparently grails.serverURL has no effect on how the application starts in tomcat. This property does. – BoxerBucks Apr 29 '13 at 18:29
2

Start your grails application with this command

grails -Dapp.context=/ run-app
srsajid
  • 1,717
  • 15
  • 12
1

In Grails version 3.3.9 I know changing:

project/grails-app/conf/application.yml

adding

server:
    contextPath: /yourcontextpath
    port: 9214 

will do the trick.

Mike Croteau
  • 1,062
  • 2
  • 16
  • 43