You should use the OSGi service which exposes the FeaturesService interface.
2016-06-17 8:47 GMT+02:00 Srivastava Rajani <[email protected]>: > > Hi, > > We are using org.apache.karaf.features jar(3.0.6 version) as a dependency > for our maven project using karaf framework. > > First issue is, using this dependency,some imports are not getting > resolved such as : > org.apache.karaf.features.internal.FeaturesServiceImpl; > org.apache.karaf.features.internal.BundleManager; > > We want to get bundles and features list using APIs not through the > command line. > > We are able to get the bundles list using org.osgi.framework, second issue > is if somehow imports are resolved, we are getting error for features list. > The code is as follows : > > URI uri = new > URI("mvn:org.opendaylight.cardinal/cardinal-features/0.1.0-SNAPSHOT/xml/features"); > BundleContext bundleContext = > FrameworkUtil.getBundle(MyClass.class).getBundleContext(); > Bundle[] list= bundleContext.getBundles(); > BundleManager bundleManager = new BundleManager(bundleContext); > FeaturesServiceImpl svc = new FeaturesServiceImpl(bundleManager); > svc.addRepository(uri); > Repository[] repositories = svc.listRepositories(); > Feature[] features = repositories[0].getFeatures(); > > > For any uri, we are getting this error: > > org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema > document 'null', because 1) could not find the document; 2) the document > could not be read; 3) the root element of the document is not <xsd:schema>. > at > org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown > Source) > at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source) > at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) > at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) > at > org.apache.xerces.impl.xs.traversers.XSDHandler.reportSchemaError(Unknown > Source) > at > org.apache.xerces.impl.xs.traversers.XSDHandler.getSchemaDocument1(Unknown > Source) > at > org.apache.xerces.impl.xs.traversers.XSDHandler.getSchemaDocument(Unknown > Source) > at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown > Source) > at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source) > at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown > Source) > at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown > Source) > at > org.apache.xerces.jaxp.validation.XMLSchemaFactory.newSchema(Unknown Source) > at javax.xml.validation.SchemaFactory.newSchema(Unknown Source) > at > org.apache.karaf.features.internal.FeatureValidationUtil.validate(FeatureValidationUtil.java:112) > at > org.apache.karaf.features.internal.FeatureValidationUtil.validate(FeatureValidationUtil.java:68) > at > org.apache.karaf.features.internal.FeaturesServiceImpl.validateRepository(FeaturesServiceImpl.java:164) > at > org.apache.karaf.features.internal.FeaturesServiceImpl.internalAddRepository(FeaturesServiceImpl.java:235) > at > org.apache.karaf.features.internal.FeaturesServiceImpl.addRepository(FeaturesServiceImpl.java:186) > at > org.apache.karaf.features.internal.FeaturesServiceImpl.addRepository(FeaturesServiceImpl.java:174) > > Kindly help to resolve it. > > Thanks & Regards > Rajani Srivastava > Systems Engineer > Tata Consultancy Services > Ground to 8th Floors, Building No. 1 & 2, > Skyview Corporate Park, Sector 74A,NH 8 > Gurgaon - 122 004,Haryana > India > Cell:- +91-124-6213214 > Mailto: [email protected] > Website: http://www.tcs.com > ____________________________________________ > Experience certainty. IT Services > Business Solutions > Consulting > ____________________________________________ > > =====-----=====-----===== > Notice: The information contained in this e-mail > message and/or attachments to it may contain > confidential or privileged information. If you are > not the intended recipient, any dissemination, use, > review, distribution, printing or copying of the > information contained in this e-mail message > and/or attachments to it are strictly prohibited. If > you have received this communication in error, > please notify us by reply e-mail or telephone and > immediately and permanently delete the message > and any attachments. Thank you > > > -- ------------------------ Guillaume Nodet ------------------------ Red Hat, Open Source Integration Email: [email protected] Web: http://fusesource.com Blog: http://gnodet.blogspot.com/
