Solved

Exception after setting jdbc session management

Posted on 2016-09-28
2
62 Views
Last Modified: 2016-10-14
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 :
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)

Open in new window

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);

Open in new window


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
0
Comment
Question by:Rohit Bajaj
  • 2
2 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 41823027
But i am starting my jetty from intellij idea from a main function
How? There's almost certainly a way of either passing the correct parameters or providing init properties
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 41843234
:)
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question