google-code-export / wiquery

Automatically exported from code.google.com/p/wiquery
MIT License
1 stars 1 forks source link

Wrong resource-lookup (NPE) in WiQueryMergedCSS/JSResourceReference if multiple classloaders are used #172

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
If you use different class loaders for wiquery.jar and rest-of-application.jar 
(eg by loading wiquery globally in some application server, and having 
local-scoped class loaders for every installed ear), and using some 
css-resources included in rest-of-application.jar, the resource lookup in both 
WiQueryMergedStyleSheetResourceReference and 
WiQueryMergedJavaScriptResourceReference fails with NPE due to not beeing able 
to locate the requested resources using the class loader of wiquery.jar. 

This is due to the lookup-code like:
temp = Streams.readString(
getClass().getResourceAsStream(...)

which uses the wiquery-based classloader to lookup the requested resource.

WiQueryMergedStyleSheetResourceReference line 192

WiQueryMergedJavaScriptResourceReference line 121

Instead, the correct usage would be one out of those two:
either use (the standard java way):
Thread.currentThread().contextClassLoader().getResource...
which uses the classloader of the running thread, which always should be able 
to look up the requested resource (as it encapsulates both the classes of 
rest-of-application and wiquery)

or (the wicket-way)
Application.get().getResourceSettings().getResourceStreamLocator().locate(scope,
 resourceName);

What version of the product are you using? On what operating system?
wiquery-1.2.3

A different idea to solve the problem could be to use 
wicketstuff-merged-resources in favour of implementing all those logic 
yourself. This of course will take quite some rewrite of the current code base 
and adding one more dependency, but will lead to a more focused fullfillment of 
the base goal to provide a jquery integration (and letting some other 
specialised library doing the compression stuff).

Original issue reported on code.google.com by ste...@schueffler.de on 12 Apr 2011 at 2:00

GoogleCodeExporter commented 9 years ago
Done first part in http://code.google.com/p/wiquery/source/detail?r=

As for the second part: the wicketstuff-merged-resources is quite basic and 
looks a lot like our merged approach. You can already use 
wicketstuff-merged-resources with wiquery, simply disable resource merging in 
wiquery :)

On a side note: what I am planning to make is a smarter system which gives you 
deltas based on which resources one already has. This takes a lot of time, 
which i hardly have, so this will not be ready any time soon..

Original comment by hielke.hoeve on 12 Apr 2011 at 2:35