Announcement Announcement Module
Collapse
No announcement yet.
mysql via spring/hibernate EOFException? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • mysql via spring/hibernate EOFException?

    Hi guys,

    After working successfully with HSQLDB I have not got the need to switch to mysql. Something that I thought was easy enough. Change configuration to...

    Code:
    <bean id="dataSource"
    		class="org.apache.commons.dbcp.BasicDataSource"
    		destroy-method="close">
    
    		<property name="driverClassName">
    			<value>com.mysql.jdbc.Driver</value>
    		</property>
    		<property name="url">
    			<value>jdbc:mysql://localhost/test</value>
    	 	</property>
    		<property name="username">
    			<value>root</value>
    		</property>
    		<property name="password">
    			<value>mxqo</value>
    		</property>
    	</bean>
    
    	<bean id="sessionFactory"
    		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    		<property name="dataSource" ref="dataSource" />
    		<property name="mappingResources">
    			<list>
    				<value>
    					com/earthisonsale/model/account/Account.hbm.xml
    				</value>
    			</list>
    		</property>
    		<property name="hibernateProperties">
    			<props>
    				<prop key="hibernate.hbm2ddl.auto">update</prop>
    				<prop key="hibernate.dialect">
    					org.hibernate.dialect.MySQLDialect
    				</prop>
    				<prop key="hibernate.show_sql">true</prop>
    				<prop key="show_sql">true</prop>
    			</props>
    		</property>
    	</bean>
    I ran a quick JDBC connection test and I can quite happliy run a stand alone program with this exact configuration and query the database using JDBC. However when I deploy my war to tomcat I get an error I would never expect to see....

    Code:
    2006-09-30 15:31:29,814 ERROR [org.hibernate.util.JDBCExceptionReporter] - <Cannot create PoolableConnectionFactory (Communications link failure due to underlying exception:
    
    ** BEGIN NESTED EXCEPTION **
    
    java.io.EOFException
    
    STACKTRACE:
    
    java.io.EOFException
            at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1934)
            at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:483)
            at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:992)
            at com.mysql.jdbc.Connection.createNewIO(Connection.java:2568)
            at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
            at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
            at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:37)
            at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:290)
            at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:877)
            at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:851)
            at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
            at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:81)
            at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:73)
            at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1928)
            at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1211)
            at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:901)
            at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:827)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:957)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:924)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:415)
            at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:301)
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:348)
            at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:156)
            at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
            at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
            at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
            at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3692)
            at org.apache.catalina.core.StandardContext.start(StandardContext.java:4127)
            at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
            at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
            at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
            at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:804)
            at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:693)
            at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:472)
            at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1181)
            at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:292)
            at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
            at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1304)
            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.run(ContainerBase.java:1557)
            at java.lang.Thread.run(Thread.java:595)
    
    
    ** END NESTED EXCEPTION **
    Can you get any more bizzare than that? I know the configuration is correct because I can use normal JDBC, so its something else. But an EOFException?

    Any help appreciated.

    Stay safe!

    MC

  • #2
    Your configuration is correct however the libraries which you are using might not be. First make sure you have the latest mysql version from your generation (4.x, 4.1.x ,5.x or whatever you are using) and you are using the appropriate jdbc driver with it - this is critical in mysql case.
    If that doesn't work properly check the mysql jdbc connector - it states what databases should be used and what are the known problems.
    Also, you might consider switching from commons-dbcp to c3p0 (it's a much better connection pooling implementation).

    Comment

    Working...
    X