Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Standalone Java Client - Help!(Trying to establish a standalone client and persist the model elements in an H2 Data Store)
[CDO] Standalone Java Client - Help! [message #1769191] Thu, 27 July 2017 12:49 Go to next message
Nirmal Kanagasabai is currently offline Nirmal KanagasabaiFriend
Messages: 11
Registered: July 2017
Junior Member
Hi Team,

I am working on a standalone Java client and make it work with CDO with an H2 data store. I looked up on all related posts for establishing a standalone client (outside Eclipse container) and have CDO as it's persistence layer.

I have created a new model (two classes with two attributes each and a composition between them). I am able to generate a CDO native code using the GenModel and persist them in an XMI file (for experimentation).

However, I end up getting stuck when I am trying to persist the model elements in an H2 Data store. At first, I tried the standalone client and server but I have been facing a lot of issues getting it forward (will be requesting your help in another post).

I then focussed on EmbeddedRepository as suggested in this post. I retained EmbeddedRepositoryConfig and CDO Facade and just changed the Embedded Repository Example to make use of my model instead of the company model.

Here's the error that's thrown in my console:

Exception in thread "main" org.eclipse.net4j.util.transaction.TransactionException: Rollback in DBStore: java.lang.UnsupportedOperationException
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.doSave(ResourceImpl.java:1462)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1430)
at org.eclipse.emf.cdo.common.model.EMFUtil.getEPackageBytes(EMFUtil.java:497)
at org.eclipse.emf.cdo.server.internal.db.MetaDataManager.getEPackageBytes(MetaDataManager.java:225)
at org.eclipse.emf.cdo.server.internal.db.MetaDataManager.fillSystemTables(MetaDataManager.java:254)
at org.eclipse.emf.cdo.server.internal.db.MetaDataManager.fillSystemTables(MetaDataManager.java:297)
at org.eclipse.emf.cdo.server.internal.db.MetaDataManager.writePackageUnits(MetaDataManager.java:142)
at org.eclipse.emf.cdo.server.internal.db.DBStoreAccessor.writePackageUnits(DBStoreAccessor.java:895)
at org.eclipse.emf.cdo.spi.server.StoreAccessor.doWrite(StoreAccessor.java:81)
at org.eclipse.emf.cdo.server.internal.db.DBStoreAccessor.doWrite(DBStoreAccessor.java:877)
at org.eclipse.emf.cdo.spi.server.StoreAccessorBase.write(StoreAccessorBase.java:150)
at org.eclipse.emf.cdo.internal.server.TransactionCommitContext.writeAccessor(TransactionCommitContext.java:1544)
at org.eclipse.emf.cdo.internal.server.TransactionCommitContext.write(TransactionCommitContext.java:679)
at org.eclipse.emf.cdo.internal.server.Repository.initRootResource(Repository.java:2068)
at org.eclipse.emf.cdo.internal.server.Repository.doActivate(Repository.java:2227)
at org.eclipse.net4j.util.lifecycle.Lifecycle.internalActivate(Lifecycle.java:76)
at org.eclipse.net4j.util.lifecycle.ShareableLifecycle.internalActivate(ShareableLifecycle.java:43)
at org.eclipse.net4j.util.lifecycle.Lifecycle.activate(Lifecycle.java:162)
at org.eclipse.net4j.util.lifecycle.LifecycleUtil.activate(LifecycleUtil.java:127)
at org.eclipse.net4j.util.lifecycle.LifecycleUtil.activate(LifecycleUtil.java:117)
at org.eclipse.emf.cdo.server.CDOServerUtil.addRepository(CDOServerUtil.java:300)
at ca.mcgill.university.server.Server.main(Server.java:44)

at org.eclipse.emf.cdo.internal.server.Repository.initRootResource(Repository.java:2074)
at org.eclipse.emf.cdo.internal.server.Repository.doActivate(Repository.java:2227)
at org.eclipse.net4j.util.lifecycle.Lifecycle.internalActivate(Lifecycle.java:76)
at org.eclipse.net4j.util.lifecycle.ShareableLifecycle.internalActivate(ShareableLifecycle.java:43)
at org.eclipse.net4j.util.lifecycle.Lifecycle.activate(Lifecycle.java:162)
at org.eclipse.net4j.util.lifecycle.LifecycleUtil.activate(LifecycleUtil.java:127)
at org.eclipse.net4j.util.lifecycle.LifecycleUtil.activate(LifecycleUtil.java:117)
at org.eclipse.emf.cdo.server.CDOServerUtil.addRepository(CDOServerUtil.java:300)
at ca.mcgill.university.server.Server.main(Server.java:44)

Here's what I found in the repo.trace.db:

07-27 00:04:52 jdbc[2]: exception
org.h2.jdbc.JdbcSQLException: Table "CDO_PROPERTIES" not found; SQL statement:
SELECT VALUE FROM CDO_PROPERTIES WHERE NAME='org.eclipse.emf.cdo.server.db.schemaVersion' [42102-168]

I humbly request you to help me out on this regard.

I would also like to know if I can make use of our standalone application (which is built on top of EMF but runs outside an Eclipse container) as a client to connect to CDO server and persist the models in any DB store (say Oracle / H2 Data Store)? From what I read, I am certain that this is possible. But, setting things upfront is where I get halted. I would be extremely glad if you can point me to the right place to look for the information.

Regards,
Nirmal
Re: [CDO] Standalone Java Client - Help! [message #1769218 is a reply to message #1769191] Thu, 27 July 2017 23:42 Go to previous messageGo to next message
Pavel Vlasov is currently offline Pavel VlasovFriend
Messages: 23
Registered: December 2015
Junior Member
Hello,

Please clarify what you mean by "Eclipse container" - Eclipse IDE or Equinox?
If it is the first, i.e. you don't want any GUI, but want to run you app from the command line, or as a service, then you should build an Eclipse GUI-less product. There is a number of tutorials here - http://www.vogella.com/tutorials/ - although they are mostly about GUI apps.

You can use Maven/Tycho for automated builds, this tutorial will help you with setting it up - http://www.vogella.com/tutorials/EclipseTycho/article.html

This online book explains how to build an Equinox/OSGi (Web) server application - http://server-side-java-development-for-innovators.books.nasdanika.org. The book is work in progress, but it already contains information on how to set up and build an Equinox/OSGi server application. The source code for the project explained in the book is here - https://github.com/Nasdanika/bank.

If you don't need a server, but an application which starts, performs some operation and exits, then implement IApplication (https://help.eclipse.org/oxygen/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fequinox%2Fapp%2FIApplication.html). Example:
- Code - https://github.com/Nasdanika/bank/blob/49627c5c263fe7464203110ecb89d7a724a4bc64/org.nasdanika.bank.tests/src/org/nasdanika/bank/tests/NasdanikaBankTestRunner.java,
- Product defiinition - https://github.com/Nasdanika/bank/blob/49627c5c263fe7464203110ecb89d7a724a4bc64/org.nasdanika.bank.repository/org.nasdanika.bank.tests.product.

If, on the other hand, you don't want to use Equinox, then I'm not sure if it is possible at all - CDO is built on top of OSGi. I've been down this path for EMF long time ago and managing dependencies becomes a huge problem pretty soon with a big question - why to go to all this trouble if OSGi/Tycho can do it for you?

I hope it helps.
---
Best regards, Pavel.

[Updated on: Fri, 28 July 2017 01:19]

Report message to a moderator

Re: [CDO] Standalone Java Client - Help! [message #1769228 is a reply to message #1769218] Fri, 28 July 2017 05:39 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
I suspect that you didn't deploy the org.eclipse.emf.ecore.xmi plugin/jar to your classpath. In that case the org.eclipse.emf.ecore.impl.EPackageImpl.createResource(String) creates a wrong resource; one that can not save. Does your problem go away if you put org.eclipse.emf.ecore.xmi on the classpath?



Re: [CDO] Standalone Java Client - Help! [message #1769485 is a reply to message #1769218] Tue, 01 August 2017 03:20 Go to previous messageGo to next message
Nirmal Kanagasabai is currently offline Nirmal KanagasabaiFriend
Messages: 11
Registered: July 2017
Junior Member
Hello Pavel,

Thank you for your valuable inputs. I am sorry for not structuring my question properly. By Eclipse container, I referred to Eclipse IDE.

We already have an application built that can create reusable concerns. As of now, the model elements are just persisted in an XMI file. I am currently focussing on having CDO as the generic persistence layer and persist the models in an H2 Data Store.

I will get back to you in case of any further queries. Thanks again.

Regards,
Nirmal
Re: [CDO] Standalone Java Client - Help! [message #1769487 is a reply to message #1769228] Tue, 01 August 2017 03:25 Go to previous message
Nirmal Kanagasabai is currently offline Nirmal KanagasabaiFriend
Messages: 11
Registered: July 2017
Junior Member
Hello Eike,

Thank you very much. That did address my concern. I can now create a new model and persist the elements in an H2 Data Store using an embedded repository.

I will retry the same model with the Server and StandaloneClient example which you have provided and try to replicate the same. I will get back to you in case of any further clarifications.

Regards,
Nirmal
Previous Topic:[EMF] [CDO] Versioned Resources in EMF
Next Topic:Update map using EditingDomain
Goto Forum:
  


Current Time: Sat Apr 20 00:48:26 GMT 2024

Powered by FUDForum. Page generated in 0.03155 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top