internal tomcat server.xml parsing

View: New views
4 Messages — Rating Filter:   Alert me  

internal tomcat server.xml parsing

by Ramesh Narayanan (ramesnar) :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi folks
               Has anyone ventured into modifying the conf/server.xml
file using the default internal XML parser of tomcat? I am currently in
a midst of a project where I am securing all in bound and out bound
communications and to that effect I have generated a SSL certificate
using our CA and when I configure manually the new keystore, keypass,
truststore, trust password, everything works like a charm. I need the
capability to just go and change these attribs at run time and restart
the tomcat server and want the new cert to load. I know I can write my
own SAX or DOM parser to achieve this, but I thought since Tomcat
internally parses this file anyways, if this parsing and persisting into
java objects is already available?

Can anyone volunteer to help me out please?

Thanks
Ramesh


Re: internal tomcat server.xml parsing

by Christopher Schultz-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ramesh,

Ramesh Narayanan (ramesnar) wrote:
| Has anyone ventured into modifying the conf/server.xml file using the
| default internal XML parser of tomcat?

IIRC, Tomcat uses commons-digester to load its XML configuration. The
digester does not have POJO->XML capabilities, so you'll have to build
them yourself.

| I am currently in a midst of a project where I am securing all in
| bound and out bound communications and to that effect I have
| generated a SSL certificate using our CA and when I configure
| manually the new keystore, keypass, truststore, trust password,
| everything works like a charm. I need the capability to just go and
| change these attribs at run time and restart the tomcat server and
| want the new cert to load.

I would recommend parameterizing the server.xml file and using simple
string replacement rather than re-parsing the server.xml file each time
and re-writing the entire thing. This will allow you to keep comments
and leave unexpected elements untouched.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkgrIyoACgkQ9CaO5/Lv0PBzawCgty1MYNof9HGfv7m7mGV4QoFF
hHoAn2D978k1fVVYSjmcuj1GnvbEaXXl
=yKnR
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@...
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


RE: internal tomcat server.xml parsing

by Ramesh Narayanan (ramesnar) :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Chris
         Thanks for your reply. I was thinking the Tomcat would parse
the XML and store it in its internal datastructures/beans but how
terribly wrong I am! I also thought about using JMX to load/reload these
properties once parsed from server.xml file. I was scourging the tomcat
API documentation yesterday and I knew it used Commons digester to parse
the config file, but I didn't knew it didn't  build java objects after
parsing.

So, I understand, the good old kludgy String manipulation is the ONLY
good approach here and here I am off to do that stuff.

--Ramesh

-----Original Message-----
From: Christopher Schultz [mailto:chris@...]
Sent: Wednesday, May 14, 2008 10:37 AM
To: Tomcat Users List
Subject: Re: internal tomcat server.xml parsing

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ramesh,

Ramesh Narayanan (ramesnar) wrote:
| Has anyone ventured into modifying the conf/server.xml file using the
| default internal XML parser of tomcat?

IIRC, Tomcat uses commons-digester to load its XML configuration. The
digester does not have POJO->XML capabilities, so you'll have to build
them yourself.

| I am currently in a midst of a project where I am securing all in
| bound and out bound communications and to that effect I have
| generated a SSL certificate using our CA and when I configure
| manually the new keystore, keypass, truststore, trust password,
| everything works like a charm. I need the capability to just go and
| change these attribs at run time and restart the tomcat server and
| want the new cert to load.

I would recommend parameterizing the server.xml file and using simple
string replacement rather than re-parsing the server.xml file each time
and re-writing the entire thing. This will allow you to keep comments
and leave unexpected elements untouched.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkgrIyoACgkQ9CaO5/Lv0PBzawCgty1MYNof9HGfv7m7mGV4QoFF
hHoAn2D978k1fVVYSjmcuj1GnvbEaXXl
=yKnR
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@...
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


---------------------------------------------------------------------
To start a new topic, e-mail: users@...
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: internal tomcat server.xml parsing

by Christopher Schultz-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ramesh,

Ramesh Narayanan (ramesnar) wrote:
| Thanks for your reply. I was thinking the Tomcat would parse
| the XML and store it in its internal datastructures/beans but how
| terribly wrong I am!

No, Tomcat does do that. But it uses the commons-digester to accomplish it.

| I also thought about using JMX to load/reload these
| properties once parsed from server.xml file. I was scourging the tomcat
| API documentation yesterday and I knew it used Commons digester to parse
| the config file, but I didn't knew it didn't  build java objects after
| parsing.

It must build some of them.

| So, I understand, the good old kludgy String manipulation is the ONLY
| good approach here and here I am off to do that stuff.

I don't find it klugey at all, actually. I use parameterized server.xml
files for all my projects and use ant to merge the local configuration
into them (things like port numbers, etc.). It seems to work quite well
for us.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkgrKJoACgkQ9CaO5/Lv0PCZJgCeII857NC3NHmo1E/5LYq9A0JX
MFwAoLkyQOpP3/wEegPf8QroNuS2cdMm
=tw6u
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@...
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...