0

I want to have this directory structure for Tomcat7 apps:

/var/lib/tomcat7/webapps
    /foo
        /current -> /var/lib/tomcat7/webapps/foo/releases/1.1
        /releases
            /1.0
            /1.1
        /shared ...

Where current is a symlink to the actual current version of the app. As a consequence I believe I need to add a context to my server.xml file, like so:

<Context path="/foo/app" docbase="/var/lib/tomcat7/webapps/foo/current" />

The URL for foo/app would then be

http://localhost:8080/foo/app

However all I get are 404 errors. I installed tomcat-admin and it shows foo/app but isn't really helping me to see where I wired things incorrectly. I've also tried a foo.xml file in /etc/tomcat7/Catalina/localhost that specifies the path and docbase, but that didn't work either.

How do I configure the context to support the directory structure shown above?

Mark Nichols
  • 1,407
  • 2
  • 19
  • 25

1 Answers1

0

It appears that you can't have an alternate context inside appbase. If you want one that is outside of appbase then using context path and context docbase are the way to go.

Ultimately I gave up on the file structure that was forcing the use of docbase and causing my Tomcat errors.

Mark Nichols
  • 1,407
  • 2
  • 19
  • 25
  • I don't know your full configuration but you might want to check if it's deployed twice, i.e., try both these URL's http://localhost:8080/foo/app and http://localhost:8080/foo/current , if it is, then you are at risk. – Narayana Nagireddi Feb 25 '15 at 05:03
  • You might be able to make that folder structure work. It's going to be tricky though because you're fighting against the conventions that Tomcat normally follows. My suggestion would be to put your /foo directory somewhere else on the disk, not under appBase. Then just point docBase at the version you want, no symlink needed. – Daniel Mikusa Feb 27 '15 at 17:22
  • You also shouldn't put tags in server.xml. That's a configuration option that's frowned on now. It technically works, but is less flexible because it requires server restarts to activate changes. That said, the preferred option is using `app.xml` usually located in the `conf/Catalina/localhost` directory, but `/etc/tomcat7/Catalina/localhost` on your system. Another advantage of this is that you can use Tomcat 7's app versioning, which might be helpful here. http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Naming – Daniel Mikusa Feb 27 '15 at 17:42