User defined classes as RPC parameters

2 views
Skip to first unread message

Arif

unread,
Apr 21, 2008, 5:59:44 PM4/21/08
to Google Web Toolkit
CODE LOOK LIKE THIS:

///////////////////////////////////////////////////////////////////////////////////////
public class Person implements IsSerializable {


private String firstName;
private String lastName;

public Person(){}
public Person(String f, String l){
firstName = f;
lastName = l;
}

public String getFirstName() {
return firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

}

////////////////////////////////////////////////////////////////

import com.google.gwt.user.client.rpc.IsSerializable;

public class Group implements IsSerializable {

/**
* @gwt.typeArgs <com.ni.client.mhe.Person>
*/
private Collection persons = new ArrayList();

private String name = new String("Student");

public Group(){}

public Collection getPersons() {
return persons;
}
public void setPersons(Collection persons) {
this.persons = persons;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}

/////////////////////////////////////////////////////////////////////////////////

public interface MyService extends RemoteService {

public Person myMethod(Group g);
}

//////////////////////////////////////////////////////////////////////////////////

public class MyServiceImpl extends RemoteServiceServlet implements
MyService {


public Person myMethod(Group g) {
// Do something interesting with 's' here on the server.
Person last = null;
Iterator iter = g.getPersons().iterator();
while (iter.hasNext()) {
last = (Person)iter.next();
}

return last;
}

}

/////////////////////////////////////////////////////////////////////////////////////


Group g = new Group();
g.getPersons().add(new Person("Arif", "Saikat"));
g.getPersons().add(new Person("Moka", "Hossain"));
g.getPersons().add(new Person("Fahim", "Kowser"));

myService.myMethod(g, callback);


//////////////////////////////////////////////////////////////////

At the line
myService.myMethod(g, callback);
I get the following error:


////////////////////////////////////////////



Analyzing permutation #1
[ERROR] An internal compiler exception occurred
com.google.gwt.dev.jjs.InternalCompilerException: Unexpected error
during visit.

at
com.google.gwt.dev.js.ast.JsVisitor.translateException(JsVisitor.java
:408)
at
com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:399)
at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:
385)
at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:
61)
at
com.google.gwt.dev.js.JsToStringGenerationVisitor.visit(JsToStringGen
erationVisitor.java:164)
at
com.google.gwt.dev.js.ast.JsBinaryOperation.traverse(JsBinaryOperatio
n.java:61)
at
com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:397)
at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:
385)
at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:
61)
at
com.google.gwt.dev.js.JsToStringGenerationVisitor.visit(JsToStringGen
erationVisitor.java:246)
at
com.google.gwt.dev.js.ast.JsConditional.traverse(JsConditional.java:6
4)
at
com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:397)
at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:
385)
at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:
61)
at
com.google.gwt.dev.js.JsToStringGenerationVisitor.visit(JsToStringGen
erationVisitor.java:631)
at com.google.gwt.dev.js.ast.JsReturn.traverse(JsReturn.java:
41)
at
com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:397)
at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:
385)
at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:
69)
at
com.google.gwt.dev.js.JsToStringGenerationVisitor.printJsBlockOptiona
lTruncate(JsToStringGenerationVisitor.java:749)
at
com.google.gwt.dev.js.JsSourceGenerationVisitor.visit(JsSourceGenerat
ionVisitor.java:38)
at com.google.gwt.dev.js.ast.JsBlock.traverse(JsBlock.java:37)
at
com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:397)
at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:
385)
at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:
69)
at
com.google.gwt.dev.js.JsToStringGenerationVisitor.visit(JsToStringGen
erationVisitor.java:437)
at
com.google.gwt.dev.js.ast.JsFunction.traverse(JsFunction.java:71)
at
com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:397)
at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:
385)
at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:
61)
at
com.google.gwt.dev.js.JsToStringGenerationVisitor.visit(JsToStringGen
erationVisitor.java:338)
at
com.google.gwt.dev.js.ast.JsExprStmt.traverse(JsExprStmt.java:34)
at
com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:397)
at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:
385)
at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:
69)
at
com.google.gwt.dev.js.JsToStringGenerationVisitor.printJsBlockOptiona
lTruncate(JsToStringGenerationVisitor.java:749)
at
com.google.gwt.dev.js.JsSourceGenerationVisitor.visit(JsSourceGenerat
ionVisitor.java:38)
at com.google.gwt.dev.js.ast.JsBlock.traverse(JsBlock.java:37)
at
com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:397)
at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:
385)
at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:
69)
at com.google.gwt.dev.js.ast.JsProgram.traverse(JsProgram.java:
144)
at
com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:397)
at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:
385)
at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:
65)
at
com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.compile(JavaToJavaScr
iptCompiler.java:404)
at
com.google.gwt.dev.GWTCompiler.realizePermutation(GWTCompiler.java:68
8)
at
com.google.gwt.dev.GWTCompiler.compilePermutations(GWTCompiler.java:4
11)
at com.google.gwt.dev.GWTCompiler.distill(GWTCompiler.java:
335)
at com.google.gwt.dev.GWTCompiler.run(GWTCompiler.java:755)
at com.google.gwt.dev.GWTCompiler.run(GWTCompiler.java:745)
at com.google.gwt.dev.GWTCompiler.main(GWTCompiler.java:213)
Caused by: java.lang.OutOfMemoryError: Java heap space
[ERROR] Out of memory; to increase the amount of memory, use
the -Xmx f
lag at startup (java -Xmx128M ...)
[ERROR] <no source info>: a === undefined
com.google.gwt.dev.js.ast.JsBinaryOperation
[ERROR] <no source info>: a == null || a === undefined
com.google.gwt.dev.js.ast.JsBinaryOperation
[ERROR] <no source info>: a == null || a === undefined?
false:true
com.google.gwt.dev.js.ast.JsConditional
[ERROR] <no source info>: return a == null || a === undefined?
false:tru
e
com.google.gwt.dev.js.ast.JsReturn
[ERROR] <no source info>: {
ax();
var a = $wnd.Ext.ComponentMgr.get(b);
return a == null || a === undefined?false:true;
}

com.google.gwt.dev.js.ast.JsBlock
[ERROR] <no source info>: function iy(b){
ax();
var a = $wnd.Ext.ComponentMgr.get(b);
return a == null || a === undefined?false:true;
}

com.google.gwt.dev.js.ast.JsFunction
[ERROR] <no source info>: function iy(b){
ax();
var a = $wnd.Ext.ComponentMgr.get(b);
return a == null || a === undefined?false:true;
}

com.google.gwt.dev.js.ast.JsExprStmt
[ERROR] <no source info>: var _, o_ =
'com.google.gwt.core.client.', p_
= 'com.google.gwt.lang.', q_ = 'com.google.gwt.user.client.', r_ =
'com.google.
gwt.user.client.impl.', s_ = 'com.google.gwt.user.client.rpc.', t_ =
'com.google
.gwt.user.client.rpc.core.java.lang.', u_ =
'com.google.gwt.user.client.rpc.core
.java.util.', v_ = 'com.google.gwt.user.client.rpc.impl.', w_ =
'com.google.gwt.
user.client.ui.', x_ = 'com.gwtext.client.core.', y_ =
'com.gwtext.client.data.'
, z_ = 'com.gwtext.client.dd.', A_ = 'com.gwtext.client.util.', B_ =
'com.gwtext
.client.widgets.', C_ = 'com.gwtext.client.widgets.event.', D_ =
'com.gwtext.cli
ent.widgets.form.', E_ = 'com.gwtext.client.widgets.grid.', F_ =
'com.gwtext.cli
ent.widgets.layout.', aab = 'com.gwtext.client.widgets.menu.', bab =
'com.gwtext
.client.widgets.menu.event.', cab = 'com.gwtext.client.widgets.tree.',
dab = 'co
m.gwtext.client.widgets.tree.event.', eab = 'com.ni.client.mhe.', fab
= 'java.io
.', gab = 'java.lang.', hab = 'java.util.';
function n_(){
}

function z3(a){
return this === a;
}

function A3(){
return c5(this);
}

[...]

com.google.gwt.dev.js.ast.JsGlobalBlock
[ERROR] <no source info>: <JsProgram>
com.google.gwt.dev.js.ast.JsProgram
[ERROR] Build failed


///////////////////////


Basically I am sedning an obejct of type Group that has a collection
of type Person to my servce that returns the name of the last person
in the group. It is just a test app. Any idea what is the reson of the
error?

gregor

unread,
Apr 21, 2008, 7:11:55 PM4/21/08
to Google Web Toolkit
Hi Arif,

Caused by: java.lang.OutOfMemoryError: Java heap space
[ERROR] Out of memory; to increase the amount of memory, use
the -Xmx f
lag at startup (java -Xmx128M ...)

You will need to either figure out why you are using so much memory or
instruct the GWT shell to use a bigger heap (e.g. -Xmx128M).

regards
gregor

Pavel Byles

unread,
Apr 21, 2008, 9:35:25 PM4/21/08
to Google-We...@googlegroups.com
Where's the Async interface? ... Maybe you have it but I just didn't see async interface code posted.

import com.google.gwt.user.client.rpc.AsyncCallback;
public interface MyServiceAync {
  public void myMethod(Group g, AsyncCallback callback);
}

-Pavel

Arif

unread,
Apr 22, 2008, 12:06:13 PM4/22/08
to Google Web Toolkit
thanks a lot Gregor, that fixed it.
> ...
>
> read more »

Arif

unread,
Apr 22, 2008, 12:06:51 PM4/22/08
to Google Web Toolkit
I have it defined in code, but forgot to put it there. Thanks for your
help Pavel.
> ...
>
> read more »
Reply all
Reply to author
Forward
0 new messages