0

I'm having problems deploying Spring/Java 1.5/Tomcat 6 webapp on CentOS. It breaks during JSP execution on one specific form which uses BigDecimals; it seems that somewhere in the bowels of Tomcat JSPs BigDecimal is being initialized with new BigDecimal(""); - why there is empty string sent to JSP I can't figure out. This is not anywhere in app code, it's during JSP compilation/execution.

Here's the exception it's been throwing at me:

SEVERE: Servlet.service() for servlet dispatcher threw exception
java.lang.NumberFormatException
    at java.math.BigDecimal.<init>(BigDecimal.java:457)
    at java.math.BigDecimal.<init>(BigDecimal.java:647)
    at org.apache.el.lang.ELArithmetic$BigDecimalDelegate.coerce(ELArithmetic.java:48)
    at org.apache.el.lang.ELArithmetic.coerce(ELArithmetic.java:357)
    at org.apache.el.lang.ELArithmetic.add(ELArithmetic.java:236)
    at org.apache.el.parser.AstPlus.getValue(AstPlus.java:40)
    at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
    at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:935)
    ...

When I run this webapp on Windows, either in Eclipse or directly in Tomcat 6, it runs with no problems whatsoever. I'm kind of stuck and any general direction at where to look would be appreciated.

One thing I've been thinking is that somehow something is wrong with Tomcat sessions, so that JSP gets blank session and then breaks when it's not able to instantiate variables... but there's not really much to configure on Tomcat regarding sessions, and it's basically a blank Tomcat installation and sessions should work by default.

Domchi
  • 10,705
  • 6
  • 54
  • 64
  • maybe related to this? http://stackoverflow.com/questions/5225013/coerce-to-zero-at-runtime – Leo Jun 22 '14 at 15:27
  • Don't assume the error comes from Tomcat. Assume it comes from your code. You have an arithmetic expression somewhere in the JSP like ${a + b}, and one of the operands is not a valid number. Try to identify what this expression is by removing portions of the JSP and reproducing the bug. Then fix the issue. – JB Nizet Jun 22 '14 at 15:28
  • @Leo - nice find! But I don't think it's the same thing as according to that question it should break on Tomcat 6.0.17 and newer, and it's running correctly for me on newer tomcat on my Windows laptop. – Domchi Jun 22 '14 at 15:40
  • @JBNizet - I actually know which line is causing it, but I don't get why one of the values is not valid, and why would this work on one Tomcat installation and fail on another. One of the values does come from Tomcat session, so this is something to explore though... – Domchi Jun 22 '14 at 15:48
  • And why don't you share this line with us? Do you think letting us in the complete dark will help us find where the problem is? – JB Nizet Jun 22 '14 at 17:20
  • The thing is that it's a perfectly ordinary line, just like any other line, which multiplies two values. In the end what worked was replacing ${a * b} with ${b * a} on one place, and on another place there was if ${empty param} I managed to get rid of completely by rewriting it in another way. Why that worked I really don't know... and why it didn't work on particular Tomcat installation while on the other it worked OK. I'm suspecting that it was due to some slight incompatibility in EL versions on different Tomcat versions, but although I solved my problem I still don't know the cause. – Domchi Jul 04 '14 at 20:34

0 Answers0