在ServiceManager上调用findServices时的类转发异常

时间:2013-10-15 15:34:15

标签: wso2 wso2carbon

我正在尝试使用org.wso2.carbon.registry.ws.client.registry.WSRegistryServiceClient来创建一个注册表对象。目标是查找具有特定属性的服务。尝试运行以下代码:

WSRegistryServiceClient registry = new WSRegistryServiceClient(serverURL, "admin", "admin", configContext);
    org.wso2.carbon.governance.api.services.ServiceManager serviceManager = new org.wso2.carbon.governance.api.services.ServiceManager(registry); 
        Service[] services = serviceManager.findServices(new ServiceFilter() 
        {
                public boolean matches(Service service) throws GovernanceException {
                        String attributeVal = service.getAttribute("owner_name");
                        return (attributeVal != null && attributeVal.equals("someName"));
                    }
                });

我得到了分类播放异常

      java.lang.ClassCastException: org.wso2.carbon.registry.ws.client.registry.WSRegistryServiceClient cannot be cast to org.wso2.carbon.registry.core.session.UserRegistry exception
at org.wso2.carbon.governance.api.util.GovernanceUtils.retrieveGovernanceArtifactByPath(GovernanceUtils.java:819)
    at org.wso2.carbon.governance.api.common.GovernanceArtifactManager.getAllGovernanceArtifacts(GovernanceArtifactManager.java:663)
    at org.wso2.carbon.governance.api.services.ServiceManager.getAllServices(ServiceManager.java:213)
    at org.wso2.carbon.governance.api.services.ServiceManager.findServices(ServiceManager.java:186)

WSO2的文档演示了如何使用WSRegistryServiceClient添加服务,但我找不到演示搜索服务的示例。我使用相同的客户端来搜索服务,但它抛出了上述异常。搜索服务的方式是什么?

另外,有没有办法从WSRegistryServiceClient创建UserRegistry对象,或者有不同的api来创建UserRegistry?

0 个答案:

没有答案