Now lets get back to the "tutorial" project that contains a web application and set up dependencies. The only extra one that we don't have yet is resin-hessian.jar, just like the client, so let's add it (and the caucho repo declaration) to the pom.xml.
|Maven Optimization Hint|
On a real project both server and client modules will likely share a common parent pom.xml where common repository delcaration can be placed, with child pom's "inheriting" it from parent. This would reduce build code duplication.
Since ROP web service requires both server and client persistent classes, we need to generate a second copy of the client classes inside the server project (see instructions here, just pick the server project as a class generation target). This is a minor inconvenience that will hopefully go away in the future versions of Cayenne. Don't forget to refresh the project in Eclipse after class generation is done.
Cayenne web service is declared in the web.xml. It is implemented as a servlet "org.apache.cayenne.remote.hessian.service.HessianServlet". Open tutorial/src/main/webapp/WEB-INF/web.xml in Eclipse and add a service declaration (you may keep the Cayenne filter declaration left there from the previous tutorial, or you can start clean, either way will work) :
|Extending Server Behavior via Callbacks|
While no custom Java code is required on the server, just a service declaration, it is possible to customizing server-side behavior via callbacks and listeners (not shown in the tutorial).
Use previosly created Eclipse Jetty run configuration available via "Run > Run Configurations..." (or create a new one if none exists yet). You should see output in the Eclipse console similar to the following:
Cayenne ROP service URL is http://localhost:8080/tutorial/cayenne-service. If you click on it, you will see "Hessian Requires POST" message, that means that the service is alive, but you need a client other than the web browser to access it.