Solved

Exception after setting jdbc session management

Posted on 2016-09-28
2
38 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Exchange and Third Party application. 8 60
array220 challenge 8 48
parentbit challenge 3 52
word0 challenge 3 58
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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 will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now