?
Solved

Exception after setting jdbc session management

Posted on 2016-09-28
2
Medium Priority
?
137 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 2000 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

Not sure which OpenStack Certification to get?

So you’ve realized you might want to get certified in OpenStack, but you’re not sure what the benefits might be or even which one you should take. You know there are several certification courses you can choose from, but how do you know which one is right for you?

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 last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses

719 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