Using Governance APIs with RemoteRegistry instance throws NullPointerException

pmhiten.gmail.com's picture
When I use the below code snippet to initialize the ServiceManager in order to use Governance APIs, it throws NullPointerException as registryContext object does not get initialized when we initialize the remote registry object as below: System.setProperty("javax.net.ssl.trustStore", "../wso2greg-3.5.0/resources/security/client-truststore.jks"); System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon"); System.setProperty("javax.net.ssl.trustStoreType","JKS"); Registry registry = new RemoteRegistry(new URL("https://localhost:9443/registry"), "admin", "admin"); ServiceManager serviceManager = new ServiceManager(GovernanceUtils.getGovernanceSystemRegistry(reg)); Here is the error stacktrace Exception in thread "main" java.lang.NullPointerException at org.wso2.carbon.governance.api.util.GovernanceUtils.getRelativeServicePath(GovernanceUtils.java:389) at org.wso2.carbon.governance.api.services.dataobjects.Service.(Service.java:61) at org.wso2.carbon.governance.api.services.ServiceManager.newService(ServiceManager.java:63) So, Is this the right way to use Governance API's ? If yes, how would we initialize RegistryContext object out of the box ? There was a JIRA (CARBON-4316) already fixed for this, I guess but no details against this issue. Appreciate any suggestions ?
dimuthuc's picture

Hi, Unfortunately currently

Hi, Unfortunately currently the Governance API works only with embedded registry. And we have not tested it with remote registry. But we are expecting to support the remote registry in the upcoming releases. Thanks Dimuthu
pmhiten.gmail.com's picture

Thanks Dimuthuc for the

Thanks Dimuthuc for the info. 1) Can you please share some more info on how to use EmbeddedRegistry or direct me to an appropriate documentation? 2) Also, the documentation for Governance Registry API mentions following : To add a service, we need to have an instance of the Governance Registry. If you are inside an admin service, you can get an instance of the governance registry by inheriting from "org.wso2.carbon.core.AbstractAdmin" class and calling its getGovernanceRegistry() method. Can you please share some more information on how this would work ? Thanks. I tried multiple options but did not got it working. We really want to leverage the new Governance API to solve some of our dynamic-discovery use-cases. Thanks for the help.
c4s4l's picture

Hello, I looked at the

Hello, I looked at the roadmap but did not understood if there is an estimate when will be the next major release, is there any predictions? As pmhiten asked, is there any example of an EmbeddedRegistry usage? Thanks, Sergio
dimuthuc's picture

Hi, Before the major release,

Hi, Before the major release, there will be patch releases for the governance registry 3.5.0. We will be able to integrate governace registry to use with the registry web service API in a minor release. The only standard way that user can retrieve the governance registry is to write an OSGI bundle. From that you can retrieve the governance registry from the RegistryService OSGI service, http://wso2.org/project/registry/3.5.0/docs/apidocs/kernel/org/wso2/carbon/registry/core/service/RegistryService.html. If you are writing your code in any other WSO2 carbon server (other than WSO2 Governance Registry, like WSO2 WSAS, ESB) you can install the goverannce.meta-data p2 feature and use the API. Here is a guide on how to install some example feature into the carbon server, http://blog.afkham.org/2010/05/installing-data-services-on-wsas-320.html. This approach is not possible, if you accessing Governance API from external code. As you realized this requires the remote registry (web service API) support for the governance API. So we will let you know when we support that. Thanks, Dimuthu
c4s4l's picture

Will wait for the patch release.

Hello Dimuthu, I am accessing the governance registry from external code, so I will have to wait for your patch release. Hope it will not take a long time though, because this is for integration with an ESB from a running project. If the integration is successful my client may even require you some production support. Thanks, Sergio
c4s4l's picture

Any Updates?

Hello, Is there any updates regarding this issue? Is it planned in the jira Roadmap for version 3.6? Regards, Sergio
library project main code
Learn Cloud
Learn
Cloud

The WSO2 Application Server is a reliable application server that can host your enterprise web applications. The WSO2 Application Server as a Service is offered in StratosLive, the WSO2 Platform as a Service. This article explains how a simple web application can be developed and deployed from Carbon Studio to the WSO2 Application Server...

Latest Webinar
Different groups within an organization need to monitor different Key Performance Indicators (KPIs) - An operations team will be interested in the response times of business services and loads of each service,..
Thursday, February 9th 2012, 09.00 AM (PST)

Thursday, February 9th 2012, 10.00 AM (GMT)