<div dir="ltr">Hi Stuart,<div><br></div><div>I have a regular servlet (the sample... public class HelloWorldServlet extends HttpServlet) running inside the same web context (in the same war).  In the HelloWorldServlet I can access the session object.  I ran that first, but when I run the non-blocking servlet, my <span style="font-family:arial,sans-serif;font-size:13px">reqctx still returns null.  </span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">I&#39;m running Wildfly 8.0.0 final, in case that matters.</span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br>
</span></div><div><span style="font-family:arial,sans-serif;font-size:13px">So is everything hinging on:</span></div><div><pre style="font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;font-size:12px;margin-top:0px;margin-bottom:0px;color:rgb(51,51,51);line-height:18px">
<div class="" id="LC73" style="padding-left:10px"><span class="" style="font-weight:bold"><br></span></div><div class="" id="LC73" style="padding-left:10px"><span class="" style="font-weight:bold">public</span> <span class="" style="font-weight:bold">class</span> <span class="" style="color:rgb(68,85,136);font-weight:bold">ServletInitialHandler</span> <span class="" style="font-weight:bold">implements</span> <span class="" style>HttpHandler</span><span class="" style="font-weight:bold">,</span> <span class="" style>ServletDispatcher</span> <span class="" style="font-weight:bold">{</span></div>
<div><span class="" style="font-weight:bold"> ...</span></div><div><span class="" style="font-weight:bold"><span class="" style="color:rgb(51,51,51)">   public</span><span style="font-weight:normal"> </span><span class="" style="color:rgb(68,85,136)">void</span><span style="font-weight:normal"> </span><span class="" style="color:rgb(153,0,0)">handleRequest</span><span class="" style>(</span><span class="" style="color:rgb(51,51,51)">final</span><span style="font-weight:normal"> </span><span class="" style="font-weight:normal;background-color:rgb(255,255,255)">HttpServerExchange</span><span style="font-weight:normal"> </span><span class="" style="font-weight:normal;background-color:rgb(255,255,255)">exchange</span><span class="" style>)</span><span style="font-weight:normal"> </span><span class="" style="color:rgb(51,51,51)">throws</span><span style="font-weight:normal"> </span><span class="" style="font-weight:normal;background-color:rgb(255,255,255)">IOException</span><span class="" style>,</span><span style="font-weight:normal"> </span><span class="" style="font-weight:normal;background-color:rgb(255,255,255)">ServletException</span><br>
</span></div><div><span class="" style="font-weight:bold"><span class="" style="font-weight:normal;background-color:rgb(255,255,255)">   ...</span></span></div></pre></div><div><pre style="font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;font-size:12px;margin-top:0px;margin-bottom:0px;color:rgb(51,51,51);line-height:18px">
<div class="" id="LC130" style="padding-left:10px"><span class="" style>    exchange</span><span class="" style="font-weight:bold">.</span><span class="" style="color:teal">putAttachment</span><span class="" style="font-weight:bold">(</span><span class="" style>ServletRequestContext</span><span class="" style="font-weight:bold">.</span><span class="" style="color:teal">ATTACHMENT_KEY</span><span class="" style="font-weight:bold">,</span> <span class="" style>servletRequestContext</span><span class="" style="font-weight:bold">);</span></div>
<div><span class="" style="font-weight:bold"> ...</span></div><div><span class="" style="font-weight:bold"><br></span></div><div><br></div></pre></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Sun, Mar 9, 2014 at 12:55 PM, Stuart Douglas <span dir="ltr">&lt;<a href="mailto:sdouglas@redhat.com" target="_blank">sdouglas@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This will only be not null after the first servlet handler has run. <br>
If your handler is executing outside the scope of the servlet deployment then you need to store a reference to the ServletContext somewhere (worst case = stick it in a static somewhere). <br><span class="HOEnZb"><font color="#888888">
Stuart</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
Lightspoke Discussion wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
If you are running before the initial handler you need to store a reference to the servlet context or the Deployment somewhere.<br>
</blockquote>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>--<br>Matthew Ma<br><a href="http://www.lightspoke.com">http://www.lightspoke.com</a><br>Lightspoke Web Based Database
</div>