2012-07-25 45 views
0

我有一个maven + spring + gwt项目,我想使用请求工厂。我无法弄清楚为什么我会得到这个例外。GWT的RequestFactory发射请求时出错:org.springframework.beans.factory.NoSuchBeanDefinitionException

要求工厂:

public interface StarRequestFactory extends RequestFactory { 

@Service(value = RaduService.class, locator = GWTServiceLocator.class) 
public interface RaduRequestContext extends RequestContext { 
     Request<Void> save(); 
    } 

RaduRequestContext raduRequestcontext(); 
} 

服务:

public class RaduService { 

    public void save(){ 
    System.out.println("You have saved."); 
    } 

} 

定位:

public class GWTServiceLocator implements ServiceLocator, 
    ApplicationContextAware { 
    private ApplicationContext context; 

    @Override 
    public Object getInstance(Class<?> clazz) { 
    return context.getBean(clazz); 
    } 

    @Override 
    public void setApplicationContext(ApplicationContext context) 
     throws BeansException { 
    this.context = context; 
    } 

} 

在我的入口点类我发出请求:

requestFactory.raduRequestcontext().save().fire(new Receiver<Void>() { 

     @Override 
     public void onSuccess(Void response) { 
      System.out.println("Success"); 

     } 
    }); 

在这一请求,我得到以下错误:

[错误] IUL 25,2012下午3点35分36秒com.google.web.bindery.requestfactory.server.RequestFactoryServlet的doPost [错误]重度:意外错误 [错误] org.springframework.beans.factory.NoSuchBeanDefinitionException:没有定义[com.base.star.shared.services.StarRequestFactory $ RaduRequestContext]类型的唯一bean:期望的单一bean,但找到0: [ERROR] at org.springframework.context.support.AbstractApplicationContext.getBean [AbstractApplicationContext.java:1083] [ERROR] at [org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:269) [ERROR] at com.base.star.server.integration.GWTServiceLocator.getInstance(GWTServiceLocator.java:25) [ERROR]在com.base.star.server.integration.GWTServiceLayerDecorator.createServiceInstance(GWTServiceLayerDecorator.java:43) [ERROR]在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法) [ERROR]在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [ERROR]在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [错误]在java.lang.reflect.Method.invoke(Method.java:601) [ERROR]在com.google.web.bindery.requestfactory.server.ServiceLayerCache.getOrCache(ServiceLayerCache.java:233) [ERROR ]在com.google.web.bindery.requestfactory.server.ServiceLayerCache.createServiceInstance(ServiceLayerCache.java:117)在com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.processInvocationMessages(SimpleRequestProcessor.java:451) [ERROR] com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.process(SimpleRequestProcessor。 java:225) [ERROR] at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.process(SimpleRequestProcessor.java:127) .................. ........................................

有谁知道这是什么关于 ?

如果需要,我可以发布pom。

回答

1

似乎是一个春天错误:

你有没有注解你RaduService@Service或在你的applicationContext.xml文件作为一个bean定义的呢?

+0

我已经在ApplicationContext.xml中将它定义为: 2012-07-25 14:26:09

+0

调试你的服务cod并在你的GWTServiceLocator的''public Object getInstance(Class clazz)''中放置一个断点,并检查它试图实例化的东西 – 2012-07-25 14:40:57

+0

它尝试实例化:interface com .base.star.shared.services.StarRequestFactory $ RaduRequestContext。 – 2012-07-25 15:06:59