How to actually use JAWR with a library from a CDN - cdn

We use JAWR to serve content, but would like to also make use of a CDN to distribute scripts. For instance, to use jQuery, we have:
jawr.js.bundle.jquery.id=/bundles/jquery.js
jawr.js.bundle.jquery.mappings=/js/lib/.license,/js/lib/jquery-1.8.2.js
jawr.js.bundle.jquery.productionURL=http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js
That works great. We get the local library in debug mode, and the one from CDN in production mode. However, let’s add:
jawr.js.bundle.bootstrap.id=/bundles/bootstrap.js
jawr.js.bundle.bootstrap.mappings=/js/lib/bootstrap-2.1.0/js/.license,/js/lib/bootstrap-2.1.0/js/bootstrap.js
jawr.js.bundle.bootstrap.dependencies=jquery
Now, upon access (not upon startup) of a page using /bundles/bootstrap.js, JAWR throws a nasty exception:
java.lang.IllegalStateException: The bundleDataHashCode must be set before accessing the url prefix.
at net.jawr.web.resource.bundle.JoinableResourceBundleImpl.getURLPrefix(JoinableResourceBundleImpl.java:560)
...
at net.jawr.web.taglib.AbstractResourceBundleTag.doStartTag(AbstractResourceBundleTag.java:68)
...
Does that mean I cannot depend on a bundle with a productionURL?

There is an open issue on JAWR about this and a thread (without any answers) in the forum. The answer (from myself) for now is:
You can use productionURL, but do not depend on these bundles. All that is broken
is the dependency mechanism. Manually adding all the necessary <jawr:.../> tags works.

Related

How to allow log4j-2.17.2 to download configuarion via HTTP?

We have a similar problem to that of the asker of this question -- after upgrading from log4j-2.17.1 to 2.17.2, the application, though otherwise working, is not logging anything.
Having read the release notes, I see the following part:
By default, the only remote protocol allowed for loading configuration files is HTTPS.
Users can specify a system property to allow others or prevent remote loading entirely.
Indeed, in our case the log4j2.xml is downloaded via regular (non-encrypted) HTTP, and that likely explains our problem (as well as that of the other guy). However, try as I might, I cannot find, how to (re)enable the ability to use HTTP -- which system property is it, that now controls the capability?
Thanks!
The system property you are looking for is called log4j2.Configuration.allowedProtocols (cf. documentation) and should contained a comma separated list of URL schemes (e.g. "http,https").
You can set it using any available property source (e.g. a log4j.component.properties file or a Java system property).

Symfony 5 hanndle access for external tools (knpsnappy)

In a Symfony 5.x project I use knplabs/knp-snappy-bundle.
Having private data-folders for different users results in generating PDF-documents that require images from folders which are not publicly accessable.
When trying to generate a PDF-document with an image in such a folder knpsnappy runs into a 60 sec timeout. The Symfony log says
Guard authenticator does not support the request.
I assume something regarding the "external" tool knpsnappy calling from outside the application but from the same server but does not triggering any security definition I defined.
I am unsure on how to allow knpsnappy to access a specific route.
Maybe someone can lead me into the right direction...?
I was misslead.
The cause of the problem wasn't access rights but the way the img-pathes were defined.
knp snappy wont be able to render images with URL-routes.
I switched the pathes to be absolut server pathes and now it works.
Found the solution here:
KnpSnappyBundle and Symfony 3.4 : images and/or css cause timeout

MVC4: List of all urls available on the site?

We have quite a large MVC4 application and we would like to have Selenium go through every page and make sure it loads - some sort of smoke test.
I can use reflection to go through the assembly, find all controllers and all actions, check if actions are not post, come up with parameters for actions that require parameters.
Then I'll feed this list to Selenium and check that everything I need on the pages is done appropriately.
But before I start playing with reflection, I'd like to check if this has already been done, so I don't reinvent the bicycle. I have googled for such thing, but could not find anything.
p.s. Writing the reflection code is not an issue. Selenium is covered as well. Just checking if this has already been done.
The AttributeRouting project has a route debugger in place, which does work even if you don't use attribute routing inside your project.
You can see the class that handles displaying the routes over on Github but I'm not sure it will display the routing information when the project isn't run locally. You may need to adapt that code so you can access it safely from your Selenium instance (and make it machine readable using JSON or something).

Asynchronous Javascript loading different behaviour

I am developing a widget, and am using extJS framework (along with stomp,orbited servers). It requires 5 different Javascript files. To avoid impacting load time for users, I am trying to load them asynchronously.
Through some callback stacks, I have managed to asynchronously load them in order they are required.
However, the widget does not work at all in the asynchronous case. I then copied the "modified" resultant HTML DOM from Chrome's developer tools, and created a static HTML file.
The static file works. I am printing few alerts when different JS files are loaded in both cases. The order of these alerts is the same.
How do I detect and fix the error. Stumped after lot of debugging.
(Link removed as they were on production server. Managed to detect the issue and find a workaround - please see answer below - keeping for anyone's reference).
The problem is that Ext.onReady is called as soon as document is ready, which is BEFORE any other scripts are loaded asynchronously.
Thus, the initialization code was not getting called. I manage to work it around by calling Ext.each("dummy args", initialization_function, this) in the last javascript that is loaded. This made things work for me.

using SquishIt with web resources

I'm using the SquishIt to manage the js/css files and it works perfect, but only with my manually created files. How can I use it with the asp.net webresources/script resources (scripts for ajax, validation etc.) which are returned to browser throught the script manager?
A method on bundles called .AddRootEmbeddedResource has been added to deal with situations like this (where an embedded resource does not use the default AssemblyName.ResourceName convention)

Resources