First Time Trouble Unknown Protocol: mongodb

123 views
Skip to first unread message

Geoffry Roberts

unread,
Oct 11, 2013, 2:14:03 PM10/11/13
to mong...@googlegroups.com

All,


This my first time using MongoEMF.  I'm following the user guide under the heading Create and I get error saying "unknown protocol: mongodb".   No doubt I'm doing something wrong.  I suspect I went wrong with IMongoProvider when I didn't do anything wrt ConfigurationAdmin, but I'm not sure.  What gives?


Thanks in advance


java.net.MalformedURLException: unknown protocol: mongodb13:22:51.757 [Gogo shell] ERROR cmd.CommandSet - 


My code:

       

       // Type this command at the OSGi console and we should get a simple save.


public Object _savecda(CommandInterpreter itrp) {

// Load a clinical document from the filesystem.

File file = new File("samples/SampleCDADocument.xml");

log.info("file=" + file.getAbsolutePath());

try {

Reader reader = new BufferedReader(new FileReader(file));

InputSource is = new InputSource(reader);

ClinicalDocument cda = CDAUtil.load(is);  // we now have a CDA which is based on EMF.

// Clinical document loaded successfully.

//begin: Mongo-emf related code

IResourceSetFactory resourceSetFactory = new MongoResourceSetFactory();

ResourceSet resourceSet = resourceSetFactory.createResourceSet();

Resource resource = resourceSet.createResource(URI

.createURI("mongodb://localhost/ehr/cda/"));

EList<EObject> eo = resource.getContents();

eo.add(cda);  

try {

cda.eResource().save(null);

} catch (IOException e) {

log.error("", e); // unknown protocol: mongodb

}

//end Mongo-emf related code

log.info("cda=" + cda.toString());

} catch (Exception e) {

log.error("", e);  

}

return null;

}



Bryan Hunt

unread,
Oct 11, 2013, 3:22:40 PM10/11/13
to mong...@googlegroups.com
Hi Geoffry,

The "unknown protocol" error typically occurs when the resource set's URIConverter is missing the URIHandler that understands the mongodb scheme.  A few questions:

  1. What version of MongoEMF are you using?
  2. If you aren't using 0.8.0, can you move to the pre-release (it will be easier for me to help)?
  3. Are you running inside an OSGi container?
  4. Are you using declarative services?

You do need to configure some of the services, otherwise, they will not be started and wired to the other services.

If you are using OSGi with declarative services (highly recommended), start up the console and use the "ls" command (assuming you are using Equinox) to see which services are unsatisfied.

Bryan

--
You received this message because you are subscribed to the Google Groups "MongoEMF" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongoemf+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Geoffry Roberts

unread,
Oct 11, 2013, 3:38:52 PM10/11/13
to mong...@googlegroups.com
Brian,

Thanks for the quick response.

I am using .0.7.1 I thought 0.8.0 was not ready for prime time.  I shall get 0.8.0 if that is your recommendation.
I am running in an OSGi container.  It's a launch as OSGi inside eclipse.
I am using DS.

Geoffry Roberts

unread,
Oct 11, 2013, 3:45:01 PM10/11/13
to mong...@googlegroups.com
I cannot find 0.8.0 per se.  I do find the set (eMongo, eModeling, eUnit), which I have.  Are these what is meant by 0.8.0?


On Friday, 11 October 2013 14:14:03 UTC-4, Geoffry Roberts wrote:

Bryan Hunt

unread,
Oct 11, 2013, 3:45:23 PM10/11/13
to mong...@googlegroups.com
Hi Geoffry,

Version 0.8.0 is basically complete.  I need to officially release the eModeling project and clean up the documentation.  I do not expect the API to change between now and the official release.  I simply haven't had time to get it all cleaned up for the official release.  When you move to the 0.8.0 release, you will at a minimum need to configure a MongoDB client service and a MongoDB database service to get things to work.  I would recommend taking a look at the source code for the ExampleComponet and ExampleConfigurator.  The ExampleConfigurator shows you how to programatically configure the necessary services.  If you are building server side code, I would recommend using the metatype bundle along with the Apache Felix Webconsole.

Bryan

Bryan Hunt

unread,
Oct 11, 2013, 3:46:43 PM10/11/13
to mong...@googlegroups.com
You also need the MongoEMF bundles.  The p2 and bndtools repo links can be found on the main wiki:  https://github.com/BryanHunt/mongo-emf/wiki

Bryan

Geoffry Roberts

unread,
Oct 11, 2013, 3:53:49 PM10/11/13
to mong...@googlegroups.com
The link for p2 appears to be broken. I was able to get the bndtools download.


On Friday, 11 October 2013 14:14:03 UTC-4, Geoffry Roberts wrote:

Bryan Hunt

unread,
Oct 11, 2013, 4:39:50 PM10/11/13
to mong...@googlegroups.com
The p2 link only works as part of a target platform ...


Geoffry Roberts

unread,
Oct 23, 2013, 10:03:36 AM10/23/13
to mong...@googlegroups.com
Brian,

I'm back on mongo-emf after chasing other things for a few days.

Things still aren't working but after following the instructions given earlier in this thread,  the problems are different.

Am I doing things correctly?  I've made assumptions.  I may be wrong. I'm still trying to get something elementary to work so I'm still approaching things with an OSGi command.  

Because of the bndtools repository you have, I decided to use that.  The p2 update refused to install most of the plugins.  I did builds of the eModeling and eMongo bundles using the eclipse export-as-a-plugin. and dropped the resulting jars into my local bndtools repository.

When I run my command bundle, the eMongo service bundle starts. To wit:

g! lb

START LEVEL 1

   ID|State      |Level|Name

    0|Active     |    0|System Bundle (4.2.1)

    1|Active     |    1|Logback Classic Module (1.0.0)

    2|Active     |    1|Logback Core Module (1.0.0)

    3|Active     |    1|Storet MongoCDA Command (0.0.0) // My command bundle

    4|Active     |    1|Storet Mongo Componenture (0.0.0)

    5|Active     |    1|Apache Felix Configuration Admin Service (1.6.0)

    6|Active     |    1|Apache Felix Gogo Command (0.12.0)

    7|Active     |    1|Apache Felix Gogo Runtime (0.10.0)

    8|Active     |    1|Apache Felix Gogo Shell (0.10.0)

    9|Active     |    1|Apache Felix Log Service (1.0.1)

   10|Active     |    1|Apache Felix Declarative Services (1.6.2)

   11|Active     |    1|eMongo Services API (1.0.0.201310230854) // Looks good to me

   12|Active     |    1|MongoDB Java Driver (2.11.1.RELEASE)

   13|Active     |    1|OPS4J Pax Logging - API (1.3.0)

   14|Active     |    1|OPS4J Pax Logging - Service (1.3.0)

   15|Active     |    1|osgi.cmpn (5.0.0.201305092017)

   16|Active     |    1|osgi.enterprise (4.2.0.201003190513)

   17|Active     |    1|osgi.residential (4.3.0.201111022239)

   18|Active     |    1|slf4j-api (1.6.2)


But the command won't run if the component contains the following code:


@Reference

public void setMongoDatabaseProvider(

MongoDatabaseProvider mongoDatabaseProvider) {

log.info("mongoDatabaseProvider=" + mongoDatabaseProvider);

this.mongoDatabaseProvider = mongoDatabaseProvider;

}


I have notices that MongoDatabaseProvider implements 

From bnd.bnd:

-buildpath: osgi.core,\

osgi.cmpn,\

biz.aQute.bnd.annotation,\

org.apache.felix.gogo.runtime,\

iop.storet.mgo.provider;version=latest,\

slf4j.api,\

org.eclipselabs.emongo.api,\

org.eclipselabs.emongo.components,\

org.eclipselabs.emongo.configurator

-sub: *.bnd


From run.runBundle:

-runfw: org.apache.felix.framework;version='[4,5)'

-runee: JavaSE-1.7

-runsystemcapabilities: ${native_capability}


-resolve.effective: active


-runbundles: ch.qos.logback.classic;version='[1.0.0,1.0.1)',\

ch.qos.logback.core;version='[1.0.0,1.0.1)',\

iop.storet.cmd.command;version=latest,\

iop.storet.mgo.provider;version=latest,\

org.apache.felix.configadmin;version='[1.6.0,1.6.1)',\

org.apache.felix.gogo.command;version='[0.12.0,0.12.1)',\

org.apache.felix.gogo.runtime;version='[0.10.0,0.10.1)',\

org.apache.felix.gogo.shell;version='[0.10.0,0.10.1)',\

org.apache.felix.log;version='[1.0.1,1.0.2)',\

org.apache.felix.scr;version='[1.6.2,1.6.3)',\

org.eclipselabs.emongo.api;version='[1.0.0,1.0.1)',\

org.mongodb.mongo-java-driver;version='[2.11.1,2.11.2)',\

org.ops4j.pax.logging.pax-logging-api;version='[1.3.0,1.3.1)',\

org.ops4j.pax.logging.pax-logging-service;version='[1.3.0,1.3.1)',\

osgi.cmpn;version='[5.0.0,5.0.1)',\

osgi.enterprise;version='[4.2.0,4.2.1)',\

osgi.residential;version='[4.3.0,4.3.1)',\

slf4j.api;version='[1.6.2,1.6.3)'


-runrequires: osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.shell)',\

osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.command)',\

osgi.identity;filter:='(osgi.identity=osgi.cmpn)',\

osgi.identity;filter:='(osgi.identity=org.ops4j.pax.logging.pax-logging-service)',\

osgi.identity;filter:='(osgi.identity=iop.storet.cmd.command)',\

osgi.identity;filter:='(osgi.identity=iop.storet.mgo.provider)',\

osgi.identity;filter:='(osgi.identity=org.eclipselabs.emongo.api)',\

osgi.identity;filter:='(osgi.identity=org.eclipselabs.emongo.components)',\

osgi.identity;filter:='(osgi.identity=org.eclipselabs.emongo.configurator)'


Bryan Hunt

unread,
Oct 23, 2013, 2:42:40 PM10/23/13
to mong...@googlegroups.com
Hi Geoffry,

It looks like you are missing a bundle.  In addition to the emongo.api bundle, you must also include the emongo.components bundle.

Bryan

Geoffry Roberts

unread,
Oct 24, 2013, 2:44:12 PM10/24/13
to mong...@googlegroups.com
Brian,

Agreed, I'm missing emongo.components. It seems my problem was more with bndtools. ~components was selected in the dialog, but was not being resolved and therefore not starting.  It starts now, but I get the same result.  

<alas>
I have found these kinds of mysterious-not-workings occur often with OSGi.  No errors, but not working either. I need to find a better means of debugging.
</alas>

I take it that you were ok with my simply exporting eMongo bundles as plugins and using them as such.

Thanks

Geoffry Roberts

unread,
Oct 24, 2013, 4:42:55 PM10/24/13
to mong...@googlegroups.com
Brian,

Progress! At least to a point.  I managed to get ~components to activate.  

Question:

Geoffry Roberts

unread,
Oct 24, 2013, 4:47:34 PM10/24/13
to mong...@googlegroups.com
Sorry about the inadvertent post.

picking up from where I left off...

Question:

MongoClientProviderComponent
...
   public void activate(Map<String, Object> properties)

{

clientId = (String) properties.get(PROP_CLIENT_ID);

handleIllegalConfiguration(validateClientId(clientId));


From where does the properties object come?  I'm getting an error here because clientId is null.

Thanks

Bryan Hunt

unread,
Oct 24, 2013, 4:55:07 PM10/24/13
to mong...@googlegroups.com
Hi Geoffry,

This is where ConfigurationAdmin comes in.  You must supply a service configuration for the client and the database services.  You can either do this programatically, or graphically using the Apache Felix Webconsole.

Bryan

Geoffry Roberts

unread,
Oct 24, 2013, 9:43:36 PM10/24/13
to mong...@googlegroups.com
Brian,

I see in the example to to code it, but if the framework is handling everything how does the configuration get called before the error has a chance to get thrown?  Does the frame work sort this out?

Bryan Hunt

unread,
Oct 25, 2013, 7:44:56 AM10/25/13
to mong...@googlegroups.com
Hi Geoffry,

If you look at the client service registration for example, you see: configuration-policy="require". The eMongo service components will not be activated until a configuration is available.  This is a very cool feature of declarative services and also one that can cause great frustration when you don't know it, or forget about it.

Bryan
Reply all
Reply to author
Forward
0 new messages