0

I'm deploying a GRAILS-application (2.3.5) on a tomcat (7.0.53) server and the deployment itself is without problems. When I click on the test controller (which uses files in the src/data folder), I get this error:

Error 500: Internal Server Error
URI 
   /schedulingAPI-0.1/tests
Class
   java.io.FileNotFoundException
Message
   /home/student/apache-tomcat-7.0.53/bin/src/data/room

I know the WAR looks at the tomcat directory whereas it should look in the WAR itself. I already tried to add the src/data folder (properties > add class folder) to the build path before creating the WAR but that didn't solve the problem.

thomasvdbossche
  • 107
  • 2
  • 9

1 Answers1

2

The Grails documentation on deployment talks about this. The two configuration options available to you are grails.war.copyToWebApp and grails.war.resources. The first of these lets you customise what files are included in the WAR file from the "web-app" directory. The second lets you do any extra processing you want before the WAR file is finally created.

BuildConfig.groovy

// This closure is passed the command line arguments used to start the
// war process.
grails.war.copyToWebApp = { args ->
    fileset(dir:"web-app") {
        include(name: "js/**")
        include(name: "css/**")
        include(name: "WEB-INF/**")
    }
}
// This closure is passed the location of the staging directory that
// is zipped up to make the WAR file, and the command line arguments.
// Here we override the standard web.xml with our own.
grails.war.resources = { stagingDir, args ->
    copy(file: "grails-app/conf/custom-web.xml",
         tofile: "${stagingDir}/WEB-INF/web.xml")
}

In your case you may consider a custom grails.war.resources command such as this:

grails.war.resources = { stagingDir, args ->
    copy(file: "src/bin/**",
         tofile: "${stagingDir}/bin")
}

All of that of course depends on the path you intend to package the additional resources in.

Update In later versions of AntBuilder to include multiple files the preferred method is to use a fileset instead of the ** notation:

grails.war.resources = { stagingDir, args ->
    copy(todir: "${stagingDir}/bin") {
        fileset(dir: "src/bin")
    }
}
Joshua Moore
  • 24,706
  • 6
  • 50
  • 73
  • Thanks joshua, I tried this but when I say src/bin/** the ** are not considered as wild cards, any idea? grails is trying to find file name with src/bin/**. – t31321 Mar 26 '15 at 07:00
  • In later versions of `AntBuilder` the `**` notation is no longer valid. You may want to see: http://stackoverflow.com/questions/29273176/how-to-include-extra-files-when-building-a-war/29273378#29273378 – Joshua Moore Mar 26 '15 at 07:52