Bug 1038728

Summary: The agent's config export command produces an invalid XML file
Product: [JBoss] JBoss Operations Network Reporter: Larry O'Leary <loleary>
Component: AgentAssignee: Michael Burman <miburman>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: low Docs Contact:
Priority: medium    
Version: JON 3.1.2CC: hrupp, mazz, miburman, mmahoney, myarboro
Target Milestone: ER01Keywords: Triaged
Target Release: JON 3.2.3   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 782915
: 1127873 (view as bug list) Environment:
Last Closed: 2014-09-05 15:40:30 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 782915    
Bug Blocks: 1127873    

Description Larry O'Leary 2013-12-05 16:53:37 UTC
Description of problem:
The agent's config export command produces an invalid XML file.

Bug 536138 introduced a change that results the DOCTYPE element being removed and no DTD being defined. This means that a config export from the agent produces a file that can not be imported back into the agent:

Failed to start the agent
java.lang.IllegalArgumentException: Failed to load configuration file [/tmp/00989956-agent-configuration-export.xml]. Cause: java.util.prefs.InvalidPreferencesFormatException: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 41; Document root element "preferences", must match DOCTYPE root "null".
	at org.rhq.enterprise.agent.AgentMain.processArguments(AgentMain.java:3155)
	at org.rhq.enterprise.agent.AgentMain.<init>(AgentMain.java:508)
	at org.rhq.enterprise.agent.AgentMain.main(AgentMain.java:404)


Version-Release number of selected component (if applicable):
3.1.2.GA

How reproducible:
Always

Steps to Reproduce:
1.  Install and configure JBoss ON agent.
2.  Launch agent command prompt:

        ${RHQ_AGENT_HOME}/bin/rhq-agent.sh -n
        
3.  Execute agent config export prompt command:

        config export /tmp/exported-agent-configuration.xml
        
4.  Exit agent command prompt.
5.  Re-configure agent using export configuration:

        ${RHQ_AGENT_HOME}/bin/rhq-agent.sh --cleanconfig --config /tmp/exported-agent-configuration.xml

6.  Validate /tmp/exported-agent-configuration.xml:

        xmllint --valid /tmp/exported-agent-configuration.xml


Actual results:
Agent fails to start:

    Failed to start the agent
    java.lang.IllegalArgumentException: Failed to load configuration file [/tmp/00989956-agent-configuration-export.xml]. Cause: java.util.prefs.InvalidPreferencesFormatException: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 41; Document root element "preferences", must match DOCTYPE root "null".
        at org.rhq.enterprise.agent.AgentMain.processArguments(AgentMain.java:3155)
        at org.rhq.enterprise.agent.AgentMain.<init>(AgentMain.java:508)
        at org.rhq.enterprise.agent.AgentMain.main(AgentMain.java:404)


xmllint reports:

    /tmp/exported-agent-configuration.xml:2: validity error : Validation failed: no DTD found !
    <preferences EXTERNAL_XML_VERSION="1.0">
                                           ^


Expected results:
Exported agent configuration file can be imported without error or validation warning.

Additional info:
As indicated in Bug 782915, this issue is a direct result of the work done in Bug 536138.

Comment 1 John Mazzitelli 2013-12-05 17:15:52 UTC
see bug #536138 and bug #782915 for some history on this issue.

Comment 2 John Mazzitelli 2013-12-05 17:17:23 UTC
HA! I didn't realize Larry alread mentioned those bugs from my last comment in his description - guess I should read the whole thing all the way through.

Comment 5 Michael Burman 2014-07-11 16:03:22 UTC
Fixed in master (includes unit test):

commit d6c14baa1bc2f4b8e63045abe10bf4d62878708c
Author: burmanm <miburman>
Date:   Fri Jul 11 19:00:06 2014 +0300

Comment 8 John Mazzitelli 2014-08-07 18:38:37 UTC
commit to release/jon3.2.x : fcc34701d5977e59f0c1d87366df9fd3438fb00c

Comment 9 Simeon Pinder 2014-08-15 03:19:06 UTC
Moving to ON_QA as this is available for test in JON 3.2.3 ER01 build:

http://jon01.mw.lab.eng.bos.redhat.com:8042/dist/release/jon/3.2.3.GA/8-14-14/