Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: for the plan.

Jump to: navigation, search

Getting started with CDO Galileo

NEWER VERSION: Getting_started_with_CDO_Helios


This tutorial will help you to get started with CDO. Therefore we will set up a small project to show the CDO basics. This tutorial was build on Eclipse 3.5 (Galileo). If you like to work through this tutorial with Eclipse 3.4 Ganymede switch to "Ganymede CDO getting started".

Maybe, hopefully not, you will experience some trouble through the tutorial. At the end of this tutorial you will find a Trouble-Shooting which might help you to handle the problems. If not, please contact the EMF-Newsgroup.

Set up Eclipse

To ensure that everyone starts from the same point and to avoid conflicts with the tutorial we first will download a fresh Eclipse installation. You are free to use your still existing application through the tutorial. You can also start with your own and return to this point if something described in the tutorial does not meet your settings.

Download the Classic version of Eclipse from the following link.

We will use the Classic version because this will give you a good overview which additional Plugins are needed. So if you are running another distribution you can add the missing Plugins, if needed. Unpack the archive and copy the “eclipse” folder to a directory of your choice. This tutorial will use “C:/eclipse”. So far with the installation. Now start the IDE.

Set Up the Environment

The IDE will start with a fresh workspace Now we need to configure the environment with the CDO Plug-ins. You can either download the CDO Plugins from the CDO Downloadpage or follow the next steps to get a feeling for the needed Plugins.

To install the packages open the Update Manager (Help-->Install new software…) and select the Galileo update site. Select "CDO Model Repository SDK". This will install the needed CDO Plugins. You can also use this update site for the 2.0 maintenance builds

Note: If you want to use the latest stable build for 3.0, use the follwing update site

Galileo installnewsoftware2.png

In the next step we need the net4j Platform which is the communication base of CDO.

CDO net4jinstall.png

Finally to work the the example in the latter part of the tutorial we need some EMF.

CDO emf.png

In this tutorial we will use a H2 database. Because it is not shipped with the Galileo update site you need to install it using the update site for the maintenance build if you haven't installed CDO using the maintenance build.

Get the server started

Before you can start the server it needs to be configured. CDO makes use of a configuration file. Copy the following file to a “config” folder under the root of your Eclipse folder (C:/eclipse/config) and name it cdo-server.xml.

<?xml version="1.0" encoding="UTF-8"?>
	<!--acceptor type="http"/ -->
	<acceptor type="tcp" listenAddr="" port="2036">
		<!-- negotiator type="challenge" description="/temp/users.db"/ -->
	<repository name="repo1">
		<property name="overrideUUID" value="1ff5d226-b1f0-40fb-aba2-0c31b38c764f"/>
		<property name="supportingAudits" value="true"/>
		<property name="verifyingRevisions" value="false"/>
		<property name="currentLRUCapacity" value="10000"/>
		<property name="revisedLRUCapacity" value="100"/>
		<store type="db">
			<mappingStrategy type="horizontal">
				<property name="qualifiedNames" value="false"/>
				<property name="toManyReferences" value="ONE_TABLE_PER_REFERENCE"/>
				<property name="toOneReferences" value="LIKE_ATTRIBUTES"/>
                        <dbAdapter name="h2"/>
			<dataSource class="org.h2.jdbcx.JdbcDataSource"

                   <!-- <dbAdapter name="derby-embedded"/>
			<dataSource class="org.apache.derby.jdbc.EmbeddedDataSource"

			<!--<dbAdapter name="hsqldb"/>
			<dataSource class="org.eclipse.net4j.db.hsqldb.HSQLDBDataSource" 
			<!--<dbAdapter name="mysql"/>
			<dataSource class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" 
			<!--<dbAdapter name="postgresql"/>
			<dataSource class="org.postgresql.ds.PGSimpleDataSource"

Now let us start the server. This can be achieved by creating a new run configuration. Open the Run dialog by selection Run->Run Configurations. Right click the "Eclipse Application" entry and create a new configuration. Just name it "CDO_Server". Select the "org.eclipse.emf.cdo.server.product" as new product on the "Program to Run" field.

CDO runconfig1.png

Note: On the arguments tab you can configure where your configuration file is stored. Therefore you need to add the following entry to the VM Arguments:


By default the "config" folder under the distribution root will be used.

On the configuration tab select "Generate a config.ini file with default content"

CDO runconfig2.png

Now hit the "Run" button. Your CDO Server will start.

CDO server started.png

Now the server hast started and additionally a H2 database. If you have not changed the default settings there will be a new folder "C:\eclipse\_database" which holds the data for the H2 db.

Prepare the Client

To prepare the client we will use the very basic EMF-library example. If you are not familiar with EMF or this famous tutorial at all, please refer to this instruction Create a new Java-Project and name it "CDO_Client" (or any other name). Create a folder called “model”. We will us the *.mdl file from the tutorial. If you have still executed the tutorial you will not need this steps. Create a new EMF-Model and name your generation model "library.genmodel".

CDO library1.png

Select import from rose model and use the following mdl file for the import (

CDO rose.png

This will create the generation model and the ecore for your. Now we need to convert the generation model to meet the need of CDO. Right click the genmodel and select CDO->Migrate EMF Model. This will change the model. Now you can open it and generate the code by invoking "generate all" an the model root.

CDO ecoretocdo.png

Connect the clients

Now it is time to play with CDO. Start on client by right clicking the editor plugin and selecting “Run as…->Eclipse Application”.

To start another client open the run configuration in the host eclipse. “Duplicate” the “Eclipse Application” and give the “Location” on the main tab a new folder.

CDO eclipse instance.png

Now run the second client, too. To Play with CDO we will use the CDO session view. This can be opened under "Windows->show View->Others…CDO session View"

CDO sessionview1.png

To open a new Session just click the green plus symbol. Add the location of the server. Remember the config.xml. Here we configured the port. We will use tcp as protocol by setting the acceptor to "tcp".

<acceptor type="tcp" listenAddr="" port="2036">
		<!-- negotiator type="challenge" description="/temp/users.db"/ -->

That’s why we will now connect to this protocol. You might also remember the repository settings:

<repository name="repo1">…</repository>

Here we specified the name of the repository which we will now connect to.

CDO sessionview2.png

Now open a transaction on the newly created Session.

CDO transaction.png

To work with the library we need to create a new session. This can be done on the transaction itself. Name it "/res1".

This will open an editor for you. In this editor create a new Library by rightclicking the editor pane and choosing “New Root->library.ecore->Library”. After saving the editor the local data will be published to the repository.

CDO createresource.png

CDO createresource2.png

By now we have connected to the repository and created a new resource in it. Automatically a new editor has opened. Right-click the empty editor pane and add a library object as new root. You can also add a book and/or a writer.

CDO newlib.png

CDO library.png

To connect the second client repeat the previous steps in the other instance. Open the CDO view, add a session and open a transaction. But now do not create but open a resource. Again enter "/res1" as resource name.

You will see the data you added to the repository on the other client. Remember that we have an opened session on both clients. Add another book on one client and watch the other. The book will appear on the other site. Because the transaction is opened on both clients you can produce a conflict and wee what happens. Change the name of a book on one client and try to commit the data on both. The second committer will not be able to publish the book and will receive an error message.

CDO conflicts.png

Congratulation! You managed your first CDO tutorial.

Trouble Shooting

[ERROR] Unknown DB adapter: XYZ

If this error occurs while starting the server, please make sure that the correct entry is set in the config.xml. Make also sure that you have download a plugin which contains the specific database driver for your choosen database system. For example for Derby:

<dataSource class="org.apache.derby.jdbc.EmbeddedDataSource"

org.eclipse.net4j.db.DBException: Column 'CREATED'…

If you receive the following exeption….

[ERROR] Column 'CREATED' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE  statement then 'CREATED' is not a column in the target table.
org.eclipse.net4j.db.DBException: Column 'CREATED' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE  statement then 'CREATED' is not a column in the target table.
	at org.eclipse.net4j.spi.db.DBAdapter.validateTable(
	at org.eclipse.net4j.spi.db.DBAdapter.createTable(
	at org.eclipse.net4j.spi.db.DBAdapter.createTables(
	at org.eclipse.net4j.spi.db.DBSchema.create(
	at org.eclipse.emf.cdo.server.internal.db.DBStore.doActivate(
	at org.eclipse.net4j.util.lifecycle.Lifecycle.activate(
	at org.eclipse.net4j.util.lifecycle.LifecycleUtil.activate(
	at org.eclipse.net4j.util.lifecycle.LifecycleUtil.activate(
	at org.eclipse.emf.cdo.internal.server.Repository.doActivate(
	at org.eclipse.net4j.util.lifecycle.Lifecycle.activate(
	at org.eclipse.net4j.util.lifecycle.LifecycleUtil.activate(
	at org.eclipse.net4j.util.lifecycle.LifecycleUtil.activate(
	at org.eclipse.emf.cdo.server.CDOServerUtil.addRepository(
	at org.eclipse.emf.cdo.internal.server.RepositoryConfigurator.configure(
	at org.eclipse.emf.cdo.internal.server.bundle.CDOServerApplication.doStart(
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(
	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.eclipse.equinox.launcher.Main.invokeFramework(
	at org.eclipse.equinox.launcher.Main.basicRun(
	at org.eclipse.equinox.launcher.Main.main(

…it may be that you have created the database specified in the server-config.xml with an older CDO version. Maybe, because you ran the Ganymede CDO getting started first. To solve this problem remove you database and let CDO create a new one.

Factory not found

It may happen that you will get a "FactoryNotFoundException" (as listed below) while connection to the server. If so, please check igf you have correctly addressed the name of the repository. The reporitory name must match the name specified in your cdo-server.xml.

org.eclipse.net4j.util.container.FactoryNotFoundException: Factory not found: org.eclipse.emf.cdo.server.repositories[default]
	at org.eclipse.net4j.util.container.ManagedContainer.getFactory(
	at org.eclipse.net4j.util.container.ManagedContainer.createElement(
	at org.eclipse.net4j.util.container.ManagedContainer.getElement(
	at org.eclipse.net4j.util.container.ManagedContainer.getElement(
	at org.eclipse.emf.cdo.spi.server.RepositoryFactory.get(
	at org.eclipse.emf.cdo.spi.server.ContainerRepositoryProvider.getRepository(
	at org.eclipse.emf.cdo.internal.server.protocol.OpenSessionIndication.responding(
	at org.eclipse.emf.cdo.internal.server.protocol.CDOServerIndication.responding(
	at org.eclipse.net4j.signal.IndicationWithResponse.doExtendedOutput(
	at org.eclipse.net4j.signal.Signal.doOutput(
	at org.eclipse.net4j.signal.IndicationWithResponse.execute(
	at org.eclipse.net4j.signal.Signal.runSync(
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$ Source)
	at Source)

Back to the top