Assets do not loading in deployed .WAR

445 views
Skip to first unread message

Robson Oliveira

unread,
Mar 21, 2017, 7:13:40 PM3/21/17
to Grails Dev Discuss
Hello, I have an application using grails 3.1.14 that works perfectly through the run-app command but the assets are not loaded into the .war file. Has anyone ever had this problem?

I'm using:

Grails 3.1.14
Itellij Idea: 2016.3
Gradle: 2.9






build.gradle
application.groovy
application.yml

Steve Hole

unread,
Mar 23, 2017, 9:49:55 AM3/23/17
to Grails Dev Discuss
Yes, we've had this problem. This issue is caused by having the less asset pipeline plugin just in the build dependencies block of the build.gradle. It needs to be in both the gradle plugins section AND in the build dependencies. You should have something that looks like this:

 buildscript {
    repositories {
        mavenLocal()
        maven { url "https://repo.grails.org/grails/core" }
    }
    dependencies {
        classpath "org.grails:grails-gradle-plugin:$grailsVersion"
        classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.13.1"
classpath "com.bertramlabs.plugins:less-asset-pipeline:2.13.1"
        classpath "org.grails.plugins:hibernate5:6.0.7"
    }
 }
 
 version "3.0.0-SNAPSHOT-1"
 group "com.spiekerpoint.ark"

 apply plugin:"eclipse"
 apply plugin:"idea"
 apply plugin:"war"
 apply plugin:"org.grails.grails-web"
 apply plugin:"org.grails.grails-gsp"
 apply plugin:"asset-pipeline"


 dependencyManagement {
    imports {
        mavenBom "org.grails:grails-bom:$grailsVersion"
    }
    applyMavenExclusions false
 }

 dependencies {
    compile "org.springframework.boot:spring-boot-starter-logging"
    compile "org.springframework.boot:spring-boot-autoconfigure"
    compile "org.grails:grails-core"
    compile "org.springframework.boot:spring-boot-starter-actuator"
    compile "org.springframework.boot:spring-boot-starter-tomcat"
    compile "org.grails:grails-dependencies"
    compile "org.grails:grails-web-boot"
    compile "org.grails.plugins:cache"
    compile "org.grails.plugins:scaffolding"
    compile "org.grails.plugins:hibernate5"
    compile "org.hibernate:hibernate-core:5.1.2.Final"
    compile "org.hibernate:hibernate-ehcache:5.1.2.Final"
    
    compile "org.grails.plugins:fields:2.1.3"
    compile 'org.grails.plugins:quartz:2.0.9'
    compile 'org.grails.plugins:external-config:1.0.0'

    compile "com.spiekerpoint.ark:arkAcl:3.0.3"
    compile "com.spiekerpoint.ark:arkCase:3.0.1-SNAPSHOT"
    compile "com.spiekerpoint.ark:arkCluster:3.0.6"
    compile "com.spiekerpoint.ark:arkContent:3.0.7"
    compile "com.spiekerpoint.ark:arkContentUi:3.0.3"
    compile "com.spiekerpoint.ark:arkCore:3.0.12
    compile "com.spiekerpoint.ark:arkComponents:3.0.8"
    compile "com.spiekerpoint.ark:arkDashboard:3.0.8-SNAPSHOT"
    compile "com.spiekerpoint.ark:arkDocument:3.0.9"
    compile "com.spiekerpoint.ark:arkFolderUi:3.0.0"
    compile "com.spiekerpoint.ark:arkJanitor:3.0.1"
    compile "com.spiekerpoint.ark:arkJanitorUi:3.0.0"
    compile "com.spiekerpoint.ark:arkMeeting:3.0.9"
    compile "com.spiekerpoint.ark:arkMessage:3.0.12"
    compile "com.spiekerpoint.ark:arkNavigation:3.0.1"
    compile "com.spiekerpoint.ark:arkOption:3.0.9"
    compile "com.spiekerpoint.ark:arkOptionUi:3.0.6"
    compile "com.spiekerpoint.ark:arkSecurity:3.0.14"
    compile "com.spiekerpoint.ark:arkSecurityUi:3.0.22-SNAPSHOT"
    compile "com.spiekerpoint.ark:arkTable:3.0.15"
    compile "com.spiekerpoint.ark:arkTour:3.0.1"
    compile "com.spiekerpoint.ark:arkUi:3.0.26-SNAPSHOT"
    compile "com.spiekerpoint.ark:arkUiThemeDefault:3.0.1"
    compile "com.spiekerpoint.ark:arkWorkflow:3.0.1-SNAPSHOT"
    
    console "org.grails:grails-console"
    profile "org.grails.profiles:web"
    
    runtime "mysql:mysql-connector-java:5.1.36"
    runtime "com.h2database:h2"
    runtime "org.grails.plugins:grails-cookie:2.0.3"
    runtime "org.grails.plugins:quartz-monitor:1.3"
    runtime "org.grails.plugins:grails-console:2.0.8"
    runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.13.1"
    assets  "com.bertramlabs.plugins:less-asset-pipeline:2.13.1"    
    
    testCompile "org.grails:grails-plugin-testing"
    testCompile "org.grails.plugins:geb"
    testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
    testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"

Robson Oliveira

unread,
Mar 23, 2017, 1:16:16 PM3/23/17
to grails-de...@googlegroups.com
Steve,
Thanks for the answer, after changing the build.gradle file and running the "gradlew assemble" command the application returns
Processing File 32 of 182 - jquery-mousewheel/jquery.mousewheel.js
:assetCompile FAILED
Processing File 31 of 182 - jquery/jquery.js
Processing File 34 of 182 - jquery-ui-1.11.4.custom/jquery-ui.min.js
Processing File 33 of 182 - jquery-ui/jquery-ui.js

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':assetCompile'.
> java.util.concurrent.ExecutionException: java.lang.Exception: LESS Engine Compiler Failed - bootstrap.less.
**Did you mean to compile this file individually (check docs on exclusion)?**


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.


--
You received this message because you are subscribed to a topic in the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/grails-dev-discuss/uTDyuPLKKzg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to grails-dev-discuss+unsub...@googlegroups.com.
To post to this group, send email to grails-dev-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/20ae8e2d-6754-4226-93ad-fa7bb7ded20a%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

build.gradle

Steve Hole

unread,
Mar 23, 2017, 3:27:27 PM3/23/17
to Grails Dev Discuss
You need to exclude the assets that you don't want directly referenced by your application. You do that within the asset block of the build.gradle. It looks something like this:

assets {
    minifyJs = true
    minifyCss = true
    excludes = [
        /* DOC - In general, we only compile manifest files and ignore the underlying libraries. As the
         * libraries are referenced by the manifests, we get all of the assets we ever reference in the
         * application and we don't support direct referencing of the libraries (the stuff in assets/lib/**).
         */
        
        //Application assets and asset libraries
        'mixins/*.less',
        "application-variables.less",
        "Highcharts/**", 
        "HighMaps/**",      
        
        //ArkUi asset libraries
        "ark-ui.less",
        "bootstrap/**",
        "jquery/**",
        "jquery-ui/**",
        "cookie/**",
        "gridster/**",
        "jsTimezoneDetect/**",
        
        //ArkComponent asset libraries
        "bootstrap-datetimepicker/**",
        "bootstrap-fileinput/**",
        "bootstrap-select/**",
        "Chart/**",
        "editable-table-master/**",
        "jasny-bootstrap/**",
        "jstree/**",
        "multiple-range-slider/**",
        "select2/**",
        "X-editable/**",
        
        //ArkMeeting asset libraries
        "meeting-variables.less",
        "bootstrap-suggest/**",
    ]
}

As noted in the comment, we put all of our libraries (jquery, bootstrap, jquery plugins etc.) into an "assets/lib" directory and then reference them in asset manifests. We exclude the lib source for .js, .css and .less files that come in the library versions. That should clean everything up for.

I will note that we are using Grails 3.2.6 and the latest version of the asset-pipeline support. I can't say if there are issues with older versions that I don't know about. I can say definitively that it does all work when it is configured properly, so keep trying.

Cheers.
To post to this group, send email to grails-de...@googlegroups.com.

Vijay Lakshman

unread,
Jun 9, 2017, 9:03:59 AM6/9/17
to Grails Dev Discuss
We ran into a similar situation. The assets scope did not work for the LESS compiler dependency. Changing the scope to runtime helped resolve our issue
Reply all
Reply to author
Forward
0 new messages