简体   繁体   中英

getMetaData() throws internal NullPointerException

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)

您可以在try / catch块中环绕getMetaData(),并且在catch块内部将其为空,而不是标准e.printStackTrace(),因为这对于实际应用程序的运行方式并不重要。

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM