Search code examples
springgwtresttemplategwt-compiler

How to make Interaction with GWT - Spring RestTemplate


This is the continuation of issue

I'm currently working on a task where it has GWT, Restful and Spring Framework environment.

It has two application; Application #1 which expose some information through Restful Webservice and Application #2 which consume that service and display those details in GWT.

For Application #2, I have used Spring RestTemplate to consume the Restful Webservice and return backs the List of Details through an Interface. And at the GWT end, there was some DataListProvider to set the Data List in GWT-DataGrid.

Now the problem is, I doesn't know how to make the interaction with GWT DataListProvider with my DetailService Class(this returns the List<Details> in a method). When I directly call the Service Class in GWT- OnModule() method, during GWT Compile, i'm facing some UnResolved Type Error, Since this class indirectly calls the Spring Libraries classes, thus GWT cannot compile this.

com.google.gwt.dev.jjs.InternalCompilerException: Failed to get JNode
    at com.google.gwt.dev.jjs.impl.TypeMap.get(TypeMap.java:140)
    at com.google.gwt.dev.jjs.impl.TypeMap.get(TypeMap.java:71)
    at com.google.gwt.dev.jjs.impl.BuildTypeMap.getType(BuildTypeMap.java:730)
    at com.google.gwt.dev.jjs.impl.BuildTypeMap.createField(BuildTypeMap.java:570)
    at com.google.gwt.dev.jjs.impl.BuildTypeMap.access$300(BuildTypeMap.java:99)
    at com.google.gwt.dev.jjs.impl.BuildTypeMap$BuildDeclMapVisitor.visit(BuildTypeMap.java:180)
    at org.eclipse.jdt.internal.compiler.ast.FieldDeclaration.traverse(FieldDeclaration.java:285)
    at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1232)
    at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:687)
    at com.google.gwt.dev.jjs.impl.BuildTypeMap.createPeersForNonTypeDecls(BuildTypeMap.java:637)
    at com.google.gwt.dev.jjs.impl.BuildTypeMap.exec(BuildTypeMap.java:514)
    at com.google.gwt.dev.jjs.impl.BuildTypeMap.exec(BuildTypeMap.java:523)
    at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.precompile(JavaToJavaScriptCompiler.java:599)
    at com.google.gwt.dev.jjs.JavaScriptCompiler.precompile(JavaScriptCompiler.java:33)
    at com.google.gwt.dev.Precompile.precompile(Precompile.java:284)
    at com.google.gwt.dev.Precompile.precompile(Precompile.java:233)
    at com.google.gwt.dev.Precompile.precompile(Precompile.java:145)
    at com.google.gwt.dev.Compiler.run(Compiler.java:232)
    at com.google.gwt.dev.Compiler.run(Compiler.java:198)
    at com.google.gwt.dev.Compiler$1.run(Compiler.java:170)
    at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:88)
    at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:82)
    at com.google.gwt.dev.Compiler.main(Compiler.java:177)
      [ERROR] <no source info>: public class org.springframework.web.client.RestTemplate
    extends org.springframework.http.client.support.InterceptingHttpAccessor
    implements : Unresolved type org.springframework.web.client.RestOperations

Please provide your suggestion how to make an interaction between these Service Class and GWT.


Solution

  • You cannot have Spring in client side code.

    Options available are:

    A callback in a presenter where an asynchronous interface makes a GWT-RPC call to a service controller (on server-side of App#2). You could have an @RequestMapping annotated method whose internals employ the RestTemplate.

    Have the presenter employ a RequestFactory and make use of GWT overlay feature for your payload.