working with GWT and PHP in the development mode

18 views
Skip to first unread message

antipattern

unread,
Mar 4, 2010, 2:30:25 PM3/4/10
to Google Web Toolkit
hello all,
i've recently started working with GWT and i want to use PHP on the
server side. now, my php code is hosted on a local web server and my
GWT modules are not able to make ne http requests to the same in the
development mode. it works correctly when i compile the project and
host it on the web server too but this doesnt allow me to debug the
application in the same way. i've figured that this is because of the
SOP (pls tellme if im wrong). ive tried using IE but the GWT developer
plugin wont install on IE and IE crashes everytime i try to do so. Ive
also tried disabling the in built server and use the local web server
but that doesnt seem to solve the problem.
this is the error im geting when i try to uncheck the built in server

00:49:01.879 [ERROR] [testing] Uncaught exception escaped
com.google.gwt.core.client.JavaScriptException:
(NS_ERROR_NOT_AVAILABLE): Component returned failure code: 0x80040111
(NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.statusText]
QueryInterface: function QueryInterface() {
[native code]
}
result: 2147746065
filename: http://127.0.0.1
lineNumber: 92
columnNumber: 0
inner: null
data: null
initialize: function initialize() {
[native code]
}
at
com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:
195)
at
com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:
120)
at
com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:
507)
at
com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:
264)
at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:
91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:188)
at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at
com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at
com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:
157)
at
com.google.gwt.dev.shell.BrowserChannel.reactToMessages(BrowserChannel.java:
1668)
at
com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:
401)
at
com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:
222)
at java.lang.Thread.run(Unknown Source)

can someone please help me out? (either help me install GWT developer
plugin on IE or show me some way to integrate GWT with php in
develoment mode)

thanx in advance

Sarvpriye

riasol

unread,
Mar 5, 2010, 3:49:58 PM3/5/10
to Google Web Toolkit
I work on gwt/php debuger together. This is great. My notes there:
http://wordpress.robwas.homelinux.net/2010/02/19/gwt-integracja/

mibtar

unread,
Mar 6, 2010, 12:29:09 PM3/6/10
to Google Web Toolkit
maybe you should just use firefox?

are you using eclipse or netbeans?

gwt php in eclipse:

suppose your apache's webroot is "c:\www"
and you created your project in "c:\www\apps\"
and your project name is "mytest"

so your project is gonna have these directories:
c:\www\apps\mytest\src
c:\www\apps\mytest\test
c:\www\apps\mytest\war

you place your php files in the war folder

test.php:

<?php
echo "hello";
?>

and in your java code, let's say you have this method to test:

public void testphp(){
try
{
RequestBuilder builder = new
RequestBuilder(RequestBuilder.POST, GWT.getHostPageBaseURL()
+"test.php");
builder.setHeader("Content-Type", "application/x-www-form-
urlencoded");
builder.sendRequest("", new RequestCallback()
{
@Override
public void onError(Request request, Throwable ex)
{
Window.alert(ex.toString());
}

@Override
public void onResponseReceived(Request request, Response
response)
{
Window.alert("PHP output: " +
response.getText());
}
});
}
catch (RequestException e)
{
Window.alert(e.toString());
}
}

in the project explorer of eclipse, right click your project and
choose properties.
click Run/Debug Settings.
choose your project and click edit.
remove the check in run built-in server and change the port to 80.

run the project. copy the link in the "development mode" window and
paste it in the browser's address bar.
when you open the link, it will display a page not found error.
because you really don't have a mytest.html in
the root of your www folder.

the link looks like this:
http://127.0.0.1/mytest.html?gwt.codesvr=127.0.0.1:9997

copy "?gwt.codesvr=127.0.0.1:9997" from the link

mytest.html is really in:
http://localhost/apps/mytest/war/mytest.html

paste the end of the previous link to the new link so it looks like
this:
http://localhost/apps/mytest/war/mytest.html?gwt.codesvr=127.0.0.1:9997

now you can simply refresh the page to view any changes made to your
java and php code.
no need to compile or run.

Marcello Nuccio

unread,
Mar 30, 2010, 5:03:37 AM3/30/10
to Google Web Toolkit
It is also possible to use the embedded Jetty server.

Here's how I do it:

1) install "Eclipse for PHP Developers" from http://www.eclipse.org/downloads/

2) install "Google Plugin for Eclipse" adding to eclipse the update
site http://dl.google.com/eclipse/plugin/3.5

3) create a "New Web Application Project"

4) edit war/WEB-INF/web.xml of newly created project and add the
following snippet (let's hope to get nice formatting... :-).
IMPORTANT NOTE: this is assuming you have php5-cgi executable
installed (in Ubuntu install php5-cgi package). Change it to suite
your setup.

<code>
<pre>

<servlet>
<servlet-name>PHP Servlet</servlet-name>
<servlet-class>org.mortbay.servlet.CGI</servlet-class>
<init-param>
<param-name>commandPrefix</param-name>
<param-value>php5-cgi</param-value>
</init-param>
</servlet>

<servlet-mapping>
<servlet-name>PHP Servlet</servlet-name>
<url-pattern>*.php</url-pattern>
</servlet-mapping>

</pre>
</code>


5) create a new PHP file in project's war folder (e.g. phpinfo.php)

6) run the project as "Web Application"

7) browse to http://127.0.0.1:8888/phpinfo.php

bye,
Marcello Nuccio

On 6 Mar, 19:29, mibtar <bim.pangili...@gmail.com> wrote:
> maybe you should just use firefox?
>
> are you using eclipse or netbeans?
>

> gwtphpin eclipse:


>
> suppose your apache's webroot is "c:\www"
> and you created your project in "c:\www\apps\"
> and your project name is "mytest"
>
> so your project is gonna have these directories:
> c:\www\apps\mytest\src
> c:\www\apps\mytest\test
> c:\www\apps\mytest\war
>

> you place yourphpfiles in the war folder


>
> test.php:
>
> <?php
>    echo "hello";
> ?>
>
> and in your java code, let's say you have this method to test:
>
> public void testphp(){
>         try
>     {
>         RequestBuilder builder = new
> RequestBuilder(RequestBuilder.POST, GWT.getHostPageBaseURL()
> +"test.php");
>         builder.setHeader("Content-Type", "application/x-www-form-
> urlencoded");
>         builder.sendRequest("", new RequestCallback()
>         {
>             @Override
>             public void onError(Request request, Throwable ex)
>             {
>                 Window.alert(ex.toString());
>             }
>
>             @Override
>             public void onResponseReceived(Request request, Response
> response)
>             {

>                 Window.alert("PHPoutput: " +

Reply all
Reply to author
Forward
0 new messages