0

I've created a Grails 3.1.1 app that uses a form to load a table with data. Running locally, everything works fine. When deployed to a remote Tomcat however, submitting the form results in a javax.servlet.ServletException error.

Typical error: javax.servlet.ServletException: Could not resolve view with name 'stuckOrders' in servlet with name 'grailsDispatcherServlet'

Snippet from stuckOrders.gsp:

<html>
    <head>
        <meta name="layout" content="main"/>
        <asset:javascript src="application.js"/>
        <title>LPP Order Fixer</title>
    </head>
<body>
    <div id="orders" style="float:left;width:70%;height:90%;">
        <g:form name="stuckOrders" controller="lppOrderFixer" action="stuckOrders">
            <label>Location: </label>
            <input type="radio" id="locationReno" name="location" value="Reno"> Reno
            <input type="radio" id="locationGalion" name="location" value="Galion"> Galion
            <g:actionSubmit value="Locate Orders" action="stuckOrders"/>

LppOrderFixerController.groovy:

package lpporderfixer
class LppOrderFixerController {
    def lppOrderFixerService
    def location

    def index() {}
    def stuckOrders() {
        location = Location.valueOf(params?.location)
        List stuckOrdersList = lppOrderFixerService.fetchStuckOrders(location)
        [stuckOrders:stuckOrdersList]
    }
}

UrlMappings.groovy:

package lpporderfixer
class UrlMappings {
    static mappings = {
        "/$controller/$action?/$id?(.$format)?"{
            constraints {
                // apply constraints here
            }
        }
        "/"(view:"/lpporderfixer/stuckOrders")
        "500"(view:'/error')
        "404"(view:'/notFound')
    }
}

Project view layout:

LPPOrderFixer view layout

I tried replacing [stuckOrders:stuckOrdersList] with render(view: 'stuckOrders', model:[stuckOrders:stuckOrdersList] in LppOrderFixerController.groovy, didn't seem to change anything.

Locally, the application starts at http://localhost:8080/. Submitting the form then populates the table, with the URL changed to http://localhost:8080/lppOrderFixer/stuckOrders.

On the remote Tomcat, the application is not at the root context, and so it starts at http://<remotehost>:8080/lpporderfixer/. Submitting the form results in the error, at the URL http://<remotehost>:8080/lpporderfixer/lppOrderFixer/stuckOrders.

I've spent the entire day trying to get this to work, and any suggestions would be wildly appreciated. Thanks in advance!

1 Answers1

0

I suspect that this is happing because the GSPs are not being compiled and shipped in your war file.

Please add this to your build.gradle file if not already

apply plugin:'war'
apply plugin:'org.grails.grails-web'
apply plugin:"org.grails.grails-gsp"

Look for apply plugin:"org.grails.grails-gsp", you should already be having the first two.

Nikhil Sharma
  • 891
  • 1
  • 8
  • 11