Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion [2.0][Java] Http context in Async Result

Received: by 10.204.129.81 with SMTP id n17mr1452550bks.3.1341315410578;
        Tue, 03 Jul 2012 04:36:50 -0700 (PDT)
X-BeenThere: play-framework@googlegroups.com
Received: by 10.204.152.214 with SMTP id h22ls6378694bkw.4.gmail; Tue, 03 Jul
 2012 04:36:32 -0700 (PDT)
Received: by 10.205.126.4 with SMTP id gu4mr252469bkc.8.1341315392545;
        Tue, 03 Jul 2012 04:36:32 -0700 (PDT)
Received: by 10.205.126.4 with SMTP id gu4mr252468bkc.8.1341315392507;
        Tue, 03 Jul 2012 04:36:32 -0700 (PDT)
Return-Path: <stik...@gmail.com>
Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com [209.85.217.177])
        by gmr-mx.google.com with ESMTPS id p5si12124071bks.1.2012.07.03.04.36.32
        (version=TLSv1/SSLv3 cipher=OTHER);
        Tue, 03 Jul 2012 04:36:32 -0700 (PDT)
Received-SPF: pass (google.com: domain of stik...@gmail.com designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of stik...@gmail.com designates 209.85.217.177 as permitted sender) smtp.mail=stik...@gmail.com; dkim=pass header...@gmail.com
Received: by mail-lb0-f177.google.com with SMTP id gg6so9387268lbb.36
        for <play-framework@googlegroups.com>; Tue, 03 Jul 2012 04:36:32 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=mime-version:in-reply-to:references:date:message-id:subject:from:to
         :content-type;
        bh=ptxYymCTK3YmU69Fhz6/42NcybJ7ghv5MwwXztP0mIY=;
        b=OD4SJYYt2O+BnY51417n0ChU+X1jt8ooEz3ujfWCpbJQtpdF/Djix2E7L4NV1w9PRt
         lFa4fcx9GI309xIC4SPC8rJ9ihB2D6cJM+fwGBCKsN4F8SSQGzachTcvjARo8Z/UHp0i
         FwBENIHn1PbqIvzp0/QQPkUEBg2/GVV4H5hbTXlBIwBgkWj7lkladYzNmtqeZXLGLNMP
         e4ZfwmhbkCoDFYbh5b8merU8GOYBFd7vk+Qinn27UTzkahjTZ54Z9sBuZmebrry/E3M7
         xJvNNs5ReTd5W1y+9kANvmOTV79zBIPSfj5ZD7zfg8zA2P/anjVKkpOfrhLHbp5c0FUB
         6NFQ==
MIME-Version: 1.0
Received: by 10.152.46.232 with SMTP id y8mr17094197lam.18.1341315392237; Tue,
 03 Jul 2012 04:36:32 -0700 (PDT)
Received: by 10.112.63.47 with HTTP; Tue, 3 Jul 2012 04:36:32 -0700 (PDT)
In-Reply-To: <98B31D84-1407-467F-B694-2257101D3...@gmail.com>
References: <E45A860D-3663-46C1-92D0-B135C947A...@gmail.com>
	<CAP1F=qfCf6fTYdin9GXvj2stmQeF5VaxewUph97QuNEez=c...@mail.gmail.com>
	<29D38775-734A-44B4-AE51-15ABE5581...@gmail.com>
	<CAP1F=qfT6n5y+cDTAjWwF8-ynUCvN1RYSO5axcAFocgnv4s...@mail.gmail.com>
	<98B31D84-1407-467F-B694-2257101D3...@gmail.com>
Date: Tue, 3 Jul 2012 12:36:32 +0100
Message-ID: <CAEY_-MNLEda8gkJpgzkLJspYKug2bDzhgK5TQzCEzX-ZHPq...@mail.gmail.com>
Subject: Re: [play-framework][2.0][Java] Http context in Async Result
From: Stijn Janssens <stik...@gmail.com>
To: play-framework@googlegroups.com
Content-Type: multipart/alternative; boundary=bcaec55242067c720104c3eb53ef

--bcaec55242067c720104c3eb53ef
Content-Type: text/plain; charset=ISO-8859-1

Hi I just upgraded to play 2.0.2 and the problem re-appeared

Caused by: java.lang.RuntimeException: There is no HTTP Context available
from here.
at play.mvc.Http$Context.current(Http.java:27) ~[play_2.9.1.jar:2.0.2]
at play.mvc.Controller.flash(Controller.java:70) ~[play_2.9.1.jar:2.0.2]

Any ideas?

Thanks!

On 15 May 2012 12:52, Stikkos <stik...@gmail.com> wrote:

> Cool, i just tested it in master and indeed it has been fixed!
>
> Love it ;-)
>
>
>
> On 15 May 2012, at 11:50, Julien Richard-Foy wrote:
>
> > This should has been fixed in master. Can you try with it?
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "play-framework" group.
> > To post to this group, send email to play-framework@googlegroups.com.
> > To unsubscribe from this group, send email to
> play-framework+unsubscribe@googlegroups.com.
> > For more options, visit this group at
> http://groups.google.com/group/play-framework?hl=en.
> >
>
>
Stikkos
15 May
to play-framework
Hi,

I am using AsyncResults in my controllers as defined http
://www.playframework.org/documentation/2.0.1/JavaAsync

public static Result index() {
  Promise<Integer> promiseOfInt = Akka.future(
    new Callable<Integer>() {
      public Integer call() {
        return intensiveComputation();
      }
    }
  );
  return async(
    promiseOfInt.map(
      new Function<Integer,Result>() {
        public Result apply(Integer i) {
	  flash().put("success", "The operation was successful");     // problem line
          return ok("Got result: " + i);
        }
      }
    )
  );
}

The problem is that there is not HTTP context in the async result, which
causes the following error

java.lang.RuntimeException: There is no HTTP Context available from here.
at play.mvc.Http$Context.current(Http.java:27) ~[play_2.9.1.jar:2.0.1]
at play.mvc.Controller.flash(Controller.java:70) ~[play_2.9.1.jar:2.0.1]

Is there any way to modify the HTTP context in an async result? Or what is the
recommended approach to handle stuff like this?

Thanks,
Stik

--bcaec55242067c720104c3eb53ef
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi I just upgraded to play 2.0.2 and the problem re-appeared<div><br></div>=
<div><div>Caused by: java.lang.RuntimeException: There is no HTTP Context a=
vailable from here.</div><div><span class=3D"Apple-tab-span" style=3D"white=
-space:pre">	</span>at play.mvc.Http$Context.current(Http.java:27) ~[play_2=
.9.1.jar:2.0.2]</div>
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre">	</span>at pl=
ay.mvc.Controller.flash(Controller.java:70) ~[play_2.9.1.jar:2.0.2]</div></=
div><div><br></div><div>Any ideas?</div><div><br></div><div>Thanks!</div><d=
iv>
<br><div class=3D"gmail_quote">On 15 May 2012 12:52, Stikkos <span dir=3D"l=
tr">&lt;<a href=3D"mailto:stik...@gmail.com" target=3D"_blank">stikkos@gmai=
l.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"m=
argin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Cool, i just tested it in master and indeed it has been fixed!<br>
<br>
Love it ;-)<br>
<div class=3D"HOEnZb"><div class=3D"h5"><br>
<br>
<br>
On 15 May 2012, at 11:50, Julien Richard-Foy wrote:<br>
<br>
&gt; This should has been fixed in master. Can you try with it?<br>
&gt;<br>
&gt; --<br>
&gt; You received this message because you are subscribed to the Google Gro=
ups &quot;play-framework&quot; group.<br>
&gt; To post to this group, send email to <a href=3D"mailto:play-framework@=
googlegroups.com">play-framework@googlegroups.com</a>.<br>
&gt; To unsubscribe from this group, send email to <a href=3D"mailto:play-f=
ramework%2Bunsubscribe@googlegroups.com">play-framework+unsubscribe@googleg=
roups.com</a>.<br>
&gt; For more options, visit this group at <a href=3D"http://groups.google.=
com/group/play-framework?hl=3Den" target=3D"_blank">http://groups.google.co=
m/group/play-framework?hl=3Den</a>.<br>
&gt;<br>
<br></div></div></blockquote><div><br></div><div class=3D"gE iv gt" style=
=3D"font-size:13px;padding-left:0px;padding-bottom:3px;padding-right:0px;pa=
dding-top:12px;border-collapse:collapse;color:rgb(34,34,34);font-family:ari=
al,sans-serif">
<table cellpadding=3D"0" class=3D"cf gJ" style=3D"border-collapse:collapse;=
margin-top:0px;width:auto"><tbody><tr class=3D"acZ" style=3D"height:16px"><=
td class=3D"gF gK" style=3D"margin-top:0px;margin-right:0px;margin-bottom:0=
px;margin-left:0px;font-family:arial,sans-serif;text-align:left;white-space=
:nowrap;padding-right:8px;vertical-align:top;width:1009px;padding-top:0px">
<table cellpadding=3D"0" class=3D"cf ix" style=3D"border-collapse:collapse;=
table-layout:fixed;width:1009px"><tbody><tr><td style=3D"margin-top:0px;mar=
gin-right:0px;margin-bottom:0px;margin-left:0px;font-family:arial,sans-seri=
f"><div class=3D"iw" style=3D"overflow-x:hidden;overflow-y:hidden;white-spa=
ce:nowrap;max-width:92%;display:inline-block">
<span class=3D"gD" style=3D"font-size:13px;font-weight:bold;white-space:now=
rap;display:inline;vertical-align:top;color:rgb(34,34,34)">Stikkos</span></=
div></td></tr></tbody></table></td><td class=3D"gH" style=3D"margin-top:0px=
;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:arial,sans-=
serif;text-align:right;white-space:nowrap;vertical-align:top;color:rgb(34,3=
4,34)">
<div class=3D"gK" style=3D"padding-top:0px;padding-right:2px"><span></span>=
<span id=3D":1o" class=3D"g3" title=3D"15 May 2012 11:14" alt=3D"15 May 201=
2 11:14" style=3D"vertical-align:top;margin-right:3px">15 May</span><div cl=
ass=3D"zd" tabindex=3D"-1" style=3D"display:inline-block;height:20px;outlin=
e-width:0px;outline-style:initial;outline-color:initial">
<span class=3D"T-KT" style=3D"display:inline-block;height:19px;text-align:c=
enter;width:19px;padding-top:2px;padding-right:2px;padding-bottom:2px;paddi=
ng-left:2px;margin-right:0px;margin-left:0px"><img class=3D"f T-KT-JX" src=
=3D"https://mail.google.com/mail/images/cleardot.gif" alt=3D"" style=3D"mar=
gin-top: 0px; vertical-align: top; "></span></div>
</div></td><td class=3D"gH" style=3D"margin-top:0px;margin-right:0px;margin=
-bottom:0px;margin-left:0px;font-family:arial,sans-serif;text-align:right;w=
hite-space:nowrap;vertical-align:top;color:rgb(34,34,34)"></td><td class=3D=
"gH acX" rowspan=3D"2" style=3D"margin-top:0px;margin-right:0px;margin-bott=
om:0px;margin-left:0px;font-family:arial,sans-serif;text-align:right;white-=
space:nowrap;vertical-align:top;color:rgb(34,34,34)">
<div class=3D"T-I J-J5-Ji T-I-Js-IF aaq T-I-ax7 L3" tabindex=3D"0" style><i=
mg class=3D"hB T-I-J3" src=3D"https://mail.google.com/mail/images/cleardot.=
gif" alt=3D"" style=3D"height: 21px; width: 21px; background-image: url(htt=
ps://ssl.gstatic.com/ui/v1/icons/mail/sprite_black2.png); background-attach=
ment: initial; background-origin: initial; background-clip: initial; backgr=
ound-color: initial; vertical-align: middle; margin-top: -3px; opacity: 0.5=
5; background-position: 0px -63px; background-repeat: no-repeat no-repeat; =
"></div>
<div id=3D":3y" class=3D"T-I J-J5-Ji T-I-Js-Gs aap T-I-awG T-I-ax7 L3" titl=
e=3D"More" tabindex=3D"0" style><img class=3D"hA T-I-J3" src=3D"https://mai=
l.google.com/mail/images/cleardot.gif" alt=3D"" style=3D"height: 21px; widt=
h: 21px; background-image: url(https://ssl.gstatic.com/ui/v1/icons/mail/spr=
ite_black2.png); background-attachment: initial; background-origin: initial=
; background-clip: initial; background-color: initial; margin-top: -3px; ve=
rtical-align: middle; opacity: 0.55; background-position: -42px -84px; back=
ground-repeat: no-repeat no-repeat; "></div>
</td></tr><tr class=3D"acZ xD" style=3D"height:16px"><td colspan=3D"3" styl=
e=3D"margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font=
-family:arial,sans-serif"><table cellpadding=3D"0" class=3D"cf adz" style=
=3D"border-collapse:collapse;table-layout:fixed;white-space:nowrap;width:10=
88px">
<tbody><tr><td class=3D"ady" style=3D"margin-top:0px;margin-right:0px;margi=
n-bottom:0px;margin-left:0px;font-family:arial,sans-serif;overflow-x:hidden=
;overflow-y:hidden;white-space:nowrap"><div class=3D"iw ajw" style=3D"overf=
low-x:hidden;overflow-y:hidden;white-space:nowrap;max-width:92%;display:inl=
ine-block">
<span class=3D"hb" style=3D"vertical-align:top;color:rgb(119,119,119)">to=
=A0<span class=3D"g2" style=3D"vertical-align:top">play-framework</span></s=
pan></div><div class=3D"ajy" style=3D"display:inline-block;padding-left:5px=
;vertical-align:top">
<img class=3D"ajz" id=3D":3z" tabindex=3D"0" src=3D"https://mail.google.com=
/mail/images/cleardot.gif" alt=3D"" style=3D"background-image: url(https://=
mail.google.com/mail/?ui=3D2&amp;view=3Ddim&amp;iv=3D1gsef47chh4uh&amp;it=
=3Dic); background-attachment: initial; background-origin: initial; backgro=
und-clip: initial; background-color: initial; cursor: pointer; height: 12px=
 !important; padding-top: 0px; padding-right: 0px; padding-bottom: 1px; pad=
ding-left: 0px; vertical-align: bottom; width: 12px !important; background-=
position: -60px -100px; background-repeat: no-repeat no-repeat; "></div>
</td></tr></tbody></table></td></tr></tbody></table></div><div class=3D"utd=
U2e" style=3D"border-collapse:collapse;color:rgb(34,34,34);font-family:aria=
l,sans-serif;font-size:medium"></div><div class=3D"tx78Ic" style=3D"border-=
collapse:collapse;color:rgb(34,34,34);font-family:arial,sans-serif;font-siz=
e:medium">
</div><div class=3D"QqXVeb" style=3D"border-collapse:collapse;color:rgb(34,=
34,34);font-family:arial,sans-serif;font-size:medium"></div><div id=3D":40"=
 tabindex=3D"-1" style=3D"border-collapse:collapse;color:rgb(34,34,34);font=
-family:arial,sans-serif;font-size:medium">
</div><div id=3D":1q" class=3D"ii gt adP adO" style=3D"font-size:13px;margi=
n-top:5px;margin-right:15px;margin-bottom:0px;margin-left:0px;padding-botto=
m:5px;border-collapse:collapse;color:rgb(34,34,34);font-family:arial,sans-s=
erif">
<div id=3D":1r"><div style=3D"word-wrap:break-word">Hi,<div><br></div><div>=
I am using AsyncResults in my controllers as defined=A0<a href=3D"http://ww=
w.playframework.org/documentation/2.0.1/JavaAsync" target=3D"_blank" style=
=3D"color:rgb(17,85,204)"><span class=3D"il" style=3D"background-image:init=
ial;background-color:rgb(255,255,204);color:rgb(34,34,34);background-repeat=
:initial initial">http</span>://www.playframework.org/documentation/2.0.1/J=
avaAsync</a></div>
<div><br></div><div><pre style=3D"white-space:pre-wrap;margin-top:10px;marg=
in-right:0px;margin-bottom:10px;margin-left:0px;padding-top:8px;padding-rig=
ht:8px;padding-bottom:8px;padding-left:8px;border-top-width:1px;border-righ=
t-width:1px;border-bottom-width:1px;border-left-width:1px;border-style:init=
ial;border-color:initial;outline-width:0px;outline-style:initial;outline-co=
lor:initial;font-weight:inherit;font-style:inherit;border-top-style:solid;b=
order-right-style:solid;border-bottom-style:solid;border-left-style:solid;b=
order-top-color:rgb(225,225,232);border-right-color:rgb(225,225,232);border=
-bottom-color:rgb(225,225,232);border-left-color:rgb(225,225,232);backgroun=
d-image:initial;background-color:rgb(247,247,249);border-top-left-radius:5p=
x;border-top-right-radius:5px;border-bottom-right-radius:5px;border-bottom-=
left-radius:5px">
<font color=3D"#1e347b" face=3D"inconsolata, monospace"><span style=3D"font=
-size:14px">public static Result index() {
  Promise&lt;Integer&gt; promiseOfInt =3D Akka.future(
    new Callable&lt;Integer&gt;() {
      public Integer call() {
        return intensiveComputation();
      }
    }
  );
  return async(
    promiseOfInt.map(
      new Function&lt;Integer,Result&gt;() {
        public Result apply(Integer i) {
	  flash().put(&quot;success&quot;, &quot;The operation was successful&quot=
;);     // problem line
          return ok(&quot;Got result: &quot; + i);
        }=20
      }
    )
  );
}</span></font></pre><div>The problem=A0<span class=3D"il" style=3D"backgro=
und-image:initial;background-color:rgb(255,255,204);color:rgb(34,34,34);bac=
kground-repeat:initial initial">is</span>=A0that=A0<span class=3D"il" style=
=3D"background-image:initial;background-color:rgb(255,255,204);color:rgb(34=
,34,34);background-repeat:initial initial">there</span>=A0<span class=3D"il=
" style=3D"background-image:initial;background-color:rgb(255,255,204);color=
:rgb(34,34,34);background-repeat:initial initial">is</span>=A0not=A0<span c=
lass=3D"il" style=3D"background-image:initial;background-color:rgb(255,255,=
204);color:rgb(34,34,34);background-repeat:initial initial">HTTP</span>=A0<=
span class=3D"il" style=3D"background-image:initial;background-color:rgb(25=
5,255,204);color:rgb(34,34,34);background-repeat:initial initial">context</=
span>=A0in the async result, which causes the following error</div>
</div><div><br></div><div><div>java.lang.RuntimeException:=A0<span class=3D=
"il" style=3D"background-image:initial;background-color:rgb(255,255,204);co=
lor:rgb(34,34,34);background-repeat:initial initial">There</span>=A0<span c=
lass=3D"il" style=3D"background-image:initial;background-color:rgb(255,255,=
204);color:rgb(34,34,34);background-repeat:initial initial">is</span>=A0<sp=
an class=3D"il" style=3D"background-image:initial;background-color:rgb(255,=
255,204);color:rgb(34,34,34);background-repeat:initial initial">no</span>=
=A0<span class=3D"il" style=3D"background-image:initial;background-color:rg=
b(255,255,204);color:rgb(34,34,34);background-repeat:initial initial">HTTP<=
/span>=A0<span class=3D"il" style=3D"background-image:initial;background-co=
lor:rgb(255,255,204);color:rgb(34,34,34);background-repeat:initial initial"=
>Context</span>=A0<span class=3D"il" style=3D"background-image:initial;back=
ground-color:rgb(255,255,204);color:rgb(34,34,34);background-repeat:initial=
 initial">available</span>=A0from here.</div>
<div><span style=3D"white-space:pre-wrap">	</span>at play.mvc.<span class=
=3D"il" style=3D"background-image:initial;background-color:rgb(255,255,204)=
;color:rgb(34,34,34);background-repeat:initial initial">Http</span>$<span c=
lass=3D"il" style=3D"background-image:initial;background-color:rgb(255,255,=
204);color:rgb(34,34,34);background-repeat:initial initial">Context</span>.=
current(<span class=3D"il" style=3D"background-image:initial;background-col=
or:rgb(255,255,204);color:rgb(34,34,34);background-repeat:initial initial">=
Http</span>.java:27) ~[play_2.9.1.jar:2.0.1]</div>
<div><span style=3D"white-space:pre-wrap">	</span>at play.mvc.Controller.fl=
ash(Controller.java:70) ~[play_2.9.1.jar:2.0.1]</div></div><div><br></div><=
div><span class=3D"il" style=3D"background-image:initial;background-color:r=
gb(255,255,204);color:rgb(34,34,34);background-repeat:initial initial">Is</=
span>=A0<span class=3D"il" style=3D"background-image:initial;background-col=
or:rgb(255,255,204);color:rgb(34,34,34);background-repeat:initial initial">=
there</span>=A0any way to modify the=A0<span class=3D"il" style=3D"backgrou=
nd-image:initial;background-color:rgb(255,255,204);color:rgb(34,34,34);back=
ground-repeat:initial initial">HTTP</span>=A0<span class=3D"il" style=3D"ba=
ckground-image:initial;background-color:rgb(255,255,204);color:rgb(34,34,34=
);background-repeat:initial initial">context</span>=A0in an async result? O=
r what=A0<span class=3D"il" style=3D"background-image:initial;background-co=
lor:rgb(255,255,204);color:rgb(34,34,34);background-repeat:initial initial"=
>is</span>=A0the recommended approach to handle stuff like this?</div>
<div><br></div><div>Thanks,</div></div></div></div><div><span class=3D"Appl=
e-style-span" style=3D"border-collapse:collapse;color:rgb(34,34,34);font-fa=
mily:arial,sans-serif;font-size:13px">Stik</span>=A0</div></div><br></div>

--bcaec55242067c720104c3eb53ef--