调试 Cocoon 中的 NPE 的方法

huangapple go评论61阅读模式
英文:

Method for debugging a NPE in Cocoon

问题

我继承了一个基于Apache Cocoon的Java 1.7 web应用程序(部署在Tomcat上)。对于静态页面似乎可以工作,但对于动态页面,浏览器显示以下错误:

发生了错误

java.lang.NullPointerException:

Cocoon堆栈跟踪[隐藏]
java.lang.NullPointerException
context:/model-runs/sitemap.xmap - 284:46	<map:serialize type="html">
context:/model-runs/sitemap.xmap - 281:35	<map:transform type="i18n">
context:/model-runs/sitemap.xmap - 273:74	<map:transform type="xslt">
context:/model-runs/sitemap.xmap - 272:79	<map:transform type="xslt">
context:/model-runs/sitemap.xmap - 271:65	<map:generate type="serverpages">
context:/sitemap.xmap - 1162:63	<map:mount>

如何调试这个问题?我可以从Eclipse中运行项目,也可以在调试模式下运行,但我不知道在哪里“设置断点”。感谢任何指导!

英文:

I inherited a Java 1.7 webapp based on Apache Cocoon, which (deployed on Tomcat) seems to work for static pages, but for dynamic ones the browser shows me the following:

An error has occured

java.lang.NullPointerException:

Cocoon stacktrace
	
隐藏的内容
会员登录后查看
java.lang.NullPointerException context:/model-runs/sitemap.xmap - 284:46 &lt;map:serialize type=&quot;html&quot;&gt; context:/model-runs/sitemap.xmap - 281:35 &lt;map:transform type=&quot;i18n&quot;&gt; context:/model-runs/sitemap.xmap - 273:74 &lt;map:transform type=&quot;xslt&quot;&gt; context:/model-runs/sitemap.xmap - 272:79 &lt;map:transform type=&quot;xslt&quot;&gt; context:/model-runs/sitemap.xmap - 271:65 &lt;map:generate type=&quot;serverpages&quot;&gt; context:/sitemap.xmap - 1162:63 &lt;map:mount&gt;

How does one go about debugging this? I am able to run the project from within Eclipse, also in debug mode, but I don't know where to "set the breakpoint". Any pointers appreciated!

答案1

得分: 2

你得到的是一个 Cocoon 堆栈跟踪,而不是 Java 的堆栈跟踪。

这里标准的 Java 调试方法可能不太适用:
Cocoon 大部分是基于配置的框架,要找出这种错误的原因,很可能需要查看这些配置文件以及它们配置的处理管道。

如果我还记得的话,在这里,引发错误的管道阶段在顶部(相当标准)。您会得到一个指向引发错误的(XML)阶段描述(这里是 HTML 序列化)的行/列指针。

现在,空指针异常是由于找不到序列化程序,它没有按照其配置找到某些资源,它从之前的(i18n)阶段接收到 null,还是其他可能的原因引起的呢?

我会从研究 sitemap.xml 中的两个阶段(HTML 序列化程序,然后是 i18n)的配置开始,以获得我的第一个调试步骤检查清单。

英文:

What you got is a Cocoon stacktrace, not a Java one.

It is unlikely that the standard Java debugging approach would be what you need here :
Cocoon is much of a configuration-based framework, and finding out the cause of that kind of error will most certainly require you to get into those configuration files, and the pipelines of processing they configure.

If I can still remember, here, the pipeline stage that launched the error is on top (quite standard). You get a line/column pointer to the (XML) description of the stage (here html serialization) that raised the error.

Now, is the NPE caused by the serializer not being found, by it not finding some resource it requires as per its configuration, by it receiving null from the previous (i18n) stage, or who knows what other cause?

I would start by studying both stages (html serializers, then i18n) config in sitemap.xml to get my first debugging steps' check list.

huangapple
  • 本文由 发表于 2023年5月25日 05:39:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/76327581.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定