views:

20

answers:

1

Hi,

I have a bit of a problem using the JDBCSessionManager in Jetty 7. For some reason the it tries to persist the SessionManager when persisting the SessionAuthentication :

...

16:46:02,455 WARN org.eclipse.jetty.util.log - Problem persisting changed session data id=b75j2q0lak5s1o2zuryj05h9y java.io.NotSerializableException: org.eclipse.jetty.server.session.JDBCSessionManager

....

Setup code:

....

    server.setSessionIdManager(getSessionIdManager());
    final SessionManager jdbcSessionManager = new JDBCSessionManager();
    jdbcSessionManager.setIdManager(server.getSessionIdManager());
    context.setSessionHandler(new SessionHandler(jdbcSessionManager));

            server.setHandler(context);
}

private SessionIdManager getSessionIdManager() {
    JDBCSessionIdManager idMan = new JDBCSessionIdManager(server);
    idMan.setDriverInfo("com.mysql.jdbc.Driver", "jdbc:mysql://localhost/monty?user=xxxx&password=Xxxx");
    idMan.setWorkerName("monty");
    return idMan;
}

....

Has anyone experienced something similar?

A: 

I wouldn't recommend serializing anything regarding JDBC to session. My preferred mode of operation is the acquire, use, and close any and all database resources such as connection, statements, and result sets in the narrowest scope possible. I use connection pools to amortize the cost of opening database connections. That's the way I think you should go, too.

Besides, you have no choice if the class doesn't implement java.io.Serializable. Perhaps the designers were trying to express my feelings in code.

I checked the javadocs for JDBCSessionManager. Neither the leaf class nor any of its superclasses implement Serializable.

duffymo
I wasn't trying to suggest that JDBCSessionManager should be Serializable, but merely trying to figure out whether the JDBCSessionManager is broken in Jetty 7.
Jesper
I'm simply responding to the error message that you posted, which complains "java.io.NotSerializableException: org.eclipse.jetty.server.session.JDBCSessionManager". This suggests to me that serialization was involved.
duffymo