Tuesday, April 27, 2010

JSF Page not submit issue

While using JSF developers may come across problem while submitting the page. Page may not be getting submitted. Following are finding for JSF not submission

1. Component in the jsf page may be seting as null. Check which component is null and fix it. Always initialize the variable in JSF backing bean.

2. Dropdown index value (SelectItem id) should be string and not integer!! So always while setting the List key value make sure it is string.

eg:
//Valid
int i = 0;
SelectItem item = new SelectItem(i+"", rvStatus.getDescription());


//Not Valid
int i = 0;
SelectItem item = new SelectItem(i, rvStatus.getDescription());

3. Rare cases - while displaying the multiple panel based on the render true or false in jsp may leads to break in submiting the button. This can be fixed by handling the render logic in backing bean by binding the panel.


There could be some more reason behind these please share it in the comment. Thanks

Friday, April 2, 2010

Solution for Connectionpool Timeout Exception

Exception: Cannot get a connection, pool error Timeout

Timeout error will be raised when the DB connection is unavailable from the pool due to the reason of not properly closed connection. So in web application connection need to be closed explicitly. Also following configuration in resource (Context.xml) changes will fix the issue also helps in debugging the code.

To configure a DBCP DataSource so that abandoned dB connections are removed and recycled add the following attribute to the Resource configuration for your DBCP DataSource:
            removeAbandoned="true"

When available db connections run low DBCP will recover and recycle any abandoned dB connections it finds. The default is false.
Use the removeAbandonedTimeout attribute to set the number of seconds a dB connection has been idle before it is considered abandoned.
            removeAbandonedTimeout="60"

The default timeout for removing abandoned connections is 300 seconds.
The logAbandoned attribute can be set to true if you want DBCP to log a stack trace of the code which abandoned the dB connection resources.
            logAbandoned="true"
The default is false.

Reference:
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html