Setting up Dependencies

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.

<project xmlns="" xmlns:xsi=""

			<name>Caucho Repository</name>
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.

Client Classes on the Server

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.

Configuring web.xml

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) :

<?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE web-app
   PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
	<display-name>Cayenne Tutorial</display-name>
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).

Running ROP Server

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:

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Cayenne Tutorial
[INFO] Id: org.example.cayenne:tutorial:jar:0.0.1-SNAPSHOT
[INFO] task-segment: [jetty:run]
[INFO] ------------------------------------------------------------------------
[INFO] [jetty:run]
[INFO] Configuring Jetty for project: Cayenne Tutorial
[INFO] Webapp source directory = /Users/andrus-tutorial/Desktop/work/tutorial/src/main/webapp
[INFO] Starting jetty 6.1.22 ...
2010-01-16 17:22:16.906:INFO::jetty-6.1.22
2010-01-16 17:22:17.027:INFO::No Transaction manager found - if your webapp requires one, please configure one.
INFO: started configuration loading.
INFO: loaded domain: UntitledDomain
INFO: loaded <map name='UntitledDomainMap' location=''>.
INFO: loading <node name='UntitledDomainNode' datasource='UntitledDomainNode.driver.xml' 
factory='org.apache.cayenne.conf.DriverDataSourceFactory' schema-update-strategy='org.apache.cayenne.access.dbsync.CreateIfNoSchemaStrategy'>.
INFO: using factory: org.apache.cayenne.conf.DriverDataSourceFactory
INFO: loading driver information from 'UntitledDomainNode.driver.xml'.
INFO: loading driver org.apache.derby.jdbc.EmbeddedDriver
INFO: loading user name and password.
INFO: Created connection pool: jdbc:derby:memory:testdb;create=true 
	Driver class: org.apache.derby.jdbc.EmbeddedDriver
	Min. connections in the pool: 1
	Max. connections in the pool: 1
INFO: loaded datasource.
INFO: no adapter set, using automatic adapter.
INFO: loaded map-ref: UntitledDomainMap.
INFO: finished configuration loading in 549 ms.
2010-01-16 17:22:17.960:INFO::Started SelectChannelConnector@

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.

Next Step: Remote Object Persistence Tutorial Client Code