Giter Site home page Giter Site logo

hqapi's People

Contributors

bsnyder avatar nebhale avatar patrickbinh avatar rmorgan avatar sfeldstein-vmware avatar wjs-broadcom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hqapi's Issues

AlertDefinitionCommand sync fails with class cast error

Attempting to sync the following XML via hqapi.sh alertdefinition sync --file produces the error immediately after it.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AlertDefinitionResponse>
    <Status>Success</Status>
    <AlertDefinition mtime="1354626457188" ctime="1353803425597" id="298258" name="Linux Platform Availability - PROBLEM" description="https://extranet.contegix.com/display/CNT/Platform+Availability" parent="98431" priority="2" enabled="false" active="false" frequency="0" count="0" range="0" willRecover="true" notifyFiltered="false" controlFiltered="false">
        <Resource id="178032" name="rmc-testing.contegix.com"/>
        <Escalation id="11009" name="RMC Escalation" description="Test escalation for Rich" pauseAllowed="false" maxPauseTime="9223372036854775807" notifyAll="false" repeat="true"/>
        <AlertCondition required="true" type="1" thresholdValue="1.0" thresholdComparator="!=" thresholdMetric="Availability"/>
        <AlertAction id="11744316" className="org.hyperic.hq.measurement.action.MetricAlertAction"/>
    </AlertDefinition>
</AlertDefinitionResponse>

Error running command: null
java.lang.ClassCastException
at java.lang.Class.cast(Class.java:2990)
at org.hyperic.hq.hqapi1.XmlUtil.deserialize(XmlUtil.java:68)
at org.hyperic.hq.hqapi1.tools.AlertDefinitionCommand.sync(AlertDefinitionCommand.java:439)
at org.hyperic.hq.hqapi1.tools.AlertDefinitionCommand.handleCommand(AlertDefinitionCommand.java:152)
at org.hyperic.hq.hqapi1.tools.Shell.dispatchCommand(Shell.java:244)
at org.hyperic.hq.hqapi1.tools.Shell.main(Shell.java:259)

Digging into the source, the issue seems to be that the sync method in AlertDefinitionCommand.java passes an object of type AlertDefinitionsResponse to XmlUtil.deserialize, which then attempts to cast it to an object of type AlertDefinitionResponse. I confirmed this by modifying the deserialize method in XmlUtil.java to have some debugging text:

    public static <T> T deserialize(Class<T> res, InputStream is)
        throws JAXBException
    {
        String pkg = res.getPackage().getName();
        JAXBContext jc = getCachedContext(pkg);
        Unmarshaller u = jc.createUnmarshaller();
        u.setEventHandler(new DefaultValidationEventHandler());
        Object unmarshalOut = u.unmarshal(is);
        System.out.println(res.getName());
        System.out.println(unmarshalOut.getClass().getName());
        return res.cast(unmarshalOut);
    }

When built and run with the same command, it produces the following output:

org.hyperic.hq.hqapi1.types.AlertDefinitionsResponse
org.hyperic.hq.hqapi1.types.AlertDefinitionResponse
Error running command: null
java.lang.ClassCastException
at java.lang.Class.cast(Class.java:2990)
at org.hyperic.hq.hqapi1.XmlUtil.deserialize(XmlUtil.java:68)
at org.hyperic.hq.hqapi1.tools.AlertDefinitionCommand.sync(AlertDefinitionCommand.java:439)
at org.hyperic.hq.hqapi1.tools.AlertDefinitionCommand.handleCommand(AlertDefinitionCommand.java:152)
at org.hyperic.hq.hqapi1.tools.Shell.dispatchCommand(Shell.java:244)
at org.hyperic.hq.hqapi1.tools.Shell.main(Shell.java:259)

This demonstrates that the res object is of type org.hyperic.hq.hqapi1.types.AlertDefinitionsResponse while the object returned by the JAXB unmarshaller is of type org.hyperic.hq.hqapi1.types.AlertDefinitionResponse.

The only workaround I have found so far is to manually change the root node of the XML to be synced to be AlertDefinitionsResponse instead of AlertDefinitionResponse, such as the following:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AlertDefinitionsResponse>
    <Status>Success</Status>
    <AlertDefinition mtime="1354626457188" ctime="1353803425597" id="298258" name="Linux Platform Availability - PROBLEM" description="https://extranet.contegix.com/display/CNT/Platform+Availability" parent="98431" priority="2" enabled="false" active="false" frequency="0" count="0" range="0" willRecover="true" notifyFiltered="false" controlFiltered="false">
        <Resource id="178032" name="rmc-testing.contegix.com"/>
        <Escalation id="11009" name="RMC Escalation" description="Test escalation for Rich" pauseAllowed="false" maxPauseTime="9223372036854775807" notifyAll="false" repeat="true"/>
        <AlertCondition required="true" type="1" thresholdValue="1.0" thresholdComparator="!=" thresholdMetric="Availability"/>
        <AlertAction id="11744316" className="org.hyperic.hq.measurement.action.MetricAlertAction"/>
    </AlertDefinition>
</AlertDefinitionsResponse>

This issue has also been reported here: http://communities.vmware.com/message/2164480

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.