Jetty
  1. Jetty
  2. JETTY-1013

MySql Error with JDBCUserRealm

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.1.18
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      We are using Embedded Jetty in an very low traffic area of our system. If no requests are made for an extended period of time (more than a day or so) the JDBCUserRealm throws an exception the first time verification is attempted.

      After reading over the thread on mysql's site (http://forums.mysql.com/read.php?39,199085,199085#msg-199085) it appears that the problems stems from using a stale connection i.e. leaving a connection open for long periods of time.

      I checked out the JDBCUserRealm code and sure enough it gets a connection once and then never closes it. I could see a few possible solutions.

      1) Use an actual database connection pool
      2) Test the connection before using it (though this could get expensive).
      3) Have a thread that async checks or blindly closes the connection after a number of hours.

      WARN 2009-05-03 14:29:24,668 org.mortbay.log.Slf4jLog.warn(Slf4jLog.java:89)[1725603492@qtp-1014593217-2 - /lms/request/CreateUserRequest/default/] org.mortbay.log UserRealm lms-realm could not load user information from database
      com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was154198 seconds ago.The last packet sent successfully to the server was 154198 seconds ago, which is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
      at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
      at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
      at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3246)
      at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1917)
      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.mortbay.jetty.security.JDBCUserRealm.loadUser(JDBCUserRealm.java:248)
      at org.mortbay.jetty.security.JDBCUserRealm.authenticate(JDBCUserRealm.java:212)
      at org.mortbay.jetty.security.DigestAuthenticator.authenticate(DigestAuthenticator.java:116)
      at org.mortbay.jetty.security.SecurityHandler.check(SecurityHandler.java:441)
      at org.mortbay.jetty.security.SecurityHandler.checkSecurityConstraints(SecurityHandler.java:269)
      at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:191)
      at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
      at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      at org.mortbay.jetty.Server.handle(Server.java:320)
      at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
      at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865)
      at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
      at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
      at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
      at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
      at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
      Caused by: 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:3227)
      ... 22 more

        Activity

          People

          • Assignee:
            Jan Bartel
            Reporter:
            Benjamin Darfler
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: