Default Grails '/' controller mapping not resolving properly
Asked Answered
P

2

9

This one has been driving me crazy today. Since upgrading to Grails 1.2 and Weblogic 10.3 the default root mapping for "/" stopped working. Here's what I have...

I have this URL mapping:

"/"(controller:"IGive", action:"index" )

I have a controller named IGiveController with an index closure

def index = {
    render "foo"
}

When I go to my application running in the embedded Tomcat and Jetty with http://localhost:8080/mycontext/ I get "foo" returned property. But when I build a war and deploy to Weblogic 10.3 I get a 404.

I downgraded to Grails 1.1.2 and it still didn't work on Weblogic 10.3 but the error was more descriptive

Could not open ServletContext resource [/WEB-INF/grails-app/views/index.gsp] 

So it seems like it's completely ignoring my URL Mapping for "/" but other URL Mappings that are deeper are working. Any clues??

Purkey answered 16/1, 2010 at 3:14 Comment(0)
C
8

I think this is more related to Weblogic - I am seeing the same on Weblogic 9.2 - but not on Tomcat or Jetty. Doesn't hit my UrlMapping:

"/"(controller: 'home', action: 'index')

I think Weblogic is being smart and converting / -> index.gsp which then comes back as a 404.

There is a slightly ugly workaround - just add a mapping like this:

"/index.gsp"(controller: 'home', action: 'index')   

and that seems to do the trick. Anyone have a better way to fix this???

Coddle answered 20/1, 2010 at 1:24 Comment(2)
thanks mate, wow you just made my day! I registered a bug in Jira later todayPurkey
This workaround also worked in a wildfly8 .war deployment which otherwise would show index.gsp not found when accessing the root: "/index.gsp"(view:"/index")Rondarondeau
W
1

It might be related to a Grails 1.2 bug. See GRAILS-5609 and this thread in Grails forum. It is fixed in 1.2.1. It seems that 1.2 introduced some regression bugs with UrlMappings...

Wootten answered 16/1, 2010 at 14:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.