[CDO] Standalone Java Client - Help! [message #1769191] |
Thu, 27 July 2017 08:49  |
Eclipse User |
|
|
|
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 19:42   |
Eclipse User |
|
|
|
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: Thu, 27 July 2017 21:19] by Moderator
|
|
|
|
|
Re: [CDO] Standalone Java Client - Help! [message #1769487 is a reply to message #1769228] |
Mon, 31 July 2017 23:25  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.05364 seconds