3

I want to store static assets like css/js/fonts in the dxa-webapp instead of publishing it in Tridion.

I have seen one guide from Bart (DXA HTML design decisions) and also some topics here at StackExchange but no solution worked for us so far.

What i did:

  • Unpublished and deleted the Publish HTML Design Page
  • Created a version.json in /src/main/webapp/system/assets setting it to {"version":"v0.1"}
  • I put some test css/js in /src/main/webapp/system/assets/
  • Went into my page view jsp and added ${markup.versionedContent('/assets/wc/main.css')}
  • Rebuilt and re-deployed the web application
  • When opening a page, the asset path gets resolved correctly into /en/system/v0.1/assets/wc/main.css including the version i specified in version.json

The browser will return status 200 however the file size is always 0 byte:

enter image description here

It does not matter if i randomly change the file name, it will always resolve in status 200 - 0 byte.

I have tried out to use other locations to store assets beside of /system/assets/ like /content/styles/but this was without success, too.

I have set the log level to TRACE to have a better look whats happening but since i never used DXA before i am not seeing anything special.

Request:

RequestMappingHandlerMapping - Found 1 matching mapping(s) for [/en/system/v0.1/assets/wc/main.css] : [{[/**],methods=[],params=[],headers=[],consumes=[],produces=[text/html || /],custom=[]}]

Getting localization, why do we even need this for static files without relation to any publication:

WebRequestContextImpl - Localization for http://mvp.dxa.local:8080/en/system/v0.1/assets/wc/main.css/en/system/v0.1/assets/wc/main.css is: [1206] /en

Strange things happening here as my understanding was, that this BinaryData folder is for database exclusive assets:

AbstractDefaultContentProvider - getStaticContentFile: C:_dev\workspaces\gitroot\linde-dxa-web-application-java\dxa-webapp\target\webapp-dxa\BinaryData\1206\en\system\assets\wc\main.css

Wait, why is there a publishing event?

AnnotationConfigWebApplicationContext - Publishing event in Root WebApplicationContext: ServletRequestHandledEvent: url=[/en/system/v0.1/assets/wc/main.css]; client=[127.0.0.1]; method=[GET]; servlet=[org.springframework.web.servlet.DispatcherServlet]; session=[DDED4DC30E12989DBD487107CFEF2E01]; user=[null]; time=[296ms]; status=[OK]

Finished request:

BasicEndpointCaller - Request ended with 201 status code.

I am really out of ideas currently. I was hoping that static assets in DXA work out of the box without the need to install and configure an apache webserver for local development.

Thank you for your help!

1 Answer 1

2

The article was written a long time ago and focussed only on DXA .NET, for Java we have a slightly different process, as documented here: http://docs.sdl.com/LiveContent/content/en-US/SDL%20DXA-v7/GUID-14174367-EFDB-4C6C-B53D-1E7AB39E78C3 (so it is a bit strange that you say it works with a version.json file).

Another thing I'm wondering about is if you taken into account that static assets are still part of a Localization/Publication (there is a separate HTML design for every Publication/Localization).

But in general (I've been looking at the .NET implementation), we might have broken support for this without noticing during some refactoring. As the code for identifying that the HTML design is not published is there, but I didn't see anything for handling the files anymore. It seems you will need to add some routes yourself for that.

5
  • Yes it is working with version.json but now i have changed it according to your provided link. I added the line dxa.assets.version=v0.1 into dxa.properties. This will result in the same output than before. /en/system/v0.1/assets/wc/main.css - 0 Byte.
    – S. Gabriel
    Jun 14, 2017 at 13:49
  • Reading your updated comment regarding the broken support due to refactor issues, our team will now implement our own solution into our custom module.
    – S. Gabriel
    Jun 14, 2017 at 14:33
  • 1
    @Bart - is there a hotfix for this? Sounds like a big issue as a large proportion of implementations have the HTML design managed in the web app and not the CMS
    – Will Price
    Aug 8, 2017 at 13:30
  • 1
    @WillPrice nope unfortunately there is no fix for that yet Aug 8, 2017 at 13:45
  • 1
    I raised an issue: github.com/sdl/dxa-web-application-java/issues/75 and will look into a fix, any pointers appreciated
    – Will Price
    Aug 9, 2017 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.