8

Calling getMetaData() on a component in ColdFusion 10 seems to randomly throw an internal NullPointerException. While this exception is neither exposed nor affects the actual request (and thus is not critical to our applications itself), it still fills up the exception.log files rapidly.

I noticed this might be related to the path caching of ColdFusion since I get these NullPointerException entries on the production server only. I also noticed that this exception is only thrown once per component where I use getMetaData() on, although not every first call seems to trigger it.

For clarification: getMetaData() works perfectly well, but it sometimes logs a NullPointerException in ColdFusion's exception.log file.

Does anyone know a solution (other than disabling the caching or the exception.log file)?

Background: I use getMetaData() to identify components, especially useful when using <cfinterface>.

java.lang.NullPointerException
    at coldfusion.util.Utils.getServletPath(Utils.java:100)
    at coldfusion.util.Utils.getServletPath(Utils.java:90)
    at coldfusion.util.Utils.getBaseTemplatePath(Utils.java:419)
    at coldfusion.runtime.TemplateProxyFactory.getTemplateFileHelper(TemplateProxyFactory.java:1567)
    at coldfusion.runtime.MetadataUtils.getComponentMetadata(MetadataUtils.java:112)
    at coldfusion.runtime.CfJspPage.GetComponentMetadata(CfJspPage.java:2744)
    at coldfusion.runtime.TemplateProxy.getRuntimeComponentMetadata(TemplateProxy.java:1940)
    at coldfusion.runtime.TemplateProxy.getRuntimeMetadata(TemplateProxy.java:1801)
    at coldfusion.runtime.MetadataUtils.getMetaData(MetadataUtils.java:54)
    at coldfusion.runtime.CfJspPage.GetMetadata(CfJspPage.java:2717)
Alex
  • 7,743
  • 1
  • 18
  • 38
  • Since CF is closed source, it's going to be hard to get an answer for why that happens from anyone other than the CF engineering team. I would submit a bug report here: https://bugbase.adobe.com/. In the mean time, can you use IsInstanceOf() to identify a component's type? https://wikidocs.adobe.com/wiki/display/coldfusionen/IsInstanceOf – Brad Wood Jun 18 '14 at 18:20
  • Unfortunately isInstanceOf() requires fully qualified paths. Since I use dynamic mappings on different server environments, I do not know the exact path. Reflection through getMetaData() seemed to be the best way to do it. Well, it wasn't I guess. – Alex Jun 18 '14 at 19:12
  • 1
    Unless you're seeing a specific performance issue with the errors being thrown I would stick with what you have. In your case, it may be the best solution. The extra logging is probably just a bug Adobe needs to fix. If the logging in question uses Log4J, you may be able to find the properties files and turn off logging for that package. Log4J is a common Java logging library. http://stackoverflow.com/questions/4972954/how-to-disable-loggers-of-a-class-or-of-whole-package – Brad Wood Jun 18 '14 at 21:01
  • I believe this issue is resolved in Coldfusion 10 Update 16. Details can be found on Adobe's website: https://helpx.adobe.com/coldfusion/kb/bugs-fixed-in-coldfusion-10-update-16.html – Will Zablocki Dec 16 '16 at 17:14
  • Nope, that bugfix is ORM related. The bug still occurs in CF10, I don't know about CF11+ though. We moved the code mentioned in the bug report to the `onRequestStart` event instead of `onSessionStart` event and that solved the problem in our particular case. – Alex Dec 16 '16 at 17:53
  • This bug is still present in CF11. And it was already there in CF9, as can be seen in https://stackoverflow.com/q/5706608/438970 . – Damien May 21 '18 at 19:20

3 Answers3

0

You could sourround getMetaData() in a try/catch block, and inside of the catch block have it empty, instead of the standard e.printStackTrace(), since it isn't critical to how the actual application runs.

  • 1
    The internal exception - as stated in my post - does not throw an exception event that can be caught in a catch. – Alex Aug 01 '14 at 22:32
0

How often are your components changing? Is there any way to compare the times the files were modified against the time the exception was thrown? I'm with you on the possibility of the caching causing this.

Out of curiosity, if you're able, before your getMetaData() call, could you explicitly NULL the servlet path?

getPageContext().getRequest().setAttribute("javax.servlet.include.servlet_path", javaCast("null", ""));

That may help meet the NULL condition there which would then resort to calling request.getServletPath() and possibly solve the path issues.

I have checked my logs and haven't found such error, but it's likely my calls to getMetaData() aren't as frequent as yours.

Tristan Lee
  • 1,210
  • 10
  • 17
0

It seems to be related to a rare race condition between request (w/o session identifier) and the session initialization as the getMetaData() throws the exception when using on any element in the SESSION scope, so it does not even depend on a custom component but rather coldfusion.runtime.SessionScope.

Unfortunately it is very difficult to reproduct this issue. Sometimes it happens but then it does not for hours or even days. I filed a report at Adobe's bugbase, but they cannot look into this unless I can tell the steps to reproduce.

Alex
  • 7,743
  • 1
  • 18
  • 38