Search code examples
grailsclassnotfoundexceptionsitemesh

Grails 2.4 ClassNotFoundException: Sitemesh GrailsPageFilter


Please note: This question is almost a duplicate to this one titled "resource plugin error when upgrading from grails 2.3.8 2.4", however a few things are different that, in my mind, make it worthy of asking it as a separate question:

  • In that question, neither the question nor any answers explain why this error is occurring, other than stating that the plugin being used was no longer the official Grails plugin for loading sitemesh
  • MOST IMPORTANTLY: In that question, there was never an accepted answer or any verification from the original poster about what the final solution was. I won't do that.

So, I ask that before you down/closevote this as a dupe, to please point out to me where in that other question the exact solution was provided that will also apply to my exact situation. If you can't do that, please don't down/closevote this question!

I am upgrading a Grails 2.3.6 app to Grails 2.4.4. When I do a run-app I get:

Error |
2015-03-05 14:42:44,257 [localhost-startStop-1] ERROR [localhost].[/myapp]  - Exception starting filter sitemesh
java.lang.ClassNotFoundException: org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter
    at org.grails.plugins.tomcat.ParentDelegatingClassLoader.findClass(ParentDelegatingClassLoader.java:59)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:532)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:514)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:142)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:258)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4809)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5485)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Error |
2015-03-05 14:42:44,268 [localhost-startStop-1] ERROR core.StandardContext  - Error filterStart
Error |
2015-03-05 14:42:44,270 [localhost-startStop-1] ERROR core.StandardContext  - Context [/myapp] startup failed due to previous errors

Here's my BuildConfig's plugins section:

plugins {
    runtime ":resources:1.2.14"
    compile 'org.grails.plugins:gson:1.1.4'
    compile ":standalone:1.3"
    build ":release:3.0.1"
    runtime ":cached-resources:1.0"
    compile ":cache-headers:1.1.7"
    compile ":yammer-metrics:3.0.1-2"
    compile ":scaffolding:2.1.2"
    compile ':cache:1.1.1'
    runtime ":hibernate:3.6.10.8" // or ":hibernate4:4.3.1.1"
    runtime ":database-migration:1.3.8"
    runtime ":jquery:1.11.1"
    test(":geb:$gebVersion")
    test(":spock:0.7") {
        exclude "spock-grails-support"
    }
}

I do not want to use asset-pipeline if it can be avoided. Everything I've read so far states that using resources:1.2.14 makes a Grails 2.4.4 app compatible with the resources plugin.

Can someone explain the Grails 2.4.4 way of using sitemesh so that this error goes away? If using asset-pipeline is unavoidable, what are the exact conversions I would need to make to my project to use it. I did try replacing the resource plugin with the latest asset pipeline plugin like so:

plugins {
    ...
    //runtime ":resources:1.2.14"
    compile ":asset-pipeline:1.8.3"
    ...
}

But the error didn't go away. Thoughts?


Solution

  • I'm not sure why you wouldn't be able to use the resources plugin in Grails 2.4.4, but my recommendation would be to use the asset-pipeline, as it is far superior to the older resources plugin. Here is a very good article explaining why (from the author of the plugin), and how:

    Edit

    On second look, I believe this may be an issue with an incompatible web.xml from version 2.3.x. which had the following:

    <filter>
        <filter-name>sitemesh</filter-name>
        <filter-class>org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter</filter-class>
    </filter>
    

    Here is a link to the new 2.4.x web.xml file: