Bug #7211

Metacat sets a wrong default value for the deploy path during the totally fresh installation

Added by Jing Tao almost 4 years ago. Updated almost 4 years ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:


Matt reported: I’ve noticed that when run from scratch, the metacat /admin utility seems to tack the /webapps/metacat onto the deployDir property, and I always have to change it. SO I think that is an admin utility bug on a totally clean deployment (i.e., with no backup directory in place).
so, this arises with clean deploys from docker and the like.

Related issues

Has duplicate Metacat - Bug #7214: Metacat overwrites the deployDir propertyClosed10/04/2017


#1 Updated by Jing Tao almost 4 years ago

I can't reproduce the bug. In mn-demo-5, I removed/backed up /var/metacat directory. So during the configuration, I was asked to input the backup directory. I created the /var/metacat directory and input /var/metadata/.metadata as the backup directory. However, my configuration still showed the deploy directory is "/var/lib/tomcat7/webapps", there is no extra "metacat". Please see the attachment.

I also looked at code:

public static String discoverDeployDir(HttpServletRequest request) {
        ServletContext servletContext = request.getSession()
        String realPath = servletContext.getRealPath(".");
        String contextPath = request.getContextPath();

        Pattern pattern = Pattern.compile(contextPath + "/\\.$");
        Matcher matcher = pattern.matcher(realPath);

        if (matcher.find()) {
            realPath = matcher.replaceFirst("");
        return realPath;

This method guess the deploy directory base on the request object. It shouldn't have the extra "metacat" if the context value is correctly detected.

#2 Updated by Jing Tao almost 4 years ago

  • Has duplicate Bug #7214: Metacat overwrites the deployDir property added

#3 Updated by Jing Tao almost 4 years ago

  • Status changed from New to Closed

The issue turns out to be Tomcat 8 has change the format of current path.
In Tomcat 7, it was /opt/local/share/java/tomcat7/webapps/metacat/.
But in Tomcat 8, it is /opt/local/share/java/tomcat8/webapps/metacat
So the fancy pattern match doesn't work.

Since we just want to remove the context part, I used the old lastIndexOf and substring method in the String class. It worked well.

#4 Updated by Jing Tao almost 4 years ago

The fix has been committed to both 2.8 branch and trunk.

#5 Updated by Jing Tao almost 4 years ago

  • Target version changed from 2.9.0 to 2.8.6

Also available in: Atom PDF