Rohit Bajaj
asked on
Exception after setting jdbc session management
HI,
Following the link http://www.eclipse.org/jetty/documentation/9.3.x/session-clustering-jdbc.html
I setup the session Id Manager and SessionManager in my embedded jetty web application.
But i am getting the following exception when i load the page :
Rest code for setting up my embedded jetty server is same. Application was running fine previously but now the server does start but then there is this exception.
Also one thing which i notice from the article which i am missing is :
When using the jetty distribution, to enable jdbc session persistence, you will first need to enable the jdbc-session module for your base using the --add-to-start or --add-to-startd argument to the start.jar.
But i am starting my jetty from intellij idea from a main function... dont know how to fit these there
Thanks
Following the link http://www.eclipse.org/jetty/documentation/9.3.x/session-clustering-jdbc.html
I setup the session Id Manager and SessionManager in my embedded jetty web application.
But i am getting the following exception when i load the page :
2016-09-28 14:43:24 DEBUG qtp248609774-19 org.eclipse.jetty.server.handler.ContextHandler scope null||/favicon.ico @ o.e.j.w.WebAppContext@34ce8af7{/,file:///Users/robinsuri/Checkout/flock-notes/target/classes/webapp/,AVAILABLE}
2016-09-28 14:43:24 DEBUG qtp248609774-19 org.eclipse.jetty.server.handler.ContextHandler scope null||/favicon.ico @ o.e.j.w.WebAppContext@34ce8af7{/,file:///Users/robinsuri/Checkout/flock-notes/target/classes/webapp/,AVAILABLE}
2016-09-28 14:43:24 DEBUG qtp248609774-19 org.eclipse.jetty.server.handler.ContextHandler context=||/favicon.ico @ o.e.j.w.WebAppContext@34ce8af7{/,file:///Users/robinsuri/Checkout/flock-notes/target/classes/webapp/,AVAILABLE}
2016-09-28 14:43:24 DEBUG qtp248609774-19 org.eclipse.jetty.server.handler.ContextHandler context=||/favicon.ico @ o.e.j.w.WebAppContext@34ce8af7{/,file:///Users/robinsuri/Checkout/flock-notes/target/classes/webapp/,AVAILABLE}
2016-09-28 14:43:24 DEBUG qtp248609774-19 org.eclipse.jetty.server.session Got Session ID stwe2x751x959689f5pnbgw3 from cookie
2016-09-28 14:43:24 DEBUG qtp248609774-19 org.eclipse.jetty.server.session Got Session ID stwe2x751x959689f5pnbgw3 from cookie
2016-09-28 14:43:24 DEBUG qtp248609774-19 org.eclipse.jetty.server.session.JDBCSessionManager getSession(stwe2x751x959689f5pnbgw3): in session map, hashcode=1332006132 now=1475054004732 lastSaved=1475053997554 interval=60000 lastNode=null thisNode=null difference=7178
2016-09-28 14:43:24 DEBUG qtp248609774-19 org.eclipse.jetty.server.session.JDBCSessionManager getSession(stwe2x751x959689f5pnbgw3): in session map, hashcode=1332006132 now=1475054004732 lastSaved=1475053997554 interval=60000 lastNode=null thisNode=null difference=7178
2016-09-28 14:43:24 DEBUG qtp248609774-19 org.eclipse.jetty.server.session.JDBCSessionManager getSession(stwe2x751x959689f5pnbgw3): session in session map
2016-09-28 14:43:24 DEBUG qtp248609774-19 org.eclipse.jetty.server.session.JDBCSessionManager getSession(stwe2x751x959689f5pnbgw3): session in session map
2016-09-28 14:43:24 WARN qtp248609774-19 org.eclipse.jetty.server.HttpChannel //localhost:8080/favicon.ico
java.lang.NullPointerException
at org.eclipse.jetty.server.session.JDBCSessionManager.getSession(JDBCSessionManager.java:528)
at org.eclipse.jetty.server.session.JDBCSessionManager.getSession(JDBCSessionManager.java:75)
at org.eclipse.jetty.server.session.AbstractSessionManager.getHttpSession(AbstractSessionManager.java:323)
at org.eclipse.jetty.server.session.SessionHandler.checkRequestedSessionId(SessionHandler.java:275)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:151)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1090)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119)
at org.eclipse.jetty.server.Server.handle(Server.java:517)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:306)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:261)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
at java.lang.Thread.run(Thread.java:745)
What could be the reason for it. Following is the code i have added in my embedded jetty to handle jdbc session management : server = new Server();
JDBCSessionIdManager idMgr = new JDBCSessionIdManager(server);
BasicDataSource dataSource = new BasicDataSource();
dataSource.setUrl(props.getProperty("note.jdbc.url"));
dataSource.setUsername(props.getProperty("note.jdbc.username"));
dataSource.setPassword(props.getProperty("note.jdbc.password"));
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
idMgr.setDatasource(dataSource);
server.setSessionIdManager(idMgr);
WebAppContext context = new WebAppContext();
JDBCSessionManager jdbcMgr = new JDBCSessionManager();
jdbcMgr.setSessionIdManager(server.getSessionIdManager());
SessionHandler sessionHandler = new SessionHandler(jdbcMgr);
context.setSessionHandler(sessionHandler);
Rest code for setting up my embedded jetty server is same. Application was running fine previously but now the server does start but then there is this exception.
Also one thing which i notice from the article which i am missing is :
When using the jetty distribution, to enable jdbc session persistence, you will first need to enable the jdbc-session module for your base using the --add-to-start or --add-to-startd argument to the start.jar.
But i am starting my jetty from intellij idea from a main function... dont know how to fit these there
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:)