1

Its kind of a strange scenario, and what I am asking for is if anybody has experienced similar things in past and any hints for possible cases

the application I am working on is used across varied environments. we generally use Tomcat for development and one of our integration environment is Websphere.

Now a statement like

BillingPaymentAssembler.java:149

finActivity.setReferenceNo(paymentDetail.getTicketNumber());

where ticketNumber is String, would run fine on Tomcat during unit testing. But when deployed on websphere would throw a nullPointerException for the same test case.

UPDATE #1

we are using JSF2 on UI, paymentDetail is the Bean.

ticket number is a field on UI corresponding to ticketNumber of bean.

the case, when I do not enter anything on UI for ticket number, leaving it blank. In that case the I get the exception

UPDATE #2

[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R java.lang.NullPointerException
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.csc.csa.assembler.BillingPaymentAssembler.disassemble(BillingPaymentAssembler.java:149)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.csc.fs.accel.AccelTransformation.disassemble(AccelTransformation.java:79)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at java.lang.reflect.Method.invoke(Method.java:600)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.csc.fs.ServiceHandler.invoke(ServiceHandler.java:59)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.csc.fs.accel.AccelService.callService(AccelService.java:1087)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.csc.csa.process.BillingPaymentBP.process(BillingPaymentBP.java:29)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.csc.fs.accel.AccelBP.process(AccelBP.java:62)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at java.lang.reflect.Method.invoke(Method.java:600)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.csc.fs.service.ServiceControllerBP.process(ServiceControllerBP.java:54)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.csc.fs.service.ServiceControllerAbstract.internalExecute(ServiceControllerAbstract.java:278)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.csc.fs.service.ServiceControllerAbstract.execute(ServiceControllerAbstract.java:197)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.csc.fs.delegate.DirectServiceController.execute(DirectServiceController.java:61)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.csc.fs.delegate.ServiceDelegateDirect.execute(ServiceDelegateDirect.java:70)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.csc.fs.accel.ui.BaseServiceAction.execute(BaseServiceAction.java:584)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.csc.fs.accel.ui.action.policy.services.MaintainBillingPayment.perform(MaintainBillingPayment.java:145)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.csc.fs.accel.ui.BaseServiceAction.perform(BaseServiceAction.java:618)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.csc.fs.accel.ui.ServiceDelegator.execute(ServiceDelegator.java:506)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.csc.fs.accel.ui.ServiceDelegator.processEvent(ServiceDelegator.java:240)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.csc.fs.accel.ui.BeanBase.executeEvent(BeanBase.java:779)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at pagecode.policy.file.Billing.executeBillingPayments(Billing.java:498)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at java.lang.reflect.Method.invoke(Method.java:600)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at org.apache.el.parser.AstValue.invoke(AstValue.java:131)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:67)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at javax.faces.component.UICommand.broadcast(UICommand.java:315)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:775)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1267)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1655)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1595)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:131)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.csc.fs.accel.ui.filters.ResponseHeaderFilter.doFilter(ResponseHeaderFilter.java:82)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:188)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:116)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:77)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:895)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:932)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:500)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:864)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:183)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
[1/16/13 5:25:02:750 EST] 00000019 SystemErr     R  at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550)
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Mukul Goel
  • 8,387
  • 6
  • 37
  • 77
  • Well which is null - `finActivity` or `paymentDetail`? You should be able to add diagnostics to work that out pretty easily. – Jon Skeet Jan 16 '13 at 11:10
  • @JonSkeet : The `ticketNumber` field is null – Mukul Goel Jan 16 '13 at 11:12
  • Okay, so where are you fetching `paymentDetail` from? Fundamentally the problem isn't a `NullPointerException` - it's the fact that you've got a null reference. You haven't given us *any* information about where the reference is coming from, which makes the question impossible to answer in its current form. – Jon Skeet Jan 16 '13 at 11:14
  • @JonSkeet : Yea I know there is not much information with the question. honestly I am not much clear on what all information would go into this for someone to help me. Please refer to UPDATE #1 for added info – Mukul Goel Jan 16 '13 at 11:17
  • The update doesn't help at all - you still haven't explained where `paymentDetail` actually *comes from*. The ticket number part is a complete red herring - it's not the ticket number which is the problem, it's that you have no `paymentDetail` reference *at all*. – Jon Skeet Jan 16 '13 at 11:24
  • @JonSkeet : No I do have a `paymentDetail` reference. the statement that I showed that is the statement where exception is thrown, inside the function(where that statement is from) there are like 20 more statements that are fetching data from `paymentDetail` to `finActivity`. _where `paymentDetail` comes from?_ its the reference to object of the bean. when user inputs the value on UI form and selects `OK`, the values of input fields are mapped to variables in bean (JSF). the `paymentDetail` is a reference to the object of bean that carries the input values. – Mukul Goel Jan 16 '13 at 11:28
  • Ah - I misread your earlier comment. Okay, if `paymentDetail` and `finActivity` are non-null, then *that statement* doesn't directly throw the exception. Maybe `setReferenceNo` does, but that statement itself won't. Posting the full stack trace would help, although I still think this question needs a lot more work before anyone's really going to be able to help you. – Jon Skeet Jan 16 '13 at 11:37
  • @JonSkeet : Yea, I think too that it would take more info added, I would try to put in any more relevant info I can think of and provide constant feedback on comments from other users.. please refer to update #2 for stack trace. – Mukul Goel Jan 16 '13 at 11:45
  • 1
    In future JavaEE questions, don't use `[java]` tag. There are too many naive users out there who would only downvote out of sheer ignorance on the subjects. Your question didn't deserve a downvote. – BalusC Jan 16 '13 at 12:09
  • @BalusC : Thanks :-) , I would not use the `java` tag in future in similar cases. I was not myself clear where this question would fit so tagged both :) – Mukul Goel Jan 16 '13 at 12:15

1 Answers1

2

I assume that ticketNumber is an instance of Number (Integer, Long, Double, etc). Normally, when a primitive type is used (int, long, double, etc), EL will automatically coerce empty string submitted values to primitive's default which is 0 or 0.0. In case of a wrapper object type, there are differences in EL parsers because the EL specification isn't crystal clear about that and/or because coercing to null makes so much more sense for an empty string submitted value on a non-primitive type.

Tomcat, which comes with Apache EL parser, will coerce empty string submitted values on Number type to the default value of the primitive representation. So an empty submitted value on an Integer type will be set as 0 instead of null. Apparently you assumed this to be "correct" behavior and your code was also written as such to intercept on that.

However, other servers, such as WebSphere in this apparent case, will coerce them to null instead of the default value of the primitive representation, causing the NPE.

Basically, the bug is in your code. You should be taking null values into account, or be using int instead of Integer if 0 is a valid representation of "no value" (which depends on your business requirements). To get all servers to behave the same, you should basically also instruct Tomcat to not coerce empty string submitted values on Number to 0. You can do that by adding the following VM argument to Tomcat startup script:

-Dorg.apache.el.parser.COERCE_TO_ZERO=false

Note that this problem is in essence unrelated to JSF. It just happens to use EL.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Hey thanks for the info, Yes I was looking for a reason for diference in behavior, I know the problem is with my code. I will add the null checks and all. But it sometimes get difficult to point out the error code when it runs fine during development. Also, in this case `ticketNumber` is `String`. But yes as you point out this problem generally occurs, in my case on `BigDecimal`. – Mukul Goel Jan 16 '13 at 12:11
  • You're welcome. In case of strings, there's also a setting to interpret empty string submitted values as `null` instead of keeping them an empty string. See also http://stackoverflow.com/questions/8939264/dorg-apache-el-parser-coerce-to-zero-for-glassfish – BalusC Jan 16 '13 at 12:20
  • Are you talking about the `javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL` context param? – Mukul Goel Jan 16 '13 at 12:22