Prevent bnd from generating metatype <Designate> element

46 views
Skip to first unread message

ro6

unread,
Apr 13, 2015, 10:31:17 AM4/13/15
to bndtool...@googlegroups.com
My ultimate goal is to use Apache ACE to provision configuration for ds components.

The constraints are:
  • ACE requires the metatype xml file to be deployed as a separate artifact from the bundle it corresponds to
  • As far as I can tell, the Felix container I'm provisioning to doesn't recognize the metatype and associate it to the ds component unless it's inside the bundle
The solution suggested on the ACE mailing list was to split up the metatype definition into two separate files, the <OCD> portion inside the OSGI-INF/metatype directory in the bundle, and the <Designate> portion as a separate artifact handled by ACE. According to them, the OSGi spec supports this separation.

I'm running into issues deploying the configuration in this way, and I'm still trying to isolate where the error is coming from. I think one of the possibilities is that since the metatype xml generated by bnd inside the bundle already has a <Designate> element, the separate one I'm provisioning with ACE doesn't get picked up. Unfortunately, I can't test this theory because I don't know how to instruct bnd to generate only the <OCD> element of the metatype file.

I'm using bndtools 2.4.1.REL-20150116-150145-g75d944b

Here is the error I get when deploying:

[ERROR] 07:25:19 (controller) Installation of deployment update failed: Error while processing resource 'com.patronpath.ring.cc.decryptor.CreditCardDecryptorImpl.Config_ring-ace-agent-test_68.0.0.xml' (463)!
INFO|3647/0|yajsw|15-04-13 07:25:19|org.osgi.service.deploymentadmin.spi.ResourceProcessorException: No Object Class Definition found with id=com.patronpath.ring.cc.decryptor.CreditCardDecryptorImpl
INFO|3647/0|yajsw|15-04-13 07:25:19| at org.apache.felix.deployment.rp.autoconf.AutoConfResourceProcessor.process(AutoConfResourceProcessor.java:174)
INFO|3647/0|yajsw|15-04-13 07:25:19| at org.apache.felix.deploymentadmin.spi.ProcessResourceCommand.doExecute(ProcessResourceCommand.java:100)
INFO|3647/0|yajsw|15-04-13 07:25:19| at org.apache.felix.deploymentadmin.spi.Command.execute(Command.java:55)

where 'com.patronpath.ring.cc.decryptor.CreditCardDecryptorImpl.Config_ring-ace-agent-test_68.0.0.xml' is:

<?xml version='1.0'?>
<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.1.0"
localization="com.patronpath.ring.cc.decryptor.CreditCardDecryptorImpl$Config">
<Designate pid="com.patronpath.ring.cc.decryptor.CreditCardDecryptorImpl"
bundle="osgi-dp:com.patronpath.ring.cc.decryptor">
<Object ocdref="com.patronpath.ring.cc.decryptor.CreditCardDecryptorImpl">
<Attribute adref="creditCardDecryptionKey" content="${context.creditCardDecryptionKey}" />
</Object>
</Designate>
</metatype:MetaData>

Any guidance on how to prevent bnd from generating the <Designate> element or other approaches to debug this are much appreciated.

Robert

ro6

unread,
Apr 13, 2015, 10:34:19 AM4/13/15
to bndtool...@googlegroups.com
I should also add that the metatype generated by bnd inside OSGI-INF/metatype is:

<?xml version='1.0'?>
<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.1.0" localization="com.patronpath.ring.cc.decryptor.CreditCardDecryptorImpl$Config">
  <OCD name="Credit card decryptor impl config" id="com.patronpath.ring.cc.decryptor.CreditCardDecryptorImpl">
    <AD name="Credit card decryption key" id="creditCardDecryptionKey" cardinality="0" required="true" type="String"/>
  </OCD>
  <Designate pid="com.patronpath.ring.cc.decryptor.CreditCardDecryptorImpl">
    <Object ocdref="com.patronpath.ring.cc.decryptor.CreditCardDecryptorImpl"/>
  </Designate>
</metatype:MetaData>

David Jencks

unread,
Apr 13, 2015, 11:49:51 AM4/13/15
to bndtool...@googlegroups.com
On another thread I suggested using the spec metatype annotation support in bnd master.  This will let you generate only the <OCD> elements.

DS doesn't deal with metatype in any way…. the problem must be that you aren't getting the metatype-supported configurations into config admin?

Again, what do the designate elements you need to use (the ones ACE constructs) look like?

Where is the autoconf tool ACE uses or expects from?  The metatype spec also mentions it but I haven't been able to locate it.

How does this scheme deal with (multiple) factory configurations, or don't you have any?

thanks
david jencks

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

ro6

unread,
Apr 13, 2015, 12:38:32 PM4/13/15
to bndtool...@googlegroups.com
Right, I'm not sure how to change the bnd version being used within bndtools, or are you suggesting that I use command line bnd?

The key portion of the metatype that ACE processes is:

<Designate pid="com.patronpath.ring.cc.decryptor.CreditCardDecryptorImpl"
bundle="osgi-dp:com.patronpath.ring.cc.decryptor">
<Object ocdref="com.patronpath.ring.cc.decryptor.CreditCardDecryptorImpl">
<Attribute adref="creditCardDecryptionKey" content="${context.creditCardDecryptionKey}" />
</Object>
</Designate>

ACE does variable interpolation on the ${context.someConfigPropertyName} portion before deploying the artifact, so as far as I understand the target OSGi container just receives a this exact metatype but with the desired value in the "content" attribute instead of the ${...} placeholder. The concept is explained in the ACE documentation here.

The autoconf resource processor is org.apache.felix.deployment.rp.autoconf-0.1.5.jar, which gets distributed with the binary download of ACE. I've been looking for the source code, but haven't been able to find it yet. 

I'm not sure about how this works with factories, but I'm not using them, all my services are singletons.

Thanks for your quick responses, this is the last hurdle I need to get over for putting this app in production.

Robert

ro6

unread,
Apr 13, 2015, 1:37:29 PM4/13/15
to bndtool...@googlegroups.com
Finally figured out the issue, it didn't have anything to do with metatype files getting merged together. Ultimately, it was that ACE requires the bundles and config to be part of the same deployment package, so all I had to do was add these two statements to the bundle header so that the resource processor would associate it with the metatype:

DeploymentPackage-SymbolicName: ${bsn}
DeploymentPackage-Version: ${Bundle-Version}

I'm guessing this isn't exactly the right idea with deployment packages, but it gets the job done for my use case and keeps everything nice and automated.

Robert
Reply all
Reply to author
Forward
0 new messages