解决JSP空指针异常问题
我正在查看一个非常旧的项目,并试图解决该项目面临的一些与其 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
上次我遇到这个问题时,当我查找中间文件时,它已经消失了。为了解决这个问题,我所做的就是在 JSP 中故意引入编译器错误,然后再次运行它。当遇到该异常时,它会保存 Servlet 源代码,以便您可以更正代码错误。
我只是倾向于走到底部并输入:
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:
尝试在 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)
您可以在相关服务器的工作目录中找到编译后的 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.