Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import from LESS files in web-app/less can't find plugin files #3

Open
longwa opened this issue Apr 21, 2012 · 6 comments
Open

Import from LESS files in web-app/less can't find plugin files #3

longwa opened this issue Apr 21, 2012 · 6 comments

Comments

@longwa
Copy link

longwa commented Apr 21, 2012

The simple example from the bootstrap plugin fails with a Malformed URI exception because the path searched for imported files does not include the plugin path.

To reproduce, just follow the steps in the bootstrap plugin for customizing.

  1. Create a custom-bootstrap.less in web-app/less directory and add the line "@import "bootstrap.less";
  2. Add a resource entry which dependsOn("bootstrap") with

resource url:[dir: 'less', file: 'custom-bootstrap.less'], attrs:[rel: "stylesheet/less", type:'css']

The compilation of the custom-bootstrap.less file fails:

| Error 2012-04-20 21:06:42,702 [pool-5-thread-1] ERROR resourceMappers.LessResourceMapper - Error compiling less file: /home/along/.grails/2.0.3/projects/boottest/tomcat/work/Tomcat/localhost/boottest/grails-resources/less/custom-bootstrap.less
Message: object Object

The problem seems to be that the "paths" searched in the resolveUri() method only includes the web-app/less directory for the application and not the web-app/less directory for the plugin. That method loops and tries to resolve a URI for the given paths, and if not found, returns null which results in the error above.

@trygvea
Copy link

trygvea commented May 8, 2012

I experience the same thing during startup (run-app) after clean. If I touch ApplicationResources to get resources regenerated, it works.

@sammyhk
Copy link

sammyhk commented Aug 18, 2012

I also experience the same issue during startup. After that when I reload the problematic resources (by editing it), it works again. I guess it is due to the resources in the plugins are not ready during startup. Maybe this plugin should delay its process after other plugins are ready.

@sammyhk
Copy link

sammyhk commented Aug 18, 2012

By the way, any quick fix/ workaround exists to prevent this issue in current stage?

@groovydev
Copy link
Owner

I cannot recreate it. Could you prepare stacktrace with debug log.

sammyhk notifications@github.com pisze:

I also experience the same issue during startup. After that when I reload the problematic resources (by editing it), it works again. I guess it is due to the resources in the plugins are not ready during startup. Maybe this plugin should delay its process after other plugins are ready.


Reply to this email directly or view it on GitHub:
#3 (comment)

@sammyhk
Copy link

sammyhk commented Aug 22, 2012

Step to reproduce the issue:
Note that I'm using Grails 2.1.0, less-resources 1.3.0.2, twitter-bootstrap 2.0.4.
ApplicationResources.groovy:

modules = {
    application {
//  dependsOn("bootstrap") // adding or removing this dependency cause the same issue
        resource(
            url: [dir: "less", file: "custom-bootstrap.less"],
            attrs: [rel: "stylesheet/less", type: "css"]
        )
    }
}

And the web-app/less/custom-bootstrap.less:

@import "bootstrap.less";

@color: green;

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    background-color: @color;
}

And included this resource in layout/main.gsp:

...
<head>
...
    <r:require module="application" />
...
</head>

When starting up the server, it throw an exception:

2012-08-22 11:01:53,261 [pool-5-thread-1] INFO  resource.ResourceProcessor  - Performing a full reload
2012-08-22 11:01:53,835 [pool-5-thread-1] INFO  resource.ResourceProcessor  - Loading resource declarations...
2012-08-22 11:01:53,836 [pool-5-thread-1] INFO  resource.ResourceProcessor  - Forgetting all known modules...
2012-08-22 11:01:53,836 [pool-5-thread-1] INFO  resource.ResourceProcessor  - Forgetting all known resources...
2012-08-22 11:01:53,977 [pool-5-thread-1] WARN  util.GrailsUtil  - [DEPRECATED] Method ApplicationHolder.getApplication() is deprecated and will be removed in a future version of Grails.
2012-08-22 11:01:53,978 [pool-5-thread-1] WARN  util.GrailsUtil  - [DEPRECATED] Method ApplicationHolder.getApplication() is deprecated and will be removed in a future version of Grails.
2012-08-22 11:01:53,978 [pool-5-thread-1] WARN  util.GrailsUtil  - [DEPRECATED] Method ApplicationHolder.getApplication() is deprecated and will be removed in a future version of Grails.
2012-08-22 11:01:54,467 [pool-5-thread-1] WARN  module.ModuleDeclarationsFactory  - 'grails.resources.modules' in config does not define any modules
| Error 2012-08-22 11:01:57,255 [pool-5-thread-1] ERROR resourceMappers.LessResourceMapper  - Error compiling less file: /home/sammy/.grails/2.1.0/projects/test-bootstrap/tomcat/work/Tomcat/localhost/test-bootstrap/grails-resources/less/custom-bootstrap.less
Message: [object Object] (<script>#17742)
    Line | Method
->> 2690 | interpretLoop                 in org.mozilla.javascript.Interpreter
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   2487 | interpret                     in     ''
|    164 | call . . . . . . . . . . . .  in org.mozilla.javascript.InterpretedFunction
|    398 | doTopCall                     in org.mozilla.javascript.ContextFactory
|   3065 | doTopCall . . . . . . . . . . in org.mozilla.javascript.ScriptRuntime
|    175 | exec                          in org.mozilla.javascript.InterpretedFunction
|   1104 | evaluateString . . . . . . .  in org.mozilla.javascript.Context
|     42 | compile                       in com.groovydev.LessCompilerService
|     34 | map . . . . . . . . . . . . . in LessResourceMapper
|    139 | invoke                        in org.grails.plugin.resource.mapper.ResourceMapper
|    128 | invokeIfNotExcluded . . . . . in     ''
|    589 | applyMappers                  in org.grails.plugin.resource.ResourceProcessor
|    535 | prepareResource . . . . . . . in     ''
|    604 | doCall                        in org.grails.plugin.resource.ResourceProcessor$_prepareSingleDeclaredResource_closure12
|     29 | addDeclaredResource . . . . . in org.grails.plugin.resource.util.ResourceMetaStore
|    602 | prepareSingleDeclaredResource in org.grails.plugin.resource.ResourceProcessor
|    627 | doCall . . . . . . . . . . .  in org.grails.plugin.resource.ResourceProcessor$_prepareResourceBatch_closure14
|      8 | each                          in org.grails.plugin.resource.ResourceProcessorBatch
|    623 | prepareResourceBatch . . . .  in org.grails.plugin.resource.ResourceProcessor
|    806 | resourcesChanged              in     ''
|    802 | loadModules . . . . . . . . . in     ''
|   1071 | reloadAll                     in     ''
|    172 | doCall . . . . . . . . . . .  in ResourcesGrailsPlugin$_closure3
|    303 | innerRun                      in java.util.concurrent.FutureTask$Sync
|    138 | run . . . . . . . . . . . . . in java.util.concurrent.FutureTask
|    886 | runTask                       in java.util.concurrent.ThreadPoolExecutor$Worker
|    908 | run . . . . . . . . . . . . . in     ''
^    662 | run                           in java.lang.Thread
2012-08-22 11:02:07,202 [pool-5-thread-1] INFO  resource.ResourceProcessor  - Finished full reload

After that, when I reload the resource by touching the custom-bootstrap.less, it works as expected:

2012-08-22 11:17:21,716 [Thread-16] INFO  compiler.GrailsProjectWatcher  - File [/home/sammy/Workspace/test-bootstrap/web-app/less/custom-bootstrap.less] changed. Applying changes to application.
2012-08-22 11:17:21,738 [Thread-16] INFO  ResourcesGrailsPlugin  - Scheduling reload of resource files due to change of file /home/sammy/Workspace/test-bootstrap/web-app/less/custom-bootstrap.less
2012-08-22 11:17:22,264 [pool-3-thread-1] INFO  resource.ResourceProcessor  - Performing a changed file reload
2012-08-22 11:17:22,267 [pool-3-thread-1] INFO  resource.ResourceProcessor  - Loading declared resources...
2012-08-22 11:17:28,595 [pool-3-thread-1] INFO  resource.ResourceProcessor  - Finished changed file reload

@Vad1mo
Copy link

Vad1mo commented Jan 17, 2013

I got the described problem because the less files need to be compiled all at the same time not one after each other.
As I see the resource framework it only handles one file after another. it can not handle all files at the same time
this is the related issue.
#8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants