The Answer to Life, the Universe, and Everything

Wednesday, January 21, 2009

Struts2: <img src="${url}"/>

In case of specifying the url for the image in struts2, you can write as follows.


<s:iterator value="books" status="rowstatus">
<s:url id="url" value="%{bookImagePath[#rowstatus.index]}"/>
<img src="${url}" alt="Book image" align="top"/>
</iterator>

Thursday, January 08, 2009

ERROR JDBCExceptionReporter - Duplicate entry

By using mysql, I faced the followin error and here is the solution
2009-01-08 22:55:18,454  WARN JDBCExceptionReporter - SQL Error: 1062, SQLState: 23000
2009-01-08 22:55:18,454 ERROR JDBCExceptionReporter - Duplicate entry '268731' for key 1
2009-01-08 22:55:18,454 ERROR AbstractFlushingEventListener - Could not synchronize database state with sessi
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update


Close the session after transaction.commit().
transaction.commit();
session.flush();
session.close();

Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost

I faced the following error and here is the solution.
  ** BEGIN NESTED EXCEPTION **

java.io.EOFException
MESSAGE: Can not read response from server. Expected to read 4 bytes, read 2
bytes before connection was unexpectedly lost.

STACKTRACE:

java.io.EOFException: Can not read response from server. Expected to read 4
bytes, read 2 bytes before connection was unexpectedly lost.


Comment the wait_timeout such as below.
#wait_timeout=30

Tuesday, January 06, 2009

SocketException: Too many open files

If you see the following error,
java.net.SocketException: Too many open files


Try to change the max open file value for the user

#check current value by calling
ulimit -a
#Set new max open file
ulimit -n 102400

as well as the OS

#Check current value
cat /proc/sys/fs/file-max
#Set the new max open file by adding the following
vi /etc/sysctl.conf
--
fs.file-max = 49500
--