Grails

Tomcat deployment error with 2 versions of a Grails app: "Choose unique values for the 'webAppRootKey' "

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 1.0.1
  • Fix Version/s: 1.0.3
  • Component/s: Configuration
  • Labels:
    None

Description

Due to Tomcat class loading, 2 applications can't have the same webAppRootKey setting in web.xml

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

Otherwise Spring throws an exception with:
"Choose unique values for the 'webAppRootKey' context-param in your web.xml files!"

A solution would be to add the environment name to the appname as value for the webAppRootKey. Nevertheless this should be done with custom template provided by the user too what changes the way template are processed. I can try to propose a patch when this second point is cleared (I'll post a mail in the dev mailing list to discuss this).

Issue Links

Activity

Hide
Lee Butts added a comment -

See related/duplicate issues for suggested solutions/patches

Show
Lee Butts added a comment - See related/duplicate issues for suggested solutions/patches
Hide
Marc Guillemot added a comment -

There is a major difference between this issue and the 2 related ones: here I use a custom web.xml template.

Show
Marc Guillemot added a comment - There is a major difference between this issue and the 2 related ones: here I use a custom web.xml template.
Hide
Graeme Rocher added a comment -

i've changed package.groovy to add the environment, if the user needs to change this they can run install-templates

Show
Graeme Rocher added a comment - i've changed package.groovy to add the environment, if the user needs to change this they can run install-templates
Hide
Marc Guillemot added a comment -

Graeme, from your comment, I think that the problem is not solved when using a custom template: I don't want to modify my template before creating a war, which means that Grails should not take the template as it but modify the webAppRootKey.

Show
Marc Guillemot added a comment - Graeme, from your comment, I think that the problem is not solved when using a custom template: I don't want to modify my template before creating a war, which means that Grails should not take the template as it but modify the webAppRootKey.
Hide
Graeme Rocher added a comment -

I don't think i understand the problem, to me the semantics seem perfectly clear. Grails by default generates the webAppRootKey, if you don't want it generated you run install-templates and specify your own. If you have issues with running the same app multiple times on the same machine then you can use the versioning system.

Show
Graeme Rocher added a comment - I don't think i understand the problem, to me the semantics seem perfectly clear. Grails by default generates the webAppRootKey, if you don't want it generated you run install-templates and specify your own. If you have issues with running the same app multiple times on the same machine then you can use the versioning system.
Hide
Marc Guillemot added a comment -

Perhaps I'm missing something. Here is my scenario:

  • I need to use custom template to put legacy filters/servlets/...
  • this template contains as well the filters/servlets/... needed by Grails, among others the webAppRootKey context param
  • if I deploy 2 versions of this web app on the same Tomcat instance, they will both have the same webAppRootKey value, which cause the problem.

Generally it seems to me that the web.xml template has 2 purposes that should perhaps not be handled together: modify the web.xml stuff needed by Grails and add custom web.xml stuff.

I don't see how the versioning system could help here, but I'm perhaps wrong.

Show
Marc Guillemot added a comment - Perhaps I'm missing something. Here is my scenario:
  • I need to use custom template to put legacy filters/servlets/...
  • this template contains as well the filters/servlets/... needed by Grails, among others the webAppRootKey context param
  • if I deploy 2 versions of this web app on the same Tomcat instance, they will both have the same webAppRootKey value, which cause the problem.
Generally it seems to me that the web.xml template has 2 purposes that should perhaps not be handled together: modify the web.xml stuff needed by Grails and add custom web.xml stuff. I don't see how the versioning system could help here, but I'm perhaps wrong.
Hide
Graeme Rocher added a comment -

If you want your webAppRootKey generated by Grails for you then put @grails.project.key@ as its value in your template

<context-param>
        <param-name>webAppRootKey</param-name>
        <param-value>@grails.project.key@</param-value>
    </context-param>

I don't see or understand what you want us to do to solve this problem any other way

Show
Graeme Rocher added a comment - If you want your webAppRootKey generated by Grails for you then put @grails.project.key@ as its value in your template
<context-param>
        <param-name>webAppRootKey</param-name>
        <param-value>@grails.project.key@</param-value>
    </context-param>
I don't see or understand what you want us to do to solve this problem any other way
Hide
Marc Guillemot added a comment -

This would be just fine but according to the code of scripts/Package.groovy, I guess that it won't work (I haven't tested): the line

Ant.replace(file:tmpWebXml, token:"@grails.project.key@", value:"${grailsAppName}-${grailsEnv}-${grailsAppVersion}")

is called only if no custom web.xml exists.

A good solution for me would be to have this Ant.replace in Package.groovy for custom web.xml as well and to remove the same line in InstallTemplates.groovy to install template with the placeholder rather than with the actual value.

Show
Marc Guillemot added a comment - This would be just fine but according to the code of scripts/Package.groovy, I guess that it won't work (I haven't tested): the line
Ant.replace(file:tmpWebXml, token:"@grails.project.key@", value:"${grailsAppName}-${grailsEnv}-${grailsAppVersion}")
is called only if no custom web.xml exists. A good solution for me would be to have this Ant.replace in Package.groovy for custom web.xml as well and to remove the same line in InstallTemplates.groovy to install template with the placeholder rather than with the actual value.
Hide
Graeme Rocher added a comment -

ok this is done now

Show
Graeme Rocher added a comment - ok this is done now
Hide
Marc Guillemot added a comment -

Thanks.

I'm not concerned, but shouldn't the replacement occur as well if custom web.xml is defined by config.grails.config.base.webXml?

Show
Marc Guillemot added a comment - Thanks. I'm not concerned, but shouldn't the replacement occur as well if custom web.xml is defined by config.grails.config.base.webXml?

People

Vote (1)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: