Hi, I tried to create a client to import a wsdl to G-Reg using WS-API + Governance API. I have intentionally left setting carbon home parameter in the test client. Since this client is going to be used inside automation framework, keeping G-Reg build on client side and pointing the location is not practical. So in order to continue with governance automation, Is there any other way I can use Governance API without setting carbon home?
Exception ========================= Exception in thread "main" java.lang.NullPointerException at java.util.Hashtable.put(Hashtable.java:394) at java.util.Properties.setProperty(Properties.java:143) at java.lang.System.setProperty(System.java:729) at org.wso2.carbon.utils.CarbonUtils.getCarbonHome(CarbonUtils.java:178) at org.wso2.carbon.utils.CarbonUtils.getCarbonConfigDirPath(CarbonUtils.java:204) at org.wso2.carbon.utils.CarbonUtils.getServerXml(CarbonUtils.java:169) at org.wso2.carbon.utils.CarbonUtils.getServerConfiguration(CarbonUtils.java:465) at org.wso2.carbon.registry.core.utils.RegistryUtils.isRegistryReadOnly(RegistryUtils.java:1053) at org.wso2.carbon.registry.core.session.UserRegistry.importResource(UserRegistry.java:677) at org.wso2.carbon.governance.api.wsdls.WsdlManager.addWsdl(WsdlManager.java:96) at SimpleWsdl_Upload.main(SimpleWsdl_Upload.java:37) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115) Once I set “*CarbonHome*” as a system property it worked perfectly, wsdl was uploaded to Greg with no issues For your reference, client code is attached here with. Best Regards, Kishan
import org.apache.axis2.AxisFault; import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.context.ConfigurationContextFactory; import org.wso2.carbon.governance.api.util.GovernanceUtils; import org.wso2.carbon.governance.api.wsdls.WsdlManager; import org.wso2.carbon.governance.api.wsdls.dataobjects.Wsdl; import org.wso2.carbon.registry.core.Registry; import org.wso2.carbon.registry.core.exceptions.RegistryException; import org.wso2.carbon.registry.ws.client.registry.WSRegistryServiceClient; public class SimpleWsdl_Upload { static String GREG_HOME = "/home/kishan/Documents/WSO2_Products/wso2greg-4.0.0"; static String username = "admin"; static String password = "admin"; static String serverURL = "https://localhost:9443/services/"; // static String axis2Repo = GREG_HOME + "/repository/deployment/client"; static String axis2Conf = GREG_HOME + "/repository/conf/axis2_client.xml"; public static void main(String[] args) throws AxisFault, RegistryException { System.setProperty("javax.net.ssl.trustStore", GREG_HOME + "/repository/resources/security/client-truststore.jks"); System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon"); System.setProperty("javax.net.ssl.trustStoreType", "JKS"); System.setProperty("carbon.home", GREG_HOME); //Create Configcontext ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(axis2Repo, axis2Conf); WSRegistryServiceClient registry = new WSRegistryServiceClient(serverURL, username, password, configContext); Registry governance = GovernanceUtils.getGovernanceUserRegistry(registry, username); WsdlManager wsdlManager = new WsdlManager(governance); Wsdl wsdl = wsdlManager.newWsdl("http://geocoder.us/dist/eg/clients/GeoCoder.wsdl"); wsdl.addAttribute("version", "1.0.0"); wsdl.addAttribute("creator", "Aaaa"); wsdlManager.addWsdl(wsdl); System.out.println("wsdl was successfully added"); //Remove wsdl registry.delete("/_system/governance/trunk/wsdls/us/geocoder/rpc/geo/coder/us/GeoCoder.wsdl"); //Remove Service registry.delete("/_system/governance/trunk/services/us/geocoder/rpc/geo/coder/us/GeoCode_Service"); } }
_______________________________________________ Carbon-dev mailing list Carbon-dev@wso2.org http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev