Solved

Exception after setting jdbc session management

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

939 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

6 Experts available now in Live!

Get 1:1 Help Now