I'm having problem running GWT local server on Eclipse 3.6 when the
Spring bean is in a separate java project.  But when the project is
built as a war file and deployed to Tomcat, things are Okay.  It
appears to me that GWT local server engine cannot find the *.class in
the Java project/bin directory.  I tried setting the classpath in the
launch configuration but nothing works.
Any help?

MyJavaProject
  com.company.service.MyDaoService.java
  test-context.xml
  @Service("myDaoService")
  public class MyDaoService
  {
     ...
  }

MyWeb
  com.company.server.MyServiceImpl.java
  public class MyServiceImpl
  {
    public List<String> getList()
    {
        ApplicationContext applicationContext =
 
WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
        MyDaoService dataService =
            (MyDaoService) applicationContext.getBean("myDaoService");
        ...
    }
  }

Web.xml
  <context-param>
    <param-name>contextConfigLocation</param-name>
       <param-value>classpath*:test-context.xml</param-value>
  </context-param>

  <listener>
    <listener-
class>org.springframework.web.context.ContextLoaderListener</listener-
class>
  </listener>

I got the following error:
   [WARN] Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method
'public abstract java.util.List
com.company.client.MyService.getList()' threw an unexpected exception:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No
bean named 'myDaoService' is defined
        at
com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:
378)
        at
com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:
581)
        at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:
188)
        at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:
224)
        at
com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:
62)
        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.handle(ServletHandler.java:
362)
        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:205)
        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)
Caused by:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No
bean named 'myDaoService' is defined
        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:
509)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:
1041)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:
273)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:
189)
        at
org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:
1044)
        at com.company.server.MyServiceImpl.getList(MyServiceImpl.java:32)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at
com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:
562)
        ... 22 more

The funny thing is that if I changed the web.xml (remove *) and copy
the test-context.xml to the /bin folder.
  <context-param>
    <param-name>contextConfigLocation</param-name>
       <param-value>classpath:test-context.xml</param-value>
  </context-param>

I got this warning message while running the local server.  But now
the application works without a problem.
[WARN] Server resource 'test-context.xml' could not be found in the
web app, but was found on the system classpath
   [WARN] Adding classpath entry 'file:/C:/workspace/MyJavaProject/
bin/' to the web app classpath for this session
   For additional info see: file:/C:/Program%20Files/eclipse/plugins/
com.google.gwt.eclipse.sdkbundle.2.0.4_2.0.4.v201006301309/gwt-2.0.4/
doc/helpInfo/webAppClassPath.html

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to