[Urgent] GWT RPC requests being made to code server rather than web server in Super dev mode

413 views
Skip to first unread message

Ali

unread,
Jun 3, 2014, 7:27:21 AM6/3/14
to google-we...@googlegroups.com
I have a code server running at http://localhost:9876/, and I have a web server running at http://localhost:8081/.

If I load the nocache.js file from the web server (http://localhost:8081/), then trying to compile by clicking the bookmarklet shows 'no modules found on this page'. So, I'm fetching the .nocache.js file from the code server (http://localhost:9876/ ) instead, while the host page is on the web server.

E.g I go to http://localhost:8081/ , which has <script src="http://localhost:9876/MyModule.nocache.js" /> file .This causes compiling via bookmarklet to work.

However, when I try to make any gwt rpc requests, they are being made to http://localhost:9876/MyModule/myRequest (code server) rather than to http://localhost:8081/MyModule/myRequest ( web server). I think this is because the base url is being determined by the nocache.js file's location, rather than the host page's url. As a result, gwt rpc requests in super dev mode are not working. I get this error:

XMLHttpRequest cannot load http://localhost:9876/MyModule/myRequest. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8081' is therefore not allowed access. 

How can I resolve this issue? Is anyone able to make gwt rpc work within super dev mode, if so, how did you get it to make the requests to the web server while fetching the nocache.js file from the code server? 

This is urgent, so would really appreciate a response.

Thanks.

Thomas Broyer

unread,
Jun 3, 2014, 7:40:44 AM6/3/14
to google-we...@googlegroups.com


On Tuesday, June 3, 2014 1:27:21 PM UTC+2, Ali wrote:
I have a code server running at http://localhost:9876/, and I have a web server running at http://localhost:8081/.

If I load the nocache.js file from the web server (http://localhost:8081/), then trying to compile by clicking the bookmarklet shows 'no modules found on this page'.

Are you using the xsiframe linker?
And if you're using GWT 2.5.x, have you enabled SuperDevMode with the devModeRedirectEnabled configuratino property?
 
So, I'm fetching the .nocache.js file from the code server (http://localhost:9876/ ) instead, while the host page is on the web server.

E.g I go to http://localhost:8081/ , which has <script src="http://localhost:9876/MyModule.nocache.js" /> file .This causes compiling via bookmarklet to work.

However, when I try to make any gwt rpc requests, they are being made to http://localhost:9876/MyModule/myRequest (code server) rather than to http://localhost:8081/MyModule/myRequest ( web server). I think this is because the base url is being determined by the nocache.js file's location, rather than the host page's url.

Yes.
You can override it using a <meta> in your host page though:
<meta name="MyModule::gwt:property" content="baseUrl=http://localhost:8081/MyModule/">

But that shouldn't be necessary if you configure everything right.
 
As a result, gwt rpc requests in super dev mode are not working. I get this error:

XMLHttpRequest cannot load http://localhost:9876/MyModule/myRequest. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8081' is therefore not allowed access. 

How can I resolve this issue? Is anyone able to make gwt rpc work within super dev mode, if so, how did you get it to make the requests to the web server while fetching the nocache.js file from the code server?

1. add <add-linker name="xsiframe"/> to your gwt.xml (and if you're not using GWT 2.6.x, also add <set-configuration-property name="devModeRedirectEnabled" value="true"/>). This will enable SuperDevMode so your bookmarklet on localhost:8081 will now find the module.
2. launch your web server with -Dgwt.codeserver.port=9876 (system property, depending on your server and how you launch it, this might have to be set in some launch script or conf file). This will tell your GWT-RPC servlets to load the serialization policy files from the SuperDevMode CodeServer, so you're sure they're in-sync with the client code running in your browser (that doesn't free you from redeploying the webapp whenever you change anything to your GWT-RPC though, but frees you from having to run the GWT compiler to get up-to-date serialization policies)

Ali

unread,
Jun 3, 2014, 8:09:28 AM6/3/14
to google-we...@googlegroups.com
Hi Thomas,

Thanks for the reply.

I am using 2.6.0 and I have these settings set:

<add-linker name="xsiframe" />
  <set-configuration-property name="devModeRedirectEnabled" value="true" />
  <set-configuration-property name="gwt.superdevmode" value="on" />
  <set-property name="compiler.useSourceMaps" value="true"/>

I'm trying to set the base url as you said, via:

<meta name="MyModule::gwt:property" content="baseUrl=http://localhost:8081/MyModule" />

I have that right above the <script> tag which loads my nocache.js file. However, my rpc requests are still being made to localhost:9876 . Does setting the baseUrl not have any effect on where the rpc requests are made?

Thomas Broyer

unread,
Jun 3, 2014, 12:31:12 PM6/3/14
to google-we...@googlegroups.com


On Tuesday, June 3, 2014 2:09:28 PM UTC+2, Ali wrote:
Hi Thomas,

Thanks for the reply.

I am using 2.6.0 and I have these settings set:

<add-linker name="xsiframe" />

Then, assuming the version your deploying to your web server has been compiled with this, the bookmarks should work.
 
  <set-configuration-property name="devModeRedirectEnabled" value="true" />

This is no longer needed with 2.6+
 
  <set-configuration-property name="gwt.superdevmode" value="on" />

You shouldn't set this. CodeServer takes care of that.
Reply all
Reply to author
Forward
0 new messages