WebSphere相等检查失败

时间:2013-08-07 06:19:59

标签: java servlets jpa websphere equality

WebSphere打印

8/7/13 11:43:47.318 000000AB SystemOut详情收据为空? = null

8/7/13 11:43:47.318 000000AB SystemOut DETAIL false

8/7/13 11:43:47.318 000000AB com.ibm.ws.webcontainer.servlet.ServletWrapper SEVERE com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0068E:其中一种服务方法引发了异常应用程序[MyWar_war]中的servlet [ReceiptReportServlet]。创建异常:[java.lang.NullPointerException     在servlet.ReceiptReportServlet.doGet(ReceiptReportServlet.java:61)     在javax.servlet.http.HttpServlet.service(HttpServlet.java:575)     在javax.servlet.http.HttpServlet.service(HttpServlet.java:668)     在com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1227)     在com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:776)     在com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:458)     在com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)     在com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1032)     在com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:87)     在com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:909)     在com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)     在com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200)     在com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:459)     在com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:526)     在com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:312)     at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:283)     at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)     在com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)     在com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)     在com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)     at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)     在com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)     在com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)     在com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)     在com.ibm.io.async.ResultHandler $ 2.run(ResultHandler.java:905)     在com.ibm.ws.util.ThreadPool $ Worker.run(ThreadPool.java:1862) ]

而不是

收据是否为空? = null

1 个答案:

答案 0 :(得分:4)

这看起来更像是操作顺序而不是WAS的问题。您打印的行

System.out.println("receipt is null? " + receipt == null);

是问题所在。如果收据对象为空,则不会打印true或false。它的作用是将字符串"receipt is null? "与收据的.toString()方法的结果连接起来,然后检查它是否等于null。这就是为什么你看到它只在那条线上打印错误。

如果你真的想在那里检查一个空对象,可以在你的空检查周围添加一些适当的()。

System.out.println("receipt is null? " + (receipt == null));

这应该按照您的预期打印为真或假。

至于为什么收据在一个环境中为空但在另一个环境中不为空的问题是我们没有足够的信息来回答。您的代码段不会向我们显示该对象的来源或实例化。