Skip to main content
added 400 characters in body
Source Link
Rick Pannekoek
  • 21.4k
  • 1
  • 18
  • 30
  • The CM Publication is not published to CD yet. In particular: this kind of Configuration data (stored as Binaries in CD) is published by the "Publish Settings" Page.
  • Actually, if the Binary was not published at all, we wouldn't have gotten this far in the code, because then there would not even have been metadata about the binary (see line 92 and earlier in the source code: before trying to retrieve the Binary data, some metadata about the binary is retrieved first).
  • The CD Deployer is configured to store Binaries on file system instead of in the CD Content Store (database).
  • This seems to be the most plausible explanation of how such an exception can occur.
  • The CM Publication is not published to CD yet. In particular: this kind of Configuration data (stored as Binaries in CD) is published by the "Publish Settings" Page.
  • The CD Deployer is configured to store Binaries on file system instead of in the CD Content Store (database).
  • The CM Publication is not published to CD yet. In particular: this kind of Configuration data (stored as Binaries in CD) is published by the "Publish Settings" Page.
  • Actually, if the Binary was not published at all, we wouldn't have gotten this far in the code, because then there would not even have been metadata about the binary (see line 92 and earlier in the source code: before trying to retrieve the Binary data, some metadata about the binary is retrieved first).
  • The CD Deployer is configured to store Binaries on file system instead of in the CD Content Store (database).
  • This seems to be the most plausible explanation of how such an exception can occur.
Source Link
Rick Pannekoek
  • 21.4k
  • 1
  • 18
  • 30

Let me explain how to interpret such a Stack Trace:

  • The exception is a NullPointerException, meaning that the code tried to dereference a pointer which is null. This generally means the code is not robust enough: it did not expect that a pointer could get a null value, but it did.
  • The first line in the Stack Trace reveals where this exception occurred: in method DefaultContentProvider.getStaticContentFile, defined in source file DefaultContentProvider.java at line 95.
  • The class is deployed as part of JAR dxa-web8-provider-1.8.0.jar (which reveals both the version of DXA and the name of the project)
  • Subsequent lines give information about the context of where the exception occurred.
  • Interesting lines are LocalizationFactoryImpl.loadMainConfiguration and LocalizationFactoryImpl.createLocalization.
  • So, apparently, the exception occured when trying to load a "main configuration" as part of creating a "Localization". Indeed, DXA loads configuration data (stored in the CD Content Store and cached on file system) when a new Localization is initialized.
  • If we got this far, apparently the Localization has already been resolved. So, there does not seem to be an issue with Topology Manager and/or Discovery Service. The problem lies in loading the configuration data.
  • Now let's go back to that first line and find the source code to get a better idea of what happened.
  • Since we're talking about a problem in the DXA Java Web Application (Framework), the source code can be found here: https://github.com/sdl/dxa-web-application-java
  • Since the DXA version is 1.8.0, we should be using the release/1.8 branch.
  • Since the artifact was dxa-web8-provider-1.8.0.jar, we should look into dxa-web8-provider
  • The fully qualified name of the class is com.sdl.webapp.tridion.mapping.DefaultContentProvider. This helps us to navigate to the class in GitHub: https://github.com/sdl/dxa-web-application-java/blob/release/1.8/dxa-framework/dxa-web8-provider/src/main/java/com/sdl/webapp/tridion/mapping/DefaultContentProvider.java
  • Now, let's see what's at line 95: writeToFile(file, pathInfo, binaryData.getBytes());
  • OK, so it's trying to write binary data to a file. There is only one thing on this line that can cause a NullPointerException: binaryData.getBytes(). That is: if binaryData is null, you will get a NullPointerException.
  • So, how did binaryData get null? We have to look at preceding lines to see how binaryData got set. At line 92 we find: BinaryData binaryData = binaryContentRetriever.getBinary(publicationId, itemId, binaryMeta.getVariantId());
  • Altogether, we now have a pretty good picture:
  • As part of Localization intialization, some configuration data is loaded in the form of a Binary in the CD Content Store, which then gets written/cached to file system.
  • However, it seems the Binary cannot be retrieved from CD Content Store and the CD API returns a null pointer.
  • The DXA code does not expect this null pointer and this results in a NullPointerException.

Question remains: why can that Binary not be found in the CD Content Store? Typical reasons for this are:

  • The CM Publication is not published to CD yet. In particular: this kind of Configuration data (stored as Binaries in CD) is published by the "Publish Settings" Page.
  • The CD Deployer is configured to store Binaries on file system instead of in the CD Content Store (database).