My service is a simple POJO with 3 methods.
public interface ActivityService extends RemoteService {
public List<ActivityDTO> listActivities();
public void deleteActivity(Long activityId);
public void addActivity(String name, String activityData);
}
I define the DispatcherServlet to look for URL's of the form /services/
*
<servlet>
<servlet-name>services</servlet-name>
<servlet-
class>org.springframework.web.servlet.DispatcherServlet</servlet-
class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>services</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
Then in services-servlet.xml define the mappings that GWTHandler
should look for:
<bean id="urlMapping"
class="org.gwtwidgets.server.spring.GWTHandler">
<property name="mappings">
<map>
<entry key="/services/activityService" value-
ref="activityService"/>
</map>
</property>
</bean>
"activityService" is defined in a separately loaded Spring
configuration using ContextLoaderListener. This loads a bunch of
other beans, including the service bean and wires them all up.
Finally, in my application, I instantiate an ActivityServiceAsync and
give it the entry point:
target.setServiceEntryPoint( GWT.getModuleBaseURL() +
"services/activityService" );
I've seen some references to hosted mode not being able to use the
Spring container, but other postings saying that it works just fine.
I looked for a FAQ on the home page in SourceForge to see if there was
more information, but I found no reference to such a page. So, I
apologize in advance if this information is out there. I just can't
seem to find it.
Thanks,
Dave
<bean id="urlMapping" class="org.gwtwidgets.server.spring.GWTHandler">
<property name="mappings">
<map>
<entry key="/activityService" value-ref="activityService"/>
</map>
</property>
</bean>
Dave
Dave
On 03/08/2010 07:43 PM, dchicks wrote:
type Rapport d'état
message /war/gwtdeply/services/activityService
description La ressource demandée (/war/gwtdeply/services/activityService) n'est pas disponible.
what is wrong with my code!!
--
You received this message because you are subscribed to the Google Groups "gwt-sl" group.
To post to this group, send an email to gwt...@googlegroups.com.
To unsubscribe from this group, send email to gwt-sl+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gwt-sl?hl=en-GB.
<module rename-to="activities">This becomes the base URL of the module. So my module is now located at something like http://localhost:8080/activities. Next, I had to make sure that the DispatcherServlet was defined to intercept the correct URLs:
<servlet>
<servlet-name>activities</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>activities</servlet-name>Notice that the url-pattern includes the name of the GWT module! This is important! Next, I define the mapping for the services in activities-servlet.xml:
<url-pattern>/activities/services/*</url-pattern>
</servlet-mapping>
<bean id="urlMapping" class="org.gwtwidgets.server.spring.GWTHandler">
<property name="mappings">
<map>
<entry key="/activityService" value-ref="activityService"/>Finally, I must define the relative path for the service on the service interface:
</map>
</property>
</bean>
@RemoteServiceRelativePath("services/activityService")
public interface ActivityService extends RemoteService {
public List<ActivityDTO> listActivities();
public void deleteActivity(Long activityId);
public void addActivity(String name, String activityData);
}
Sending name to the server:
878
Server replies:
Etat HTTP 404 - Servlet activities n'est pas disponible.
type Rapport d'�tat
message Servlet activities n'est pas disponible.
description La ressource demand�e (Servlet activities n'est pas
disponible.) n'est pas disponible.
another thing that may help you to help me:in developpment mode, i get
Starting Jetty on port 8888
[WARN] Exception while dispatching incoming RPC call
java.lang.RuntimeException:
com.google.gwt.user.server.rpc.UnexpectedException: Service method
'public abstract java.lang.String
gwt.spring.serverlibrary.client.GreetingService.greetServer(java.lang.String)'
threw an unexpected exception: java.lang.NullPointerException
at
org.gwtwidgets.server.spring.GWTRPCServiceExporter.handleExporterProcessingException(GWTRPCServiceExporter.java:
384)
at
org.gwtwidgets.server.spring.GWTRPCServiceExporter.processCall(GWTRPCServiceExporter.java:
353)
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
org.gwtwidgets.server.spring.GWTRPCServiceExporter.handleRequest(GWTRPCServiceExporter.java:
407)
at
org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:
49)
at
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:
771)
at
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:
716)
at
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:
647)
at
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:
563)
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: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)
Caused by: com.google.gwt.user.server.rpc.UnexpectedException: Service
method 'public abstract java.lang.String
gwt.spring.serverlibrary.client.GreetingService.greetServer(java.lang.String)'
threw an unexpected exception: java.lang.NullPointerException
at
com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:
378)
at
com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:
361)
at
org.gwtwidgets.server.spring.GWTRPCServiceExporter.encodeResponseForFailure(GWTRPCServiceExporter.java:
223)
at
org.gwtwidgets.server.spring.GWTRPCServiceExporter.handleInvocationTargetException(GWTRPCServiceExporter.java:
256)
at
org.gwtwidgets.server.spring.GWTRPCServiceExporter.processCall(GWTRPCServiceExporter.java:
344)
... 27 more
Caused by: java.lang.NullPointerException
at javax.servlet.GenericServlet.getServletContext(GenericServlet.java:
160)
at
gwt.spring.serverlibrary.server.GreetingServiceImpl.greetServer(GreetingServiceImpl.java:
14)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.gwtwidgets.server.spring.GWTRPCServiceExporter.invokeMethodOnService(GWTRPCServiceExporter.java:
169)
at
org.gwtwidgets.server.spring.GWTRPCServiceExporter.processCall(GWTRPCServiceExporter.java:
338)
... 27 more
[ERROR] 500 - POST /activities/services/activityService (127.0.0.1) 57
bytes
Request headers
Host: localhost:8888
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; fr; rv:
1.9.1.8) Gecko/20100202 Firefox/3.5.8
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://localhost:8888/activities/hosted.html?activities
X-GWT-Permutation: HostedMode
X-GWT-Module-Base: http://localhost:8888/activities/
Content-Type: text/x-gwt-rpc; charset=utf-8
Content-Length: 178
Pragma: no-cache
Cache-Control: no-cache
Response headers
Content-Type: text/plain
my web.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>activities</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</
servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>activities</servlet-name>
<url-pattern>/activities/services/*</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>Activities.html</welcome-file>
</welcome-file-list>
</web-app>
my activities-servlet.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://
www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="activityService"
class="gwt.spring.serverlibrary.server.GreetingServiceImpl" />
<bean id="urlMapping" class="org.gwtwidgets.server.spring.GWTHandler">
<property name="mappings">
<map>
<entry key="/activityService" value-ref="activityService" />
</map>
</property>
</bean>
</beans>
and in my service interface: @RemoteServiceRelativePath("services/
activityService")
i had test all the cases and i am really getting worried
what is my fault
i don't know why my servlet
org.springframework.web.servlet.DispatcherServlet isn't found
i have include all the necessar jar in the war/WEB-INF/lib folder
There are dozens of reasons why it might not find the servlet. If it's
working in Dev mode for you, you probably have some kind of
configuration problem on your app container.
To get logging turned on, add a log4j.xml file and the log4j listener in
your web.xml. Like this...
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
Here's an example log4j.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" >
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="stdout" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE} %5p %c{1}:%L - %m%n" />
</layout>
</appender>
<root>
<priority value="info"></priority>
<appender-ref ref="stdout" />
</root>
<logger name="org.mypackages">
<priority value="debug"/>
<appender-ref ref="stdout"/>
</logger>
</log4j:configuration>