解决JSP空指针异常问题

发布于 2024-08-20 07:00:04 字数 448 浏览 3 评论 0原文

我正在查看一个非常旧的项目,并试图解决该项目面临的一些与其 JSP 页面抛出空指针异常相关的问题。 JSP 页面抛出空指针异常,如下例所示。

/e2fo/tools/user/search/searchUser.jsp. Exception thrown : java.lang.NullPointerException
    at com.ibm._jsp._searchUser_5F_TA._jspService(_searchUser_5F.java:207)

现在这个问题是不可重现的,所以只需查看上面的异常,我就需要找出问题所在。 据我了解,JSP 页面被编译成 java servlet,因此异常堆栈中显示的 .java 文件是 servlet 文件。这是一个中间文件,我们看不到它,我正在运行 websphere 6.1。在这种情况下,如何确定或映射 servlet 到 JSP 文件的行号?

I am looking at a very old project and trying to fix some problems that this project is facing with related to its JSP pages throwing nullpointer exception.
The JSP page is throwing a null pointer exception like the sample below.

/e2fo/tools/user/search/searchUser.jsp. Exception thrown : java.lang.NullPointerException
    at com.ibm._jsp._searchUser_5F_TA._jspService(_searchUser_5F.java:207)

Now this problem is not reproducible, so just by looking at the exception above I need to figure put where could be the problem.
As I understand, JSP pages get compiled into java servlets and so the .java file displayed in the exception stack is the servlet file. This is an intermediate file and we do not get to see this, I am running websphere 6.1. In this case, How to determine or rather map the line number from the servlet to the JSP file ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我很OK 2024-08-27 07:00:04

上次我遇到这个问题时,当我查找中间文件时,它已经消失了。为了解决这个问题,我所做的就是在 JSP 中故意引入编译器错误,然后再次运行它。当遇到该异常时,它会保存 Servlet 源代码,以便您可以更正代码错误。

我只是倾向于走到底部并输入:

<% novariable.toString(); %>

The last time I ran into this, the intermediate file was gone by the time I looked for it. What I did to get around it was to introduce an intentional compiler error into the JSP and run it again. When it hits that exception, it saves the Servlet source so that you can correct the code error.

I just tended to go to the bottom and put:

<% novariable.toString(); %>
飘过的浮云 2024-08-27 07:00:04

尝试在 JSP 引擎配置中使用 classdebuginfo 参数。

如果您想尝试查看生成的 .java 文件,则需要使用 keep generated 参数。

要了解在何处设置此参数,请参阅配置 JSP 引擎参数 (http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com。 ibm.websphere.nd.multiplatform.doc/info/ae/ae/tweb_jspengine.html

参考:http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1 /index.jsp?topic=/com.ibm.websphere.nd.doc/info/ae/ae/rweb_jspengine.html

此链接可能会有所帮助:在服务器上调试 JSP 文件 (http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.base.iseries.doc/info/welcome_base.html

Try using classdebuginfo parameter in the JSP engine configuration.

If you want to try looking at the generated .java file, you will need to use keepgenerated parameter.

To know where to set this parameters, see Configuring JSP Engine Parameters (http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.nd.multiplatform.doc/info/ae/ae/tweb_jspengine.html)

Reference: http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.nd.doc/info/ae/ae/rweb_jspengine.html

May be this link could help: Debugging a JSP file on a server (http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.base.iseries.doc/info/welcome_base.html)

还在原地等你 2024-08-27 07:00:04

您可以在相关服务器的工作目录中找到编译后的 JSP 文件。我(不再)使用 Websphere,但我知道它是构建在 Tomcat 之上的,并且 Tomcat 默认将编译后的 JSP 文件存储在安装目录的 /work 文件夹中。看一下,也许它使用相同的文件夹名称。

如果仍然无效,则对 Websphere 根文件夹内的文件名 _searchUser_5F.java 匹配的文件进行基于平台的文件搜索。

You can find the compiled JSP files in the work directory of the server in question. I don't do Websphere (anymore) but I know that it's built on top of Tomcat and that Tomcat by default stores the compiled JSP files in /work folder of the installation directory. Give it a look, maybe it uses the same foldername.

If still in vain, then do a platform based file search on files matching filename _searchUser_5F.java inside the root folder of Websphere.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文