Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JForum and the fly likes java.io.EOFException JForum 1.5 mysql connection timeout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Products » JForum
Bookmark "java.io.EOFException JForum 1.5 mysql connection timeout" Watch "java.io.EOFException JForum 1.5 mysql connection timeout" New topic
Author

java.io.EOFException JForum 1.5 mysql connection timeout

Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
If I had to take a guess, that stack trace looks like your DB connection pool is returning a connection that has timed out, and it no longer communicating with the mysql server. Does your pooling software have any concept of "keeping connection open" with some periodic sql query? Do it have some concept of validating the connection before handing it to you.

Also note, that the mysql jdbc driver also has some code to ensure that the connection remains open. You should look into those settings to see if that solves the problem.
[originally posted on jforum.net by time]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Well that's the thing. My connection for the main context has these settings, see below.

Is there a way to pass these via jforum in the system globals or the custom config?

<Resource name="jdbc/mydb" <br /> auth="Container" <br /> type="javax.sql.DataSource" <br /> removeAbandoned="true" <br /> logAbandoned="true" <br /> maxActive="50" <br /> maxIdle="20" <br /> maxWait="3000" <br /> username="xxxx" <br /> password="xxxx" <br /> driverClassName="com.mysql.jdbc.Driver" <br /> url="jdbc:mysql://localhost/db" <br /> validationQuery="select 1 from dual" <br /> />

[originally posted on jforum.net by Anonymous]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
It seems that if JForum sits idle for a while I'll eventually get this exception:

java.io.EOFException
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1903)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2349)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2860)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1666)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2978)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2902)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:933)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1027)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
at net.jforum.dao.generic.GenericUserSessionDAO.selectById(GenericUserSessionDAO.java:110)
at net.jforum.dao.generic.GenericUserSessionDAO.update(GenericUserSessionDAO.java:87)
at net.jforum.SessionFacade.storeSessionData(SessionFacade.java:413)
at net.jforum.SessionFacade.storeSessionData(SessionFacade.java:384)
at net.jforum.ForumSessionListener.sessionDestroyed(ForumSessionListener.java:81)
at org.apache.catalina.session.StandardSession.expire(StandardSession.java:685)
at org.apache.catalina.session.StandardSession.isValid(StandardSession.java:577)
at org.apache.catalina.session.ManagerBase.processExpires(ManagerBase.java:678)
at org.apache.catalina.session.ManagerBase.backgroundProcess(ManagerBase.java:663)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1283)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1568)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1577)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1577)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1557)
at java.lang.Thread.run(Thread.java:595)



I'm using MYSql 5 and below are the relavant settings from jforum-custom.conf

database.support.subqueries=false
database.connection.pool.timeout=5000
database.connection.driver=com.mysql.jdbc.Driver
database.connection.port=3306
database.connection.pool.max=10
database.support.autokeys=true
database.connection.dbname=jforum
database.connection.host=localhost
database.connection.string=jdbc\:mysql\://${database.connection.host}\
:${database.connection.port}/${database.connection.dbname}?user\
=${database.connection.username}&password\=
${database.connection.password}&autoReconnect\=
true${mysql.unicode}${mysql.encoding}&useNewIO\=
false&zeroDateTimeBehavior\=convertToNull&useServerPrepStmts\=
false
database.connection.pool.min=5
database.connection.password=xxxxxxx
database.connection.username=xxxxxxxxx

Now I do have a Datasource set in the main context but while I struggle to figure out how to share that I'd like to fix this.

I've not written any of my own jdbc code in the sso stuff either. So it's not an open connection or something like that which I've not returned to the pool.

[originally posted on jforum.net by conquest]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
I'll provide a better documentation for that, but, until there, take a look int he C3P0 documentation:

http://sourceforge.net/projects/c3p0

There you'll find properties to fix these problems

Rafael
[originally posted on jforum.net by Rafael Steil]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Ok ... all I did was add a pooled connection in my META-INF/context.xml. I also had to copy this to the conf/Catalina/localhost/myforum.xml becuase for some reason tomcat wasn't auto deplying this.


<Context path="/forums" debug="5" reloadable="true">
<Resource name="jdbc/mydb" <br /> auth="Container" <br /> type="javax.sql.DataSource" <br /> removeAbandoned="true" <br /> logAbandoned="true" <br /> maxActive="50" <br /> maxIdle="20" <br /> maxWait="3000" <br /> username="xxxxxx" <br /> password="xxxxxx" <br /> driverClassName="com.mysql.jdbc.Driver" <br /> url="jdbc:mysql://myhost/mydb" <br /> validationQuery="select 1 from dual" <br /> />
</Context>

[originally posted on jforum.net by conquest]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.io.EOFException JForum 1.5 mysql connection timeout