• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Hibernate code not working on Linux Server

 
Bartender
Posts: 1973
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have working Hibernate code running fine on the local machine, but when I put it up on the Linux box, the Dao logic fails (the database part...).

The MySQL version, Tomcat version, passwords, JDBC Driver passwords are the same. Class files are the same. Hibernate config file is in the classes directory.

In the project's lib folder under Tomcat, I copies all the Jar files (except the JBOSS ones) that come with the Hiberate 3.2 zip file.

I don't get any errors when running the code on the server, except in the log it just says: "Entry retrieval failed.".

Since the Linux box uses Apache (mod_jk and all that), are there any special requirements to run Hibernate on Linux that I'm not aware of?

Anything else I could try?

Thanks in advance.

Mike
 
Saloon Keeper
Posts: 28469
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Turn on the Hibernate logging features. The presence or absence of Apache should make no difference and neither should the fact that it's running Linux.
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On the logging note, here's a great tutorial on Hibernate logging that I found the other day:

How to configure Hibernate Logging with Log4J

It might be helpful in your troubleshooting.

-Cameron McKenzie
 
Mike London
Bartender
Posts: 1973
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks to all.

So far, the error I seem to be getting is that the SQL command is denied for select for table users.

In phpAdmin, the users table (in the affected database) has select rights.

I'm also having connection issues.

.....

Mike
 
Mike London
Bartender
Posts: 1973
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've gotten the code working to the point where, on the linux server, it works the first time.

But, if I close the browser and try again, it doesn't. The log then says: "Communications Link Failure" with a nice error stack.

This Linux server is Apache/Tomcat 5.5/MySQL 5.0.latest

Look forward to any suggestions.

Mike
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mike London:

But, if I close the browser and try again, it doesn't. The log then says: "Communications Link Failure" with a nice error stack.



Please post the entire exception stacktrace.
 
Mike London
Bartender
Posts: 1973
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, here's the situation.

After getting the stack trace I reboot apache and tomcat. I can log in fine, but only twice (works fine everytime locally, of course...). The third time, the log-in just returns to the user name field, but in the Tomcat log, I have the error stack below.

I've tried using both the 3.1.X version of the JDBC driver and the 5.1 version, but get the results with both (MySQL 5.0.45, Tomcat 5.5).

Thanks for any help or suggestions!!!

Mike

------------------------

STACKTRACE:

com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:

** BEGIN NESTED EXCEPTION **

java.net.SocketException
MESSAGE: Broken pipe

STACKTRACE:

java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2739)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2650)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1581)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1695)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3026)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1137)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1231)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
at org.hibernate.loader.Loader.doQuery(Loader.java:674)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2213)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at testProject.UsersDAO.findByProperty(UsersDAO.java:125)
at testProject.UsersDAO.findByUsrLogin(UsersDAO.java:176)
at testProject.ValidateLogin.validate(ValidateLogin.java:48)
at org.apache.jsp.login_jsp._jspService(login_jsp.java:121)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:200)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:773)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:703)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:895)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:595)


** END NESTED EXCEPTION **



Last packet sent to the server was 3 ms ago.
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2757)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2650)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1581)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1695)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3026)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1137)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1231)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
at org.hibernate.loader.Loader.doQuery(Loader.java:674)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2213)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at testProject.UsersDAO.findByProperty(UsersDAO.java:125)
at testProject.UsersDAO.findByUsrLogin(UsersDAO.java:176)
at testProject.ValidateLogin.validate(ValidateLogin.java:48)
at org.apache.jsp.login_jsp._jspService(login_jsp.java:121)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:200)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:773)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:703)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:895)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:595)


** END NESTED EXCEPTION **
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Based on what i have seen about similar errors, these turn out to be because of using an old version of JDBC driver. Are you sure you used the latest 5.1.6 version of MySQL driver. I would recommend, you do a search for mysql related driver jar files on your server to ensure that some incorrect jar is not being picked up.
 
Mike London
Bartender
Posts: 1973
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your quick response...

The error stack above was with the 3.1 driver.

Below is the error stack using the 5.1 driver (Connector/J),

(Again, an login once, but then...)

Have you ever seen this error or how to resolve it?

Thanks.

-- Mike

------------------------



com.mysql.jdbc.CommunicationsException
MESSAGE: Communications link failure

Last packet sent to the server was 42 ms ago.

STACKTRACE:

com.mysql.jdbc.CommunicationsException: Communications link failure

Last packet sent to the server was 42 ms ago.
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1070)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2985)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2871)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3414)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1885)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
at org.hibernate.loader.Loader.doQuery(Loader.java:674)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2213)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at testProject.UsersDAO.findByProperty(UsersDAO.java:125)
at testProject.UsersDAO.findByUsrLogin(UsersDAO.java:176)
at testProject.ValidateLogin.validate(ValidateLogin.java:48)
at org.apache.jsp.login_jsp._jspService(login_jsp.java:121)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:200)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:773)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:703)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:895)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2431)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2882)
... 44 more


** END NESTED EXCEPTION **
 
Mike London
Bartender
Posts: 1973
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here are the lib files I have running locally and on the Linux server. Maybe there's something wrong here? For example, I am not sure I should have the JBOSS jar files on an Apache server, but am not sure...

Thanks again for any help solving this strange communications link failure..

Mike

08/13/2005 03:28 PM 1,034,049 ant-1.6.5.jar
08/13/2005 03:28 PM 5,667 ant-antlr-1.6.5.jar
08/13/2005 03:28 PM 74,237 ant-junit-1.6.5.jar
08/13/2005 03:28 PM 9,180 ant-launcher-1.6.5.jar
08/13/2005 03:28 PM 6,763 ant-swing-1.6.5.jar
05/05/2006 11:58 AM 443,432 antlr-2.7.6.jar
03/17/2005 04:05 PM 16,777 asm-attrs.jar
03/17/2005 03:32 PM 26,360 asm.jar
01/19/2007 09:04 AM 608,376 c3p0-0.9.1.jar
12/02/2005 11:28 AM 282,338 cglib-2.1.3.jar
08/08/2004 06:35 AM 1,204,897 checkstyle-all.jar
07/22/2004 02:24 PM 142,704 cleanimports.jar
06/30/2004 04:59 AM 175,426 commons-collections-2.1.1.jar
07/04/2004 04:49 AM 38,015 commons-logging-1.0.4.jar
06/03/2004 11:31 AM 171,071 concurrent-1.3.2.jar
08/13/2005 03:28 PM 313,898 dom4j-1.6.1.jar
11/03/2006 01:05 PM 208,048 ehcache-1.2.3.jar
02/06/2008 09:31 PM 2,274,768 hibernate3.jar
06/03/2004 11:31 AM 104,359 jaas.jar
12/23/2004 09:26 PM 24,180 jacc-1_0-fr.jar
11/16/2006 01:46 PM 471,005 javassist.jar
08/16/2005 02:04 PM 226,877 jaxen-1.1-beta-7.jar
02/10/2006 09:39 PM 517,527 jboss-cache.jar
03/16/2005 12:10 AM 583,206 jboss-common.jar
03/16/2005 12:10 AM 591,568 jboss-jmx.jar
03/16/2005 12:10 AM 223,640 jboss-system.jar
12/15/2005 06:06 PM 1,611,518 jgroups-2.2.8.jar
06/03/2004 11:31 AM 8,812 jta.jar
06/03/2004 11:31 AM 121,070 junit-3.8.1.jar
08/13/2005 03:28 PM 350,627 log4j-1.2.11.jar
01/19/2005 10:11 AM 114,308 oscache-2.1.jar
06/03/2004 11:31 AM 475,943 proxool-0.8.3.jar
06/03/2004 11:31 AM 30,602 swarmcache-1.0rc2.jar
10/24/2005 06:45 AM 142,026 syndiag2.jar
11/14/2004 07:03 AM 5,762 versioncheck.jar
12/19/2004 06:14 PM 1,010,806 xerces-2.6.2.jar
06/03/2004 11:31 AM 123,705 xml-apis.jar
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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



This (long) thread in the MySQL forum discusses exactly this problem. Some of the users there, mention solving the problem by using mysql-5.0 JDBC driver and some have fixed it by changing the MySQL server configuration in their .ini files.
 
Tim Holloway
Saloon Keeper
Posts: 28469
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I really think you need to have a talk with your network administrator. Also have someone check the log files on the MySQL server itself. By all appearances, you're having issues with the network link between the client and server, and the OS's of each shouldn't be making a difference. One possibility is that the client's MTU setting (Maximum Transfer Unit or packet size) needs to be adjusted.
 
Mike London
Bartender
Posts: 1973
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, I've been working with the admin for a couple days now. It's frustrating when things work perfectly locally, and for some reason, crap out on the actual server...

Plus, depending on the JDBC version, the exceptions change. Therefore, it's most likely not the JDBC driver, but something else, I know.

Just for completeness, I tried the 5.0 JDBC driver this morning but also (still) get the 4 byte exception.

I'm also using Red Hat 7.3 -- a VERY OLD, no longer supported, Linux distribution. And, while that OS version shouldn't make any difference, it may be something to look at.

As for editing the actual MySQL files, I don't see them when browsing my VPS using putty. Perhaps I'll need to have the admin edit these for me (or get a standalone server...)

Sigh............

Thanks to all for all the help....I'll keep you updated....

Mike
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also check on how many current connections are allowed to the database..
 
This guy is skipping without a rope. At least, that's what this tiny ad said:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic