Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] running stand alone?
[CDO] running stand alone? [message #762819] Thu, 08 December 2011 17:02 Go to next message
Missing name Missing name is currently offline Missing name Missing nameFriend
Messages: 4
Registered: December 2011
Junior Member
Hi,

I'm trying to find details on how to run CDO standalone without the needs for an equinox OSGi container. I've done lots of Google searches and forum searches but the best I've found is people saying it can be done, but no instructions.

I'm using CDO 4.0.0.v20110608-1440

I found this post here:

*topic and message, can't post links* CDO+standalone#msg_728087

Which obviously is a start of the puzzle, and I found the snippet on the wiki about defining it in Spring but half the classes don't seem to exist any more

*remove link as I can't post it*

So again this got me no further.

Specifically I'm after using Teneo and Hibernate with a simple MySQL back end. I have a config.xml that works perfectly when running inside eclipse/OSGi but I cannot get it to boot strap inside a simple java main class.

So far my attempt is:

final IManagedContainer container = IPluginContainer.INSTANCE;
        Net4jUtil.prepareContainer(container); // Prepare the Net4j kernel
        TCPUtil.prepareContainer(container); // Prepare the TCP transport (optional)
        CDONet4jServerUtil.prepareContainer(container); // Prepare the CDO server for Net4j

        final RepositoryConfigurator repositoryConfigurator = new RepositoryConfigurator(container);
        final File configFile = new File("cdo-server.xml");
        repositories = repositoryConfigurator.configure(configFile);
        if ((this.repositories == null) || (this.repositories.length == 0)) {
            System.err.println("Failed to find config file: " + configFile.getAbsolutePath());
        }

        final String port = OMPlatform.INSTANCE.getProperty("org.eclipse.emf.cdo.server.browser.port");
        if (port != null) {
            container.getElement("org.eclipse.emf.cdo.server.browsers", "default", port);
        }

        final Net4jAppExtension net4j = new Net4jAppExtension();
        net4j.start(configFile);
        Thread.sleep(Long.MAX_VALUE);


Which is mostly taken from the application that is launched by eclipse. However it blows up with an NPE when trying to call the repositoryConfigurator.configure line:

Exception in thread "main" java.lang.NullPointerException
	at org.eclipse.emf.cdo.spi.server.RepositoryConfigurator.createExecutableExtension(RepositoryConfigurator.java:329)
	at org.eclipse.emf.cdo.spi.server.RepositoryConfigurator.getStoreFactory(RepositoryConfigurator.java:275)
	at org.eclipse.emf.cdo.spi.server.RepositoryConfigurator.createStore(RepositoryConfigurator.java:290)
	at org.eclipse.emf.cdo.spi.server.RepositoryConfigurator.getRepository(RepositoryConfigurator.java:163)
	at org.eclipse.emf.cdo.spi.server.RepositoryConfigurator.configure(RepositoryConfigurator.java:105)


Which looks like it is trying to go off down eclipse extension point route, so is clearly wrong.

Any pointers would be greatfuly received.

Thank you.

[Updated on: Thu, 08 December 2011 17:03]

Report message to a moderator

Re: [CDO] running stand alone? [message #762840 is a reply to message #762819] Thu, 08 December 2011 17:34 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 08.12.2011 18:02, schrieb stephen.rowles:
> Hi,
>
> I'm trying to find details on how to run CDO standalone without the needs for an equinox OSGi container. I've done
> lots of Google searches and forum searches but the best I've found is people saying it can be done, but no instructions.
>
> I'm using CDO 4.0.0.v20110608-1440
>
> I found this post here:
>
> *topic and message, can't post links* CDO+standalone#msg_728087
>
> Which obviously is a start of the puzzle, and I found the snippet on the wiki about defining it in Spring but half the
> classes don't seem to exist any more
>
> *remove link as I can't post it*
>
> So again this got me no further.
>
> Specifically I'm after using Teneo and Hibernate with a simple MySQL back end. I have a config.xml that works
> perfectly when running inside eclipse/OSGi but I cannot get it to boot strap inside a simple java main class.
>
> So far my attempt is:
>
>
> final IManagedContainer container = IPluginContainer.INSTANCE;
> Net4jUtil.prepareContainer(container); // Prepare the Net4j kernel
> TCPUtil.prepareContainer(container); // Prepare the TCP transport (optional)
> CDONet4jServerUtil.prepareContainer(container); // Prepare the CDO server for Net4j
Please add this for standalone:

container.activate();

>
> final RepositoryConfigurator repositoryConfigurator = new RepositoryConfigurator(container);
Please add this for standalone:

repositoryConfigurator.getStoreFactories().put(HibernateStore.TYPE, new HibernateStoreFactory());

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper



> final File configFile = new File("cdo-server.xml");
> repositories = repositoryConfigurator.configure(configFile);
> if ((this.repositories == null) || (this.repositories.length == 0)) {
> System.err.println("Failed to find config file: " + configFile.getAbsolutePath());
> }
>
> final String port = OMPlatform.INSTANCE.getProperty("org.eclipse.emf.cdo.server.browser.port");
> if (port != null) {
> container.getElement("org.eclipse.emf.cdo.server.browsers", "default", port);
> }
>
> final Net4jAppExtension net4j = new Net4jAppExtension();
> net4j.start(configFile);
> Thread.sleep(Long.MAX_VALUE);
>
>
> Which is mostly taken from the application that is launched by eclipse. However it blows up with an NPE when trying to
> call the repositoryConfigurator.configure line:
>
>
> Exception in thread "main" java.lang.NullPointerException
> at org.eclipse.emf.cdo.spi.server.RepositoryConfigurator.createExecutableExtension(RepositoryConfigurator.java:329)
> at org.eclipse.emf.cdo.spi.server.RepositoryConfigurator.getStoreFactory(RepositoryConfigurator.java:275)
> at org.eclipse.emf.cdo.spi.server.RepositoryConfigurator.createStore(RepositoryConfigurator.java:290)
> at org.eclipse.emf.cdo.spi.server.RepositoryConfigurator.getRepository(RepositoryConfigurator.java:163)
> at org.eclipse.emf.cdo.spi.server.RepositoryConfigurator.configure(RepositoryConfigurator.java:105)
>
>
> Which looks like it is trying to go off down eclipse extension point route, so is clearly wrong.
>
> Any pointers would be greatfuly received.
>
> Thank you.


Re: [CDO] running stand alone? [message #763125 is a reply to message #762840] Fri, 09 December 2011 08:20 Go to previous messageGo to next message
Missing name Missing name is currently offline Missing name Missing nameFriend
Messages: 4
Registered: December 2011
Junior Member
Thank you for the pointer, that's got be a bit further. However I now have a new NPE, again from registry point processing, but this time inside the HibernateUtil class. Having looked through the code I can't work out how to avoid it going down that route. Should I not be using the repositoryConfigurator.configure(configFile) method?

Exception in thread "main" java.lang.NullPointerException
	at org.eclipse.emf.cdo.server.internal.hibernate.HibernateUtil.createMappingProviderFactory(HibernateUtil.java:194)
	at org.eclipse.emf.cdo.server.internal.hibernate.HibernateStoreFactory.getMappingProvider(HibernateStoreFactory.java:73)
	at org.eclipse.emf.cdo.server.internal.hibernate.HibernateStoreFactory.createStore(HibernateStoreFactory.java:49)
	at org.eclipse.emf.cdo.spi.server.RepositoryConfigurator.createStore(RepositoryConfigurator.java:291)
	at org.eclipse.emf.cdo.spi.server.RepositoryConfigurator.getRepository(RepositoryConfigurator.java:163)
	at org.eclipse.emf.cdo.spi.server.RepositoryConfigurator.configure(RepositoryConfigurator.java:105)


My code now looks like this but again it still fails as the repositoryConfigurator.configure(configFile) line with the above stack trace.

final IManagedContainer container = IPluginContainer.INSTANCE;
        Net4jUtil.prepareContainer(container); // Prepare the Net4j kernel
        TCPUtil.prepareContainer(container); // Prepare the TCP transport (optional)
        CDONet4jServerUtil.prepareContainer(container); // Prepare the CDO server for Net4j
        container.activate();

        final RepositoryConfigurator repositoryConfigurator = new RepositoryConfigurator(container);
        repositoryConfigurator.getStoreFactories().put(HibernateStore.TYPE, new HibernateStoreFactory());
        final File configFile = new File("cdo-server.xml");
        repositories = repositoryConfigurator.configure(configFile);
        if ((this.repositories == null) || (this.repositories.length == 0)) {
            System.err.println("Failed to find config file: " + configFile.getAbsolutePath());
        }

        final String port = OMPlatform.INSTANCE.getProperty("org.eclipse.emf.cdo.server.browser.port");
        if (port != null) {
            container.getElement("org.eclipse.emf.cdo.server.browsers", "default", port);
        }

        final Net4jAppExtension net4j = new Net4jAppExtension();
        net4j.start(configFile);
        Thread.sleep(Long.MAX_VALUE);
Re: [CDO] running stand alone? [message #763153 is a reply to message #763125] Fri, 09 December 2011 09:09 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 09.12.2011 09:20, schrieb stephen.rowles:
> Thank you for the pointer, that's got be a bit further. However I now have a new NPE, again from registry point
> processing, but this time inside the HibernateUtil class. Having looked through the code I can't work out how to avoid
> it going down that route. Should I not be using the repositoryConfigurator.configure(configFile) method?
>
>
> Exception in thread "main" java.lang.NullPointerException
> at org.eclipse.emf.cdo.server.internal.hibernate.HibernateUtil.createMappingProviderFactory(HibernateUtil.java:194)
> at
> org.eclipse.emf.cdo.server.internal.hibernate.HibernateStoreFactory.getMappingProvider(HibernateStoreFactory.java:73)
> at org.eclipse.emf.cdo.server.internal.hibernate.HibernateStoreFactory.createStore(HibernateStoreFactory.java:49)
> at org.eclipse.emf.cdo.spi.server.RepositoryConfigurator.createStore(RepositoryConfigurator.java:291)
> at org.eclipse.emf.cdo.spi.server.RepositoryConfigurator.getRepository(RepositoryConfigurator.java:163)
> at org.eclipse.emf.cdo.spi.server.RepositoryConfigurator.configure(RepositoryConfigurator.java:105)
I think Martin (cc'ed) should factor the call to HibernateUtil.getInstance().createMappingProviderFactory() into a
protected method that you can override in your derived implementation. Please submit a bugzilla.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


>
>
> My code now looks like this but again it still fails as the repositoryConfigurator.configure(configFile) line with the
> above stack trace.
>
>
> final IManagedContainer container = IPluginContainer.INSTANCE;
> Net4jUtil.prepareContainer(container); // Prepare the Net4j kernel
> TCPUtil.prepareContainer(container); // Prepare the TCP transport (optional)
> CDONet4jServerUtil.prepareContainer(container); // Prepare the CDO server for Net4j
> container.activate();
>
> final RepositoryConfigurator repositoryConfigurator = new RepositoryConfigurator(container);
> repositoryConfigurator.getStoreFactories().put(HibernateStore.TYPE, new HibernateStoreFactory());
> final File configFile = new File("cdo-server.xml");
> repositories = repositoryConfigurator.configure(configFile);
> if ((this.repositories == null) || (this.repositories.length == 0)) {
> System.err.println("Failed to find config file: " + configFile.getAbsolutePath());
> }
>
> final String port = OMPlatform.INSTANCE.getProperty("org.eclipse.emf.cdo.server.browser.port");
> if (port != null) {
> container.getElement("org.eclipse.emf.cdo.server.browsers", "default", port);
> }
>
> final Net4jAppExtension net4j = new Net4jAppExtension();
> net4j.start(configFile);
> Thread.sleep(Long.MAX_VALUE);
>


Re: [CDO] running stand alone? [message #763182 is a reply to message #763153] Fri, 09 December 2011 09:57 Go to previous messageGo to next message
Missing name Missing name is currently offline Missing name Missing nameFriend
Messages: 4
Registered: December 2011
Junior Member
Thank you for the assistance,

I've raised a bug id 366162 (still can't post links)

Which includes my test java "main" class, server.xml file etc.
Re: [CDO] running stand alone? [message #763228 is a reply to message #763182] Fri, 09 December 2011 11:33 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Okay seen it!

gr. Martin

On 12/09/2011 10:57 AM, stephen.rowles wrote:
> Thank you for the assistance,
> I've raised a bug id 366162 (still can't post links)
>
> Which includes my test java "main" class, server.xml file etc.


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Previous Topic:[Teneo] Do I understand OneToOne correctly?
Next Topic:Re: Removing EObject from EMF Resource with RemoveCommand
Goto Forum:
  


Current Time: Thu Apr 18 06:39:21 GMT 2024

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

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

Back to the top