Closed GoogleCodeExporter closed 9 years ago
I notice that when using wro4j-1.6.2, the url of the resource being processed
looks like: /../assets/stylesheets/page.css, while when using the wro4j-1.4.8.1
it looks like: /assets/stylesheets/page.css
I assume it has something to do with the way the model is built. Could you
provide more details? How your wro.xml looks like? How do you configure it?
Please provide as many details as you can.
Original comment by alex.obj...@gmail.com
on 11 Jan 2013 at 9:35
In src/main/webapp/WEB-INF/wro.xml I have:
<group name="application">
<css>/assets/stylesheets/application.css</css>
</group>
and other .js groups which works correctly.
application.css is the only css that is included on the page.
also in web.xml mapping part is:
<filter-mapping>
<filter-name>WebResourceOptimizer</filter-name>
<url-pattern>/assets/*</url-pattern>
</filter-mapping>
I also use custom
<filter>
<filter-name>WebResourceOptimizer</filter-name>
<filter-class>com.diio.platform.wro.http.CustomWroFilter</filter-class>
</filter>
which just allows to override wro.properties with wro-debug.properties and
wro-override.properties depending on environment, but this should not be
related to the issue.
I tested both in debug and not debug mode.
Original comment by lystoc...@gmail.com
on 11 Jan 2013 at 9:47
I think this has to do with the way the css is imported. Not sure yet why there
is a difference with the older version, but could you try instead of:
assets/stylesheets/application.css
to import the
/<context>/assets/stylesheets/application.css
Let me know if that fixes the problem. I'll try to identify the cause of the
problem when css is imported with relative url.
Original comment by alex.obj...@gmail.com
on 11 Jan 2013 at 9:52
Original comment by alex.obj...@gmail.com
on 11 Jan 2013 at 9:53
Oh, sorry, I missed important bits which is applied in this case:
I also have in web.xml:
<filter-mapping>
<filter-name>WebResourceOptimizer</filter-name>
<url-pattern>/v/*</url-pattern>
</filter-mapping>
and application.css is actually included on page as
<link rel="stylesheet" type="text/css"
href="/starod/v/-/assets/application.css" />
where '-' is replaced with build number in production mode to allow cache
bursting.
Original comment by lystoc...@gmail.com
on 11 Jan 2013 at 10:00
/starod/ is webapp context here
Original comment by lystoc...@gmail.com
on 11 Jan 2013 at 10:00
The version you encode in url is the one which breaks the computation of the
css path, since you are adding a virtual subfolder (-) which changes the way
relative resource path is computed.
Could you try a different approach for encoding version for aggressive caching?
Example: /assets-123/application.css & strip the -123 on the serverside when
serving request... or /assets/application.css?version=123 which should work
without any changes....
Original comment by alex.obj...@gmail.com
on 11 Jan 2013 at 10:06
From my point of view, since you are changing with css path name, it is your
responsibility to handle it in a custom way, so this is not a bug.
Original comment by alex.obj...@gmail.com
on 11 Jan 2013 at 10:07
Also, I recommend to consider using http://tuckey.org/urlrewrite/ which could
probably be useful for your use-case.
Original comment by alex.obj...@gmail.com
on 11 Jan 2013 at 10:13
Do you mean that in v1.4.8.1 it works correctly by some 'mistake' and now in
1.6.2 it regressioned because something else was fixed? I don't understand why
it can not work as in 1.4.8.1.
Original comment by lystoc...@gmail.com
on 11 Jan 2013 at 10:14
I'm not sure yet why it worked correctly in 1.4.8.1, but the current behavior
is the expected one. I'll do some investigation to identify the reason ... very
interesting :)
Original comment by alex.obj...@gmail.com
on 11 Jan 2013 at 10:17
I tried urlrewrite before and was having problems with css image urls rewriting
not being working correctly in this case (or I would need some custom solution
for images url rewritting) - spend lots of time on this. But then I realized
that wro4j ignoring /context/path/<gropu>.js|css and I could put into path
anything to allow cache bursting.
Original comment by lystoc...@gmail.com
on 11 Jan 2013 at 10:29
There is an open issue for this: issue280. I hope to have enough time to
implement that feature. Contributions are welcome. I like when people are
contributing, since it allows to discuss this kind of issues and approaches.
Original comment by alex.obj...@gmail.com
on 11 Jan 2013 at 10:31
Btw, could you try with other versions too? I'm wondering where exactly the
change related to this issue happened. Let me know if it works the same way
with 1.5.0 or 1.6.0..
Thanks.
Original comment by alex.obj...@gmail.com
on 11 Jan 2013 at 10:35
I'm not sure how issue280 is related to this. With urlrewrite combined with
wro4j css image url rewritting I was having image urls having incorrect
relative paths.
Original comment by lystoc...@gmail.com
on 11 Jan 2013 at 10:48
It appears it worked in all previous versions (1.5.0, 1.6.0, 1.6.1) but just
not in 1.6.2.
Original comment by lystoc...@gmail.com
on 11 Jan 2013 at 10:49
That is weird... Thanks for confirming this.
The issue280 is not related to this particular issue, but is a feature which
enhance aggressive caching for images referred by css..
Original comment by alex.obj...@gmail.com
on 11 Jan 2013 at 10:51
Hey Alex,
I wanted to confirm I also see this issue on 1.6.2, but not 1.6.1. I was using
urlrewrite with /v-*/, but have found that this issue exists if I also use my
/nocache/ path which avoids the urlrewrite entirely.
Thanks,
D.
Original comment by dannyjro...@gmail.com
on 12 Feb 2013 at 6:45
Can you elaborate on your configuration?
Original comment by alex.obj...@gmail.com
on 12 Feb 2013 at 6:48
UPDATE: Removing any @Imports from my css files and just adding them directly
to wro.xml worked around this issue for me.
Here's my configuration that caused the failure - running 1.6.2:
wro.xml section
<group name="legacy">
<!-- Legacy CSS - this needs to be removed by the end of migration -->
<css>/css/legacy/style.css</css>
</group>
styles.css
/* CSS Document */
@import url("style-common.css");
@import url("style-components.css");
@import url("style-plugins.css");
ro.isdc.wro.model.resource.processor.impl.css.CssImportPreProcessor@503bbcfd,
ro.isdc.wro.model.resource.processor.impl.js.SemicolonAppenderPreProcessor@1f4af
32]
2013-02-12 15:20:46,049 [http-bio-8100-exec-1] DEBUG
r.i.w.m.r.l.ServletContextUriLocator - locate resource:
/css/css/legacy/style-common.css
2013-02-12 15:20:46,049 [http-bio-8100-exec-1] DEBUG
r.i.w.m.r.l.s.DispatcherStreamLocator - dispatching request to location:
/css/css/legacy/style-common.css
Feb 12, 2013 3:20:46 PM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet default threw exception
java.io.FileNotFoundException: The requested resource
(/thdc/css/css/legacy/style-common.css) is not available
at org.apache.catalina.servlets.DefaultServlet.serveResource(DefaultServlet.java:776)
at org.apache.catalina.servlets.DefaultServlet.doGet(DefaultServlet.java:411)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:690)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:599)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:536)
at ro.isdc.wro.model.resource.locator.support.DispatcherStreamLocator.getInputStream(DispatcherStreamLocator.java:77)
at ro.isdc.wro.model.resource.locator.ServletContextUriLocator.dispatcherBasedStreamLocator(ServletContextUriLocator.java:206)
at ro.isdc.wro.model.resource.locator.ServletContextUriLocator.dispatcherFirstStreamLocator(ServletContextUriLocator.java:193)
at ro.isdc.wro.model.resource.locator.ServletContextUriLocator.locate(ServletContextUriLocator.java:168)
at ro.isdc.wro.model.resource.locator.factory.InjectorAwareUriLocatorFactoryDecorator.locate(InjectorAwareUriLocatorFactoryDecorator.java:56)
at ro.isdc.wro.model.group.processor.PreProcessorExecutor.getResourceContent(PreProcessorExecutor.java:251)
at ro.isdc.wro.model.group.processor.PreProcessorExecutor.applyPreProcessors(PreProcessorExecutor.java:191)
at ro.isdc.wro.model.group.processor.PreProcessorExecutor.processAndMerge(PreProcessorExecutor.java:105)
at ro.isdc.wro.model.resource.processor.impl.css.CssImportPreProcessor.doTransform(CssImportPreProcessor.java:50)
at ro.isdc.wro.model.resource.processor.impl.css.AbstractCssImportPreProcessor.parseCss(AbstractCssImportPreProcessor.java:109)
at ro.isdc.wro.model.resource.processor.impl.css.AbstractCssImportPreProcessor.process(AbstractCssImportPreProcessor.java:74)
at ro.isdc.wro.model.resource.processor.decorator.ProcessorDecorator.process(ProcessorDecorator.java:87)
at ro.isdc.wro.model.resource.processor.decorator.ProcessorDecorator.process(ProcessorDecorator.java:87)
at ro.isdc.wro.model.resource.processor.decorator.ProcessorDecorator.process(ProcessorDecorator.java:87)
at ro.isdc.wro.model.resource.processor.decorator.SupportAwareProcessorDecorator.process(SupportAwareProcessorDecorator.java:39)
at ro.isdc.wro.model.resource.processor.decorator.ProcessorDecorator.process(ProcessorDecorator.java:87)
at ro.isdc.wro.model.resource.processor.decorator.ExceptionHandlingProcessorDecorator.process(ExceptionHandlingProcessorDecorator.java:56)
at ro.isdc.wro.model.resource.processor.decorator.ProcessorDecorator.process(ProcessorDecorator.java:87)
at ro.isdc.wro.model.group.processor.PreProcessorExecutor.applyPreProcessors(PreProcessorExecutor.java:216)
at ro.isdc.wro.model.group.processor.PreProcessorExecutor.processAndMerge(PreProcessorExecutor.java:105)
at ro.isdc.wro.model.group.processor.PreProcessorExecutor.processAndMerge(PreProcessorExecutor.java:79)
at ro.isdc.wro.model.group.processor.GroupsProcessor.process(GroupsProcessor.java:81)
at ro.isdc.wro.cache.support.DefaultSynchronizedCacheStrategyDecorator.loadValue(DefaultSynchronizedCacheStrategyDecorator.java:90)
at ro.isdc.wro.cache.support.DefaultSynchronizedCacheStrategyDecorator.loadValue(DefaultSynchronizedCacheStrategyDecorator.java:36)
at ro.isdc.wro.cache.support.AbstractSynchronizedCacheStrategyDecorator.get(AbstractSynchronizedCacheStrategyDecorator.java:57)
at ro.isdc.wro.manager.ResourceBundleProcessor.serveProcessedBundle(ResourceBundleProcessor.java:66)
at ro.isdc.wro.manager.WroManager.process(WroManager.java:127)
at ro.isdc.wro.http.WroFilter.processRequest(WroFilter.java:328)
at ro.isdc.wro.http.WroFilter.doFilter(WroFilter.java:270)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:394)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
2013-02-12 15:20:46,051 [http-bio-8100-exec-1] DEBUG
r.i.w.m.r.l.s.DispatcherStreamLocator - [FAIL] Error while dispatching the
request for location /css/css/legacy/style-common.css
2013-02-12 15:20:46,082 [http-bio-8100-exec-1] DEBUG
r.i.w.m.r.l.ServletContextUriLocator - retrieving servletContext stream for
uri: /css/css/legacy/style-common.css
2013-02-12 15:20:46,083 [http-bio-8100-exec-1] DEBUG
r.i.w.m.r.l.ServletContextUriLocator - [FAIL] reading resource from
/css/css/legacy/style-common.css
2013-02-12 15:20:46,084 [http-bio-8100-exec-1] DEBUG
r.i.w.m.r.l.ServletContextUriLocator - Wrong or empty resource with location:
/css/css/legacy/style-common.css
2013-02-12 15:20:46,084 [http-bio-8100-exec-1] DEBUG
r.i.w.m.g.p.PreProcessorExecutor - Invalid resource found:
ro.isdc.wro.model.resource.Resource@500ab58d[CSS,/css/css/legacy/style-common.cs
s,true]
2013-02-12 15:20:46,084 [http-bio-8100-exec-1] ERROR
r.i.w.m.g.p.PreProcessorExecutor - Cannot ignore missing resource:
ro.isdc.wro.model.resource.Resource@500ab58d[CSS,/css/css/legacy/style-common.cs
s,true]
2013-02-12 15:20:46,084 [http-bio-8100-exec-1] DEBUG
r.i.w.m.r.p.d.ExceptionHandlingProcessorDecorator - Failed to process the
resource:
ro.isdc.wro.model.resource.Resource@4e64f6fe[CSS,/css/legacy/style.css,true]
using processor:
ro.isdc.wro.model.resource.processor.impl.css.CssImportPreProcessor@503bbcfd.
Reason: Exception while reading resource from /css/css/legacy/style-common.css
2013-02-12 15:20:46,090 [http-bio-8100-exec-1] DEBUG
r.i.w.m.r.p.d.ExceptionHandlingProcessorDecorator - Original Exception
java.io.IOException: Exception while reading resource from
/css/css/legacy/style-common.css
at ro.isdc.wro.model.resource.locator.ServletContextUriLocator.validateInputStreamIsNotNull(ServletContextUriLocator.java:227) ~[wro4j-core-1.6.2.jar:1.6.2]
at ro.isdc.wro.model.resource.locator.ServletContextUriLocator.locate(ServletContextUriLocator.java:172) ~[wro4j-core-1.6.2.jar:1.6.2]
at ro.isdc.wro.model.resource.locator.factory.InjectorAwareUriLocatorFactoryDecorator.locate(InjectorAwareUriLocatorFactoryDecorator.java:56) ~[wro4j-core-1.6.2.jar:1.6.2]
at ro.isdc.wro.model.group.processor.PreProcessorExecutor.getResourceContent(PreProcessorExecutor.java:251) [wro4j-core-1.6.2.jar:1.6.2]
at ro.isdc.wro.model.group.processor.PreProcessorExecutor.applyPreProcessors(PreProcessorExecutor.java:191) [wro4j-core-1.6.2.jar:1.6.2]
at ro.isdc.wro.model.group.processor.PreProcessorExecutor.processAndMerge(PreProcessorExecutor.java:105) [wro4j-core-1.6.2.jar:1.6.2]
at ro.isdc.wro.model.resource.processor.impl.css.CssImportPreProcessor.doTransform(CssImportPreProcessor.java:50) ~[wro4j-core-1.6.2.jar:1.6.2]
Original comment by dannyjro...@gmail.com
on 12 Feb 2013 at 8:55
Attachments:
This issue is fixed in branch 1.6.x.
Can anybody confirm that it works with your project?
Thanks!
Original comment by alex.obj...@gmail.com
on 19 Feb 2013 at 5:50
The cause of the problem: apparently the regex used to identify the @import
statement was wrong. I don't understand why this problem didn't occur
earlier... :)
Original comment by alex.obj...@gmail.com
on 19 Feb 2013 at 5:51
For some reason I wasn't able to reproduce the problem on 1.6.2 anymore, is
there any specifics that causes it?
Original comment by lystoc...@gmail.com
on 19 Feb 2013 at 8:18
I was able to reproduce the problem when there is a css resource containing
@import statement and has some relative url's which should be rewritten with
cssUrlRewritingProcessor. Once the @import statements are removed and imported
resource are referenced in the model, the problem cannot be reproduced anymore.
@lystochok You are saying that you can't reproduce with 1.6.2. Have you
modified anything since you've reported the problem? If yes, it would help if
you could use initial configuration and try the snapshot version (1.6.3) to
confirm that the problem is fixed for your test-case.
Original comment by alex.obj...@gmail.com
on 19 Feb 2013 at 8:26
Sorry, I couldn't reproduce it because styles were not used (were embedded into
page itself as workaround), so now I was able to confirm again it didn't work
in 1.6.2 BUT I'm still able to reproduce it in 1.6.3-SNAPSHOT. Attaching log.
Original comment by lystoc...@gmail.com
on 19 Feb 2013 at 10:28
Attachments:
Managed to reproduce the problem. The cause is the following: apparently the
cssUrlRewriter also rewrites @import statements. Until the fix is available,
use a different import syntax:
Instead of:
@import url("path/to/style.css");
use
@import "path/to/style.css";
I have a fix already, but need to create more unit tests to be sure that
nothing else is broken.
Original comment by alex.obj...@gmail.com
on 20 Feb 2013 at 1:53
Reopening issue, until the final fix is committed.
Original comment by alex.obj...@gmail.com
on 20 Feb 2013 at 1:53
Fixed in 1.6.x.
@lystochok - could you try with the latest version again and confirm it works
now?
Original comment by alex.obj...@gmail.com
on 22 Feb 2013 at 2:56
Thanks Alex, now I can confirm it works as required. Looking forward to new
1.6.3 release which will be first one bugless for me :).
Original comment by lystoc...@gmail.com
on 22 Feb 2013 at 7:04
Bugfree software hans random features :)
Original comment by alex.obj...@gmail.com
on 22 Feb 2013 at 7:54
Original issue reported on code.google.com by
lystoc...@gmail.com
on 11 Jan 2013 at 9:23