Bug 42899 - Creating a new context via Admin Tool fails when clicking button "commit changes"
Creating a new context via Admin Tool fails when clicking button "commit chan...
Status: RESOLVED FIXED
Product: Tomcat 5
Classification: Unclassified
Component: Catalina
5.5.23
All All
: P2 normal with 1 vote (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2007-07-15 13:25 UTC by Andres Posada
Modified: 2008-08-14 01:51 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andres Posada 2007-07-15 13:25:17 UTC
Hi,

I'm migrating from Tomcat 5.5.0 to the last version offered in
http://tomcat.apache.org, 5.5.23. When I try to create new contexts via Admin
Tool (/admin), I got a "successful" page, but then checking the Catalina logs I
get errors like the following:

org.apache.catalina.storeconfig.StandardContextSF storeWithBackup
GRAVE: Cannot move orignal context output file at
<tomcat_install_dir>/conf/Catalina/localhost/<new_context_name>.xml

And no file is written in the folder as expected. Certainly the file doesn't
exists, because is a new context and that's the name of the file that must be
created. 

I've tried this in Linux (SuSE Linux 9.2 Professional, Ubuntu 7.04) and Windows
XP and with versions 5.5.20 and 5.5.18 with no luck.

I've searched in Google and get the reference to bug 37781, "Permission error
causes malformed server.xml to be saved.". The fix was the following code:

File: StandardContextSF.java

    protected void storeWithBackup(StandardContext aContext) throws Exception {
        StoreFileMover mover = getConfigFileWriter((Context) aContext);
        if (mover != null) {
            // Bugzilla 37781 Check to make sure we can write this output file
            if ((mover.getConfigOld() == null)
                    || (!mover.getConfigOld().isFile())
                    || (!mover.getConfigOld().canWrite())) {
                log.error("Cannot move orignal context output file at "
                        + mover.getConfigOld());
                throw new IOException("Context orginal file at "
                        + mover.getConfigOld()
                        + " is null, not a file or not writable.");
            }

Which suggest that if the "old config file" doesn't exist (like in this case),
the whole operation is aborted. If I create the file just before clicking in the
button "commit changes" in the admin page, the file writes successfully and I
get the context created as expected. 

In our case we tried to go back to version 5.5.16 (which is the version prior to
the fix) and in that version this operation works just fine. 

Can you check this behavior? Thanks!
Comment 1 Mark Thomas 2008-05-10 02:47:30 UTC
Yep, this is broken.

I have proposed a patch (http://people.apache.org/~markt/patches/2008-05-10-bug42899.patch) to fix this.
Comment 2 Mark Thomas 2008-08-14 01:51:44 UTC
This has been fixed in 5.5.x and will be included in 5.5.27 onwards.