Runtime exception: com.google.web.bindery.requestfactory.server.UnexpectedException: Could not find static method with a single parameter of a key type

889 views
Skip to first unread message

Ashu

unread,
Apr 23, 2012, 7:51:48 AM4/23/12
to google-we...@googlegroups.com
Hi,
 
I am getting the above exception while running the GWT application.
 
I am using Entity and EntityProxies.
 
Below is the code:
 
@Entity
@Table(name = "tlkpState")
public class State{
.................
}
@ProxyFor(value = State.class)
public interface StateProxy extends EntityProxy {
 
 public String getFips();
 public String getName();
 EntityProxyId<StateProxy> stableId();
}
@Service(value = StateServiceImpl.class)
 public interface StateRequest extends RequestContext {
  Request<List<StateProxy>> getStates() throws Exception;
  //Request<Void> getStates() throws Exception;
 }
in widget.java
try {
   clientFactory.getRequestFactory().stateRequestContext().getStates().fire(new Receiver<List<StateProxy>>(){
    @Override
    public void onSuccess(List<StateProxy> response) {
     // TODO Auto-generated method stub
     System.out.println("on success");
    }
    
     @Override
                 public void onFailure(ServerFailure error) {
                     System.out.println("on Failure");
                 }
   });
  } catch (Exception e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
 
when i call getstate() method with return type void it is working fine.
but the same method with return type List<StateProxy> it is throwing the following exception:
 
 

com.google.web.bindery.requestfactory.server.UnexpectedException

: Could not find static method with a single parameter of a key type

at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.die(

ServiceLayerDecorator.java:216)

at com.google.web.bindery.requestfactory.server.ReflectiveServiceLayer.getFind(

ReflectiveServiceLayer.java:253)

at com.google.web.bindery.requestfactory.server.ReflectiveServiceLayer.getFind(

ReflectiveServiceLayer.java:271)

at com.google.web.bindery.requestfactory.server.ReflectiveServiceLayer.getFind(

ReflectiveServiceLayer.java:271)

at com.google.web.bindery.requestfactory.server.ReflectiveServiceLayer.isLive(

ReflectiveServiceLayer.java:200)

at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.isLive(

ServiceLayerDecorator.java:116)

at com.google.web.bindery.requestfactory.server.LocatorServiceLayer.doIsLive(

LocatorServiceLayer.java:186)

at com.google.web.bindery.requestfactory.server.LocatorServiceLayer.isLive(

LocatorServiceLayer.java:85)

at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.isLive(

ServiceLayerDecorator.java:116)

at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.createReturnOperations(

SimpleRequestProcessor.java:274)

at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.process(

SimpleRequestProcessor.java:232)

at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.process(

SimpleRequestProcessor.java:127)

at com.google.web.bindery.requestfactory.server.RequestFactoryServlet.doPost(

RequestFactoryServlet.java:133)

at javax.servlet.http.HttpServlet.service(

HttpServlet.java:637)

at javax.servlet.http.HttpServlet.service(

HttpServlet.java:717)

at org.mortbay.jetty.servlet.ServletHolder.handle(

ServletHolder.java:487)

at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(

ServletHandler.java:1097)

at com.yieldstar.mpfui.server.MpfAuthFilter.doFilter(

MpfAuthFilter.java:41)

at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(

ServletHandler.java:1088)

at org.mortbay.jetty.servlet.ServletHandler.handle(

ServletHandler.java:360)

at org.mortbay.jetty.security.SecurityHandler.handle(

SecurityHandler.java:216)

at org.mortbay.jetty.servlet.SessionHandler.handle(

SessionHandler.java:181)

at org.mortbay.jetty.handler.ContextHandler.handle(

ContextHandler.java:729)

at org.mortbay.jetty.webapp.WebAppContext.handle(

WebAppContext.java:405)

at org.mortbay.jetty.handler.HandlerWrapper.handle(

HandlerWrapper.java:152)

at org.mortbay.jetty.handler.RequestLogHandler.handle(

RequestLogHandler.java:49)

at org.mortbay.jetty.handler.HandlerWrapper.handle(

HandlerWrapper.java:152)

at org.mortbay.jetty.Server.handle(

Server.java:324)

at org.mortbay.jetty.HttpConnection.handleRequest(

HttpConnection.java:505)

at org.mortbay.jetty.HttpConnection$RequestHandler.content(

HttpConnection.java:843)

at org.mortbay.jetty.HttpParser.parseNext(

HttpParser.java:647)

at org.mortbay.jetty.HttpParser.parseAvailable(

HttpParser.java:211)

at org.mortbay.jetty.HttpConnection.handle(

HttpConnection.java:380)

at org.mortbay.io.nio.SelectChannelEndPoint.run(

SelectChannelEndPoint.java:395)

at org.mortbay.thread.QueuedThreadPool$PoolThread.run(

QueuedThreadPool.java:488)

 

I am using gwt 2.4 version.

Not using locators.

could any one help on this.

 

Thanks

Thomas Broyer

unread,
Apr 23, 2012, 8:00:51 AM4/23/12
to google-we...@googlegroups.com
Your State class probably do not have a "public static state findState(X id)" method (where X is the return type of the getId instance method).
The alternative to the static method is to use a Locator.

Ashu

unread,
Apr 23, 2012, 8:14:38 AM4/23/12
to google-we...@googlegroups.com
Thanks for the quick reply!!
what is the use of this method and this class return type is my State class. how can i write that?
could you please give me more information about this?

Thomas Broyer

unread,
Apr 23, 2012, 10:09:19 AM4/23/12
to google-we...@googlegroups.com

On Monday, April 23, 2012 2:14:38 PM UTC+2, Ashu wrote:
Thanks for the quick reply!!
what is the use of this method and this class return type is my State class. how can i write that?
could you please give me more information about this?

The find method should load your entity from your datastore, given its ID. 

Ashu

unread,
Apr 25, 2012, 5:34:56 AM4/25/12
to google-we...@googlegroups.com
could you please provide me the sample findby....() method for reference?

Thomas Broyer

unread,
Apr 25, 2012, 5:48:21 AM4/25/12
to google-we...@googlegroups.com


On Wednesday, April 25, 2012 11:34:56 AM UTC+2, Ashu wrote:
could you please provide me the sample findby....() method for reference?

Ashu

unread,
Apr 25, 2012, 6:22:40 AM4/25/12
to google-we...@googlegroups.com
  now i am getting the runtime exception for EMF class
 
Server Error: Could not initialize class com.....................shared.EMF 
 
 

On Monday, 23 April 2012 17:21:48 UTC+5:30, Ashu wrote:

Ashu

unread,
Apr 27, 2012, 5:37:48 AM4/27/12
to google-we...@googlegroups.com
How to initialize entity manager here
Iam not able to intialize this.
 
Could you please help me on this?

On Monday, 23 April 2012 17:21:48 UTC+5:30, Ashu wrote:

Thomas Lefort

unread,
Apr 27, 2012, 1:03:26 PM4/27/12
to google-we...@googlegroups.com
You do have to read the doc carefully indeed. I got stuck for a little while, I thought I could get away by simply using "find" but no you need to use "findEntity", ie replace Entity by your entity name. This got me, because at first it worked with a single entity, but when I had two entities with relationships, it wouldn't work anymore. By changing the method names to respect the convention mentioned above, it worked fine.
Reply all
Reply to author
Forward
0 new messages