Search code examples
grailsweblogichttp-status-code-404render

Grails not able to render GSP when deployed in weblogic


I am facing an issue when I am deploying my grails (2.4.0) project war into weblogic 12.1.2. The war works perfectly fine when deployed into tomcat. Issue is, when the war is deployed in weblogic. Once the user logs in, the authentication process using LDAP also works fine. Next the home page should be rendered with a GSP page, but seems weblogic is not able to render the GSP page. It is throwing 404 on the browser.

Once I log in to the application, if I directly use any URL in the browser, the flow goes to the Controller and performs all the required code execution in the controller but it fails to go back to view and render the GSP page mentioned in the "render" block.

My Controller action code is as below:

def index(){
    log.debug("**********Reached MyHomeController**********")
    MyHome myHome = new MyHome()
    myHome.setMessageId(1)
    myHome.setMessageText("***TEST MESSAGE***")

    render (view: 'myhome')
}

I tried to render a plain text on the browser using the same controller action and it works fine. I am able to see the message rendered on the browser without issue, even in weblogic deployment.

def index(){
    log.debug("**********Reached MyHomeController.testCall**********")
    render ("*@***Reached MyHomeController.testCall**********")
}

I have verified the weblogic issues in grails site ([here][1]) and have done the remedies mentioned there. But I think, the issue is requests are getting submitted to correct Controller but when coming back to UI, weblogic is not able to find the GSP (where as tomcat has no issue with it).

Please help in resolving how to make the GSP get rendered when deployed in weblogic. Below is the exception in log when weblogic throws a 404 on the browser: Not sure why it is trying to find a *.jsp file.

: MyHomeController - **********Reached MyHomeController********** ::: [2c5cb87d-29ad-4006-8294-4a1f355e124e] [Lokajit_Tikayatray] : OptimizedAutowireCapableBeanFactory - Returning cached instance of singleton bean 'groovyPagesUriService' ::: [2c5cb87d-29ad-4006-8294-4a1f355e124e] [Lokajit_Tikayatray] : AbstractGrailsControllerHelper - Action [testCall1] executed with result [null] and view name [/myHome/index] ::: [2c5cb87d-29ad-4006-8294-4a1f355e124e] [Lokajit_Tikayatray] : AbstractGrailsControllerHelper - Action [testCall1] handled, created Spring model and view [ModelAndView: reference to view with name '/myHome/myhome'; model is {}] ::: [2c5cb87d-29ad-4006-8294-4a1f355e124e] [Lokajit_Tikayatray] : SimpleGrailsController - [SimpleGrailsController] Forwarding model and view [ModelAndView: reference to view with name '/myHome/myhome'; model is {}] with class [/myHome/myhome] ::: [2c5cb87d-29ad-4006-8294-4a1f355e124e] [Lokajit_Tikayatray] : CompositeInterceptor - postHandle SecurityContextHolderAwareRequestWrapper[ org.springframework.security.web.context.HttpSessionSecurityContextRepository$Servlet3SaveToSessionRequestWrapper@320c8103], org.springframework.security.web.context.HttpSessionSecurityContextRepository$SaveToSessionResponseWrapper@52ea05a0, org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsController@4720353f, ModelAndView: reference to view with name '/myHome/myhome'; model is {} ::: [2c5cb87d-29ad-4006-8294-4a1f355e124e] [Lokajit_Tikayatray] : GrailsDispatcherServlet - Rendering view [org.codehaus.groovy.grails.web.sitemesh.SitemeshLayoutView: unnamed; URL [null]] in DispatcherServlet with name 'grails' ::: [2c5cb87d-29ad-4006-8294-4a1f355e124e] [Lokajit_Tikayatray] : JstlView - Forwarding to resource [/WEB-INF/grails-app/views/myHome/myhome.jsp] in InternalResourceView 'null' ::: [2c5cb87d-29ad-4006-8294-4a1f355e124e] [Lokajit_Tikayatray] : GrailsDispatcherServlet - Error rendering view [org.codehaus.groovy.grails.web.sitemesh.SitemeshLayoutView: unnamed; URL [null]] in DispatcherServlet with name 'grails' java.lang.NullPointerException at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:341) at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79) at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:574) at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:272) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79) at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.java:53) at grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter.doFilter(RequestHolderAuthenticationFilter.java:49) at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.java:82) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3367) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3333) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120) at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57) at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2220) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2146) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2124) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1564) at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:295) at weblogic.work.ExecuteThread.run(ExecuteThread.java:254)


Solution

  • Finally, the deployment worked with weblogic with properly navigating from one page to another. The issue was with naming convention for the view folders. Seems weblogic needs the view folder name exactly same (case sensitive) as the URL generated by framework.

    log printed:
    Forwarding to resource [/WEB-INF/grails-app/views/myHome/myhome.jsp]

    So, weblogic was trying to find the 'myhome' GSP file inside the "myHome" folder (with H in capital) but all my view folder names were in lower case. Hence, weblogic was not able to find the GSP in the URL. Even when I copied similar JSP to the required path still it failed to find it. Getting clue from the log, I changed my view folder names to exactly same cases as the URL and it worked fine. :)

    Same is not the case with Tomcat. Tomcat does not use the URL as case sensitive. It is able to find the URL path in any case. That is why my application was working fine with tomcat even when URL was /myHome/** but my view folder name was 'myhome'. As tomcat was able to identify the URL path properly, hence it did not strike me that weblogic will be doing a case sensitive search of the URL path (until I ran out of all possible options to fix the issue :) ).