Reputation: 10719
I am having an issue with Grails 2.2.3 where the Spring Security added login/auth.gsp view is not displaying in the browser when I run grails run-war
or grails war
then deploy to a Tomcat server. However it displays and works just fine when I do grails run-app
or grails prod run-app
. I have done a grails clean
several times, as well as recompiled and refreshed dependencies.
A couple of things to note:
login/auth.gsp
view is in a custom UI plugin I am using. It is in
the projects BuildConfig.groovy
file as an inplace plugin.main.gsp
template is also in that custom UI plugin.The browser returns an HTTP 404:
type Status report
message /processes/WEB-INF/grails-app/views/login/auth.jsp
description The requested resource is not available.
Does anyone know what this issue might be, or how I could fix it?
Upvotes: 0
Views: 1113
Reputation: 63
This drove me nuts for several days even after reading this thread.
I'm using Grails 1.3.7 and I have several plugins that come from a vendor which I pull from a git repo. I recently upgraded a few plugins by getting newer versions from git and encountered this problem. It seems that when you run grails war
it builds the plugins and creates a plugin.xml file in the root of each plugin. The metadata in plugin.xml contains the plugin version (apparently acquired from the xxxGrailsPlugin.groovy file). The version from plugin.xml is used in naming the folder where the plugin code is stored in the war. The problem comes in when you change the plugin version since it seems that Grails does not regenerate the plugin.xml file. grails clean
does NOT do the trick. This causes the new version of the plugin to be stored in the war with the old version as part of its folder name.
Once I went through the plugins and removed all plugin.xml files I could successfully rebuild by war deploy it on Tomcat and not get 404's.
Upvotes: 1
Reputation: 437
If I remember correctly and am not completely wrong we had exactly the same problem with our project at work.
The problem was (and it is probably the same for you) that we had two versions set for the plugin.
One was set in application.properties
app.version=0.1
and than there was one set in the plugin descriptor
def version = "0.1"
If you remove the version declaration from the application.properties it should work. The version for plugins is set via plugin descriptor and for projects it's set via application.properties. I don't know how we ended up with the two version declarations but I'm guessing it's either due to some copy and paste mistake or that Grails used to generate plugins' application.properties with app.version
.
Upvotes: 2
Reputation: 10719
I "fixed" it but I am at a complete loss as to why this worked.
I remembered that I had bumped the version of my inplace plugin from '0.1' to '1.0'. Since doing that, the app has not worked when I build a war. Changing the plugin version back from 1.0 to 0.1 has fixed the issue.
Can anyone explain why this worked? I've cleaned and recompiled the UI plugin as well, but that never worked until I bumped the version back down.
Upvotes: 0
Reputation:
When you use plugins to serve resources, you need to add the plugin
property. This property is available in most of Grails tags / methods. Consider a plugin called my-plugin.
To use a resource:
g.resource(dir: "js", file:"myPluginJs.js", plugin: "myPlugin")
To render a plugin view:
render(view: 'path/to/view', plugin: "myPlugin")
That's also true when you declare a plugin resources file.
modules = {
"my-plugin-module" {
resource url: '/js/app.js', plugin: 'myPlugin'
}
}
Upvotes: 0