commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <oliver.he...@oliver-heger.de>
Subject Re: XMLConfiguration: Editing Root Node
Date Wed, 02 Jun 2010 19:03:15 GMT
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


Mime
View raw message