|
|
Re: Upgrade from 2.0M2 to RC2 : ajax call are not working anymore: msg#00189
java.dwr.user
|
Subject: |
Re: Upgrade from 2.0M2 to RC2 : ajax call are not working anymore |
Sorry for the delay - I've been up to my ears in work.
I've put some effort into making sure that DWR sets the correct content
type itself now. This should go into rc3. If you still have issues then
I'll give you a chart to work out the correct mime type.
Thanks,
Joe.
Thomas Manson wrote:
Hi,
I've found a way of solving the problem.
In my servlet filter which bridge my 2 webapps :
public class DwrBridgeServlet extends HttpServlet
{
private static final long serialVersionUID = -7674592154408542744L;
protected void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
{
this.getServletContext().getContext("/crf-irp-monitor").getRequestDispatcher("/dwr").include(request,
response);
}
}
I've changed the code to the following :
if(request.getRequestURI().startsWith("/crf-irp-portail/dwr"))
response.setContentType("text/plain");
this
.getServletContext().getContext("/crf-irp-monitor").getRequestDispatcher( "/dwr").include(request,
response);
I don't know what could I've changed between dwr 2.0M2 and M4 (I
had this issue on M4 and I revert to M2 so i could progress on my
application),
but by manually setting the content type, it partially solve the
problem.
Partially, because I fear I can break something by doing this.
Joe, I've seen you declare 2 other mime types in
org.directwebremoting.util.MimeConstants (Html & Js)
I feel I need to properly set the contentType so I don't break a
thing.
Is there anything in the requestUri that can tell me when I
should put text/plain, text/html or text/_javascript_ in the response
contentType ?
Also, Can you see what changes between M2 & M4 version of
DWR has break my webapp ?
Is it possible to restore the M2 behaviour on this point ?
Regards,
Manson Thomas.
On 2/9/07, Thomas
Manson <dev.mansonthomas-Re5JQEeQqe8AvxtiuMwx3w@xxxxxxxxxxxxxxxx
> wrote:
Hi,
I'm still blocked by this contentType issue and this make me
loose a lot of time :'( (I'm not blaming anyone)
I went into dwr code in debug mode, and here :
org.directwebremoting.dwrp.BaseCallMarshaller.marshallOutbound(org.directwebremoting.extend.Replies,
javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse)
On this line :
response.setContentType(getOutboundMimeType());
And after this line has been executed, when i add a watch on
getOutboundMimeType(), it returns "text/plain"
but a watch on response.getContentType() returns null.
And even if i look into the response object (on the variable
tab)
I can see that
response->response->response->coyoteResponse->contentType
is null
And wherever the coyoteResponse appear, content type is null
(it's probably the same object...)
I've a tomcat 5.5.17... i'll try with a newer, but I doubt it
will change anything...
Any Ideas ?
Regards,
Manson Thomas.
On 2/8/07, Thomas Manson <dev.mansonthomas-Re5JQEeQqe8AvxtiuMwx3w@xxxxxxxxxxxxxxxx
> wrote:
well, i've rechecked the response, and it's not the same...
don't understand why it changes...(see below for trafic dump)
but I still have the error contentType has no properties.
I've looked into the code in debug mode
I've the line :
var contentType =
batch.req.getResponseHeader("Content-Type");
in engine.js
the function returns null, but the
contentType Attribute is in batch.req.channel.contentType and its value
is "text/plain" (but channel is not readable)
Also
batch.req.getAllResponseHeaders()
gives :
Server: Apache-Coyote/1.1\nContent-Length:
95\nDate: Wed, 07 Feb 2007 23:53:07 GMT\n
There's no contentType here... so maybe
something has to be done on the serverside... ??
Now here is the traffic on the wire :
Header :
Response Headers :
| Date |
Wed, 07 Feb 2007 23:39:39 GMT |
|
Request Headers
| User-Agent |
Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1.1) Gecko/20061204
Firefox/2.0.0.1 |
| Accept |
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 |
| Accept-Language |
fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3 |
| Accept-Encoding |
gzip,deflate |
| Accept-Charset |
ISO-8859-1,utf-8;q=0.7,*;q=0.7 |
| Cookie |
JSESSIONID=1A5E63FFE841CECD2C018A10B00E9787 |
Request :
callCount=1
page=/crf-irp-monitor/monitor/out.jsp
httpSessionId=86A001E4FE8CC4937E27422B9B2031F2
scriptSessionId=D6B2910A20A7E2A881F7C2E991F22487754
c0-scriptName=Monitor
c0-methodName=getDate
c0-id=0
batchId=18
Response:
//#DWR-INSERT
//#DWR-REPLY
dwr.engine._remoteHandleCallback('18','0',"08/02/2007 00:39:39");
My _javascript_ test code :
function init()
{
DWRUtil.useLoadingMessage("Loading...");
// DWREngine.setReverseAjax(true);
updateClock = new PeriodicalExecuter(updateClock,5);
}
function updateClockReturn(clockTime)
{
DWRUtil.setValue('clock', clockTime);
}
function updateClock()
{
Monitor.getDate(updateClockReturn);
}
On 2/7/07, Thomas Manson <dev.mansonthomas-Re5JQEeQqe8AvxtiuMwx3w@xxxxxxxxxxxxxxxx
> wrote:
Hi Joe,
And
the ajax response seems to be good (but I can't see the name of the
callback function, normal ?):
//#DWR-INSERT
//#DWR-REPLY
var s0={};var s1={};var s2={};s0.autreDelegation="";s0.challengePassword=null;s0.delegation=s1;s0.idUser
=2;s0.nom="Manson";s0.numNivol="111111";s0.password=null;s0.prenom="Thomas";s0.role=s2;
s1.departement=null;s1.idDelegation=0;s1.nom=null;
s2.code=null;s2.idUserRole=2;s2.label=null;
dwr.engine._remoteHandleCallback('0','0',{coRegulateurs:null,comment:"R\u00E9gulation de Test",expectedEndDate
:new Date(1167087600000),expectedEndDateStr:"26/12/2006 12:00:00",label:"R\u00E9gulation Paris",open
:true,regulateur:s0,regulationId:2,startDate:new Date(1167001200000),startDateStr:"25/12/2006 12:00:00"
}
Is this what you want ? (i'm not
sure whete the FB console is. here is the content of the
NET->XHR->Response)
Regards,
Manson Thomas.
Do you have FireBug installed?
Could you tell me what the reply was that you were getting on the wire
using the FB console?
Thanks.
Joe.
On 2/6/07, Thomas Manson <dev.mansonthomas-Re5JQEeQqe8AvxtiuMwx3w@xxxxxxxxxxxxxxxx
> wrote:
Hi,
Joe, any thought about making an exception for
localhost about CSRF attack protection ?
Nobody did have the error about contentType on the
client side ?
Regards,
Manson Thomas.
On 2/2/07, Thomas Manson <dev.mansonthomas-Re5JQEeQqe8AvxtiuMwx3w@xxxxxxxxxxxxxxxx
> wrote:
Don't
know why I didn't notice this before but I do have logs ;)
A request has been denied as a potential CSRF attack
I think the origin of this error is because my application runs on two
webapp (in order to have jsf and spring webflow working all together)
The ajax part of the application is in the 'crf-irp-monitor', but links
to js points to the other webapp (portal) 'crf-irp-portal'.
(I wanted to have only one webapp to be exposed to the client)
A servlet filter makes the bridge between webapps :
public class DwrBridgeServlet extends HttpServlet
{
private static final long serialVersionUID = -7674592154408542744L;
protected void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
{
this.getServletContext().getContext("/crf-irp-monitor").getRequestDispatcher("/dwr").include(request,
response);
}
}
If I add
<init-param>
<param-name>crossDomainSessionSecurity</param-name>
<param-value>false</param-value>
</init-param>
to the web.xml, there's no more Security exception but at the price of
security drawbacks (and also I've another error)
In my case it's localhost (ie the server itself) that makes the
request...
is it possible to allow localhost (Is there possible security breach
with localhost (ie the server itself)?
or specify some exception in order this exception Secruty exception is
not raised ?
Also what is strange it's that my tomcat and my firefox are on the same
computer so domain are the same... it should work, shouldn't it?
Now I've this error :
contentType has no Properties
it happens in engine.js
try {
645 for (prop in batch.headers) {
646 var value = batch.headers[prop];
647 if (typeof value == "string")
batch.req.setRequestHeader(prop, value);
649 if (!batch.headers["Content-Type"])
batch.req.setRequestHeader("Content-Type", "text/plain");
652 dwr.engine._handleWarning(batch,
ex);
And the ajax response seems to be good (but I can't see the name of the
callback function, normal ?):
//#DWR-INSERT
//#DWR-REPLY
var s0={};var s1={};var s2={};s0.autreDelegation="";s0.challengePassword=null;s0.delegation=s1;s0.idUser
=2;s0.nom="Manson";s0.numNivol="111111";s0.password=null;s0.prenom="Thomas";s0.role=s2;
s1.departement=null;s1.idDelegation=0;s1.nom=null;
s2.code=null
;s2.idUserRole=2;s2.label=null;
dwr.engine._remoteHandleCallback('0','0',{coRegulateurs:null,comment:"R\u00E9gulation de Test",expectedEndDate
:new Date(1167087600000),expectedEndDateStr:"26/12/2006 12:00:00",label:"R\u00E9gulation Paris",open
:true,regulateur:s0,regulationId:2,startDate:new Date(1167001200000),startDateStr:"25/12/2006 12:00:00"
});
Any Idea with the contentType issue ?
Regards,
Manson Thomas.
On 1/30/07, Joe Walker < joe-klYz7rYGnPJ7dT6CjAjUyw@xxxxxxxxxxxxxxxx
> wrote:
I can't think of anything obvious. I can only suggest taking a good
look at the logs and looking at the XHR monitor in firebug to see what
is getting sent and received.
Joe.
On 1/30/07, Thomas Manson <dev.mansonthomas-Re5JQEeQqe8AvxtiuMwx3w@xxxxxxxxxxxxxxxx
> wrote:
Hi,
No I didn't enabled pollAndCometEnabled. I'll
look at the dwr servlet option (I didn't noticed them untill now ;)
Also it's classical ajax call that are not
working (I can't get to reverse ajax part until classical ajax call are
working.
Thanks for help.
Regards,
Manson Thomas.
On 1/30/07, Joe Walker <joe-klYz7rYGnPJ7dT6CjAjUyw@xxxxxxxxxxxxxxxx
> wrote:
have you enabled pollAndCometEnabled?
http://getahead.ltd.uk/dwr/server/servlet
Is there anything that might help on the server console?
Joe.
On 1/29/07, Thomas Manson <dev.mansonthomas-Re5JQEeQqe8AvxtiuMwx3w@xxxxxxxxxxxxxxxx
> wrote:
Hi,
My Application is working fine on M2, i've
switched to RC2, make some change (ScriptBuffer appear ...) to my java
code, clear my browser cache.
And now, the ajax part is not working
anymore.
When I look with firebug, the call to the
js dwr interface is done, but it doesn't reach the server side.
Is there anything obvious that was needed
to be done that I miss ? Security conf change ?
Regards,
Manson Thomas.
|
| |