-1

我得到了这个例外

    at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisO
peration.java:413) ~[axis2_1.6.1-wso2v7.jar:na]
    at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(Out
InAxisOperation.java:224) ~[axis2_1.6.1-wso2v7.jar:na]
Caused by: org.apache.axiom.om.OMException: Stream Errorjava.io.IOException: Bad
 chunk size:
    at org.apache.axiom.attachments.Attachments.<init>(Attachments.java:242)
 ~[axiom_1.2.11-wso2v3.jar:na]
    at org.apache.axis2.builder.BuilderUtil.createAttachments(BuilderUtil.ja
va:594) ~[axis2_1.6.1-wso2v7.jar:na]
    at org.apache.axis2.builder.BuilderUtil.createAttachmentsMap(BuilderUtil
.java:545) ~[axis2_1.6.1-wso2v7.jar:na]
    at org.apache.axis2.builder.MIMEBuilder.processDocument(MIMEBuilder.java
:39) ~[axis2_1.6.1-wso2v7.jar:na]
    at org.apache.axis2.transport.TransportUtils.createDocumentElement(Trans
portUtils.java:179) ~[axis2_1.6.1-wso2v7.jar:na]
    at org.apache.axis2.transport.TransportUtils.createSOAPMessage(Transport
Utils.java:145) ~[axis2_1.6.1-wso2v7.jar:na]
Caused by: java.io.IOException: Bad chunk size:
    at org.apache.commons.httpclient.ChunkedInputStream.getChunkSizeFromInpu
tStream(ChunkedInputStream.java:306) ~[commons-httpclient_3.1.0-wso2v2.jar:na]
    at org.apache.commons.httpclient.ChunkedInputStream.nextChunk(ChunkedInp
utStream.java:221) ~[commons-httpclient_3.1.0-wso2v2.jar:na]
    at org.apache.commons.httpclient.ChunkedInputStream.read(ChunkedInputStr
eam.java:146) ~[commons-httpclient_3.1.0-wso2v2.jar:na]
    at java.io.FilterInputStream.read(FilterInputStream.java:83) ~[na:1.7.0_
04]
    at org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInpu
tStream.java:88) ~[commons-httpclient_3.1.0-wso2v2.jar:na]
    at java.io.FilterInputStream.read(FilterInputStream.java:83) ~[na:1.7.0_
04]
org.wso2.carbon.governance.api.exception.GovernanceException: Error in retrievin
g governance artifact by path. path: /trunk/schemas/com/mycorp/xmlns/common/faul
t/v1/common_fault_v1.2.xsd.
    at org.wso2.carbon.governance.api.util.GovernanceUtils.retrieveGovernanc
eArtifactByPath(GovernanceUtils.java:805)
    at org.wso2.carbon.governance.api.schema.SchemaManager.getAllSchemas(Sch
emaManager.java:385)
    at org.wso2.carbon.governance.api.schema.SchemaManager.findSchemas(Schem
aManager.java:351)
    at wso2client.SchemaDAO.getReusableSchemas(SchemaDAO.java:62)

当我在我的类 wso2client.SchemaDAO 中运行以下代码时:

public static List<models.domain.Schema> getReusableSchemas() {
    List<models.domain.Schema> domainSchemas = null;
    try {
        registry = Util.initialize();
        governanceRegistry = Util.getGovernanceRegistry(registry);

        // starting with the schema manager created with governanceRegistry
        schemaManager = new SchemaManager(governanceRegistry);

        // get schemas with attribute "creator" == "yyy"
        List<Schema> schemas = Arrays.asList(
            schemaManager.findSchemas(new ReusableSchemaFilter())
        );

        System.out.println("Number of matches:" + schemas.size());
        domainSchemas = DTOMapper.Wso2Schemas2DomainSchemas(schemas);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } 
    return domainSchemas;
}

private static class ReusableSchemaFilter implements SchemaFilter {

    @Override
    public boolean matches(Schema wso2Schema) throws GovernanceException {
        boolean schemaIsReusable = false;
        // in order to read the properties (not attributes!) of the schema I need to retrieve the resource.
        try {
            Resource resource = governanceRegistry.get(wso2Schema.getPath());

            boolean isDeprecated = "Deprecated".equals(wso2Schema.getLifecycleState());
            boolean isCanonical = "canonicalInformation1".equals(resource.getProperty("informationModelRelation"));
            schemaIsReusable = (isCanonical && !isDeprecated);
        } catch (RegistryException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return schemaIsReusable;
    }

}

你知道可能是什么问题吗?

4

1 回答 1

0

我改变了过滤器如下:

private static class ReusableSchemaFilter implements SchemaFilter {

    @Override
    public boolean matches(Schema wso2Schema) throws GovernanceException {
        boolean schemaIsReusable = false;
        // in order to read the properties (not attributes!) of the schema I need to retrieve the resource.
        try {
            //Resource resource = governanceRegistry.get(wso2Schema.getPath());

            boolean isDeprecated = "Deprecated".equals(wso2Schema.getLifecycleState());
            boolean isCanonical = "canonicalInformation1".equals(wso2Schema.getAttribute("informationModelRelation"));
            schemaIsReusable = (isCanonical && !isDeprecated);
        } catch (RegistryException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return schemaIsReusable;
    }

}

换句话说,我在 WSO2 Schema 类上使用了 getAttribute 而不是使用 Resource 类的 getProperty,我没有得到任何异常。

我仍然对为什么可以使用 getAttribute 方法检索 Schema 的属性值感到困惑。不能使用 setAttribute 方法来设置相同的属性。为此,您需要使用 setProperty。

于 2013-04-25T09:11:05.003 回答