You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Scott Dudley <sc...@telesoft.com> on 2010/06/02 01:32:23 UTC

XMLConfiguration: Editing Root Node

I'm attempting to use XMLConfiguration to edit the Tomcat server.xml 
file.  I created a fragment with which to test:

<Server port="8005" shutdown="SHUTDOWN">
  <Service name="Catalina">
    <Connector connectionTimeout="20000" port="80" protocol="HTTP/1.1" 
redirectPort="8443"/>
  </Service>
</Server>

The following snippet first reads the Connector port and then sets both 
the Server and Connector ports to values based on same.

            XMLConfiguration xml = new 
XMLConfiguration("/home/scott/x.xml");
            int port = 
TFormatter.parseInt(xml.getString("Service.Connector[@port]"));  //80;
            xml.setProperty("[@port]", String.valueOf(6100+port));
            xml.setProperty("Service.Connector[@port]", 
String.valueOf(6000+port));
            // if i display the two properties at this point, they are 
as expected - 6180 and 6080
            xml.save();

The save does no overwrite the Server port.  It remains set to 8005.

What am I missing?

Many thanks.

-- 
Scott Dudley


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: XMLConfiguration: Editing Root Node

Posted by Oliver Heger <ol...@oliver-heger.de>.
Am 02.06.2010 22:01, schrieb Scott Dudley:
>
>
> Oliver Heger wrote:
>> Scott,
>>
>> which version of Commons Configuration do you use? Older versions had
>> a bug related to manipulations of attributes of the root element.
>> Details can be found in [1]. So maybe you are hit by this bug.
> Oliver,
>
> I'm using 1.2 but also downloaded and tested with 1.6 - same result.
>
> I did find that I'm able to set it by first calling clearProperty
> followed by addProperty. That works.
>
> My issue sounded much like this:
> http://apache-commons.680414.n4.nabble.com/jira-Created-CONFIGURATION-296-XMLConfiguration-and-attributes-on-the-root-node-td748669.html
>

Scott,

there is a test case in the junit test for XMLConfiguration [1] which 
checks exactly this scenario. So I am pretty convinced that changing 
attributes of the root element via setProperty() works.

Is it possible that somewhere in your classpath is still an old version 
of Commons Configuration? The bug you are referring to has been fixed in 
Configuration 1.5.

Oliver

[1] 
http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestXMLConfiguration.java?view=markup

>>
>> Oliver
>>
>> [1] https://issues.apache.org/jira/browse/CONFIGURATION-296
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: XMLConfiguration: Editing Root Node

Posted by Scott Dudley <sc...@telesoft.com>.

Oliver Heger wrote:
> Scott,
>
> which version of Commons Configuration do you use? Older versions had 
> a bug related to manipulations of attributes of the root element. 
> Details can be found in [1]. So maybe you are hit by this bug.
Oliver,

I'm using 1.2 but also downloaded and tested with 1.6 - same result.

I did find that I'm able to set it by first calling clearProperty 
followed by addProperty.  That works.

My issue sounded much like this: 
http://apache-commons.680414.n4.nabble.com/jira-Created-CONFIGURATION-296-XMLConfiguration-and-attributes-on-the-root-node-td748669.html
>
> Oliver
>
> [1] https://issues.apache.org/jira/browse/CONFIGURATION-296
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

-- 
Scott Dudley
Senior Developer

Telesoft Corp. | 3443 N. Central Ave., 18th Floor | Phoenix, AZ, 85012

*o:* (602) 308-1115* *| *f:* (602) 308-1300 | *w:* www.telesoft.com 
<http://www.telesoft.com/?utm_source=signature&utm_medium=email&utm_campaign=signature>

<http://www.telesoft.com/?utm_source=signature&utm_medium=email&utm_campaign=signature> 
<http://www.telesoft.com/sites/default/files/go/signature.html>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: XMLConfiguration: Editing Root Node

Posted by Oliver Heger <ol...@oliver-heger.de>.
Am 02.06.2010 01:32, schrieb Scott Dudley:
>
> I'm attempting to use XMLConfiguration to edit the Tomcat server.xml
> file. I created a fragment with which to test:
>
> <Server port="8005" shutdown="SHUTDOWN">
> <Service name="Catalina">
> <Connector connectionTimeout="20000" port="80" protocol="HTTP/1.1"
> redirectPort="8443"/>
> </Service>
> </Server>
>
> The following snippet first reads the Connector port and then sets both
> the Server and Connector ports to values based on same.
>
> XMLConfiguration xml = new XMLConfiguration("/home/scott/x.xml");
> int port =
> TFormatter.parseInt(xml.getString("Service.Connector[@port]")); //80;
> xml.setProperty("[@port]", String.valueOf(6100+port));
> xml.setProperty("Service.Connector[@port]", String.valueOf(6000+port));
> // if i display the two properties at this point, they are as expected -
> 6180 and 6080
> xml.save();
>
> The save does no overwrite the Server port. It remains set to 8005.
>
> What am I missing?
>
> Many thanks.
>
Scott,

which version of Commons Configuration do you use? Older versions had a 
bug related to manipulations of attributes of the root element. Details 
can be found in [1]. So maybe you are hit by this bug.

Oliver

[1] https://issues.apache.org/jira/browse/CONFIGURATION-296

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org