The problem:
Submitting a form and the number based fields (BigDecimal/Number/Integer etc) that had an empty string (null) on the form get populated with zero ("0") values.
The problem domain:
Tomcat/JBoss servers. I am running JBoss 5.1.0.GA.
The solution:
It appears the team at Tomcat didn't want us to be able to have nullable number fields in a JSF form! The solution is to set this java system variable: "org.apache.el.parser.COERCE_TO_ZERO=false", e.g.:
run.bat -Dorg.apache.el.parser.COERCE_TO_ZERO=false
This was a bit of a nightmare to track down, I tried writing and stepping through custom converters and thought I was going insane. Hopefully this helps someone out there.
P.S. I know I said this is a bug, but technically (crazily?) the spec does say to convert null's to 0's. See: http://tomcat.apache.org/tomcat-6.0-doc/config/systemprops.html.
Problems and solutions I have found working with Hibernate, Spring, Struts, Seam and JEE.
Showing posts with label Tomcat. Show all posts
Showing posts with label Tomcat. Show all posts
Friday, July 08, 2011
Tuesday, September 05, 2006
CSS and Images not loading
Alrighty, my first (hopefully) helpful blog :).I am using a hosting company for my webapp. They are using plain, good old Apache for hosting the static content such as images, css files and html pages. Requests are passed to Tomcat for processing any of the jsp files etc.
I noticed that the first time I went to my website after clearing the browser cache, the images and the CSS files were not being displayed or even found. This kept me up a few nights pulling my hair out, but I eventually noticed that when I disabled cookies the images and CSS NEVER got displayed!
The problem? After viewing the page source I noticed that without cookies enabled, the URLs included the session id in them, like so: "http://www.stroke-education.com/image/cart.gif;jsessionid=24A03F5B45814B192ABF9F7B1918B8AB.tomcat36". Of course Apache doesn't know how to deal with the jsessionid, it treats the whole thing as one URL, and it cannot find the file. The session id gets included the first time because tomcat isn't sure if cookies are enabled/disabled.
The solution? Tomcat has to get passed the requests that have jsessionid in the URL. My host company ended up forwarding all requests to Tomcat, which is overkill but it works.
A better solution is talked about here:
http://www.jguru.com/faq/view
They suggest adding the following to Apaches config:
<IfModule mod_rewrite.c>
RewriteEngine on
# Force URLs with a jsessionid to go to Tomcat. Necessary because
# Apache doesn't recognise that the semi-colon is special.
RewriteRule ^(/.*;jsessionid=.*)$ $1 [T=jserv-servlet]
</IfModule>
Subscribe to:
Posts (Atom)