0

Currently trying to setup multiple subdomains/domains in my Tomcat and I'm needing them all to use the same WEB-INF/classes/ for everything.

Basically my folder structure is like so:

Z:/
project/
    assets/   (assets.domain.com)
    main/     (www.domain.com)
    dev/      (dev.domain.com)
    WEB-INF/  (the WEB-INF I want everyone using.)
        classes/
            com/
                example/

So basically I need assets.domain.com, www.domain.com, and dev.domain.com to go up one level in the directory to find the WEB-INF and use the Java classes stored there... Is there any way to accomplish this? Thanks!

Tynarus
  • 141
  • 7

1 Answers1

1

if you are trying to share java code across webapps, you will need to package them as jar and place it in either server/lib or endorsed folder . then each deployed webapp will have access to the same class files.

Akhilesh Singh
  • 2,548
  • 1
  • 13
  • 10
  • Seems like a pain in the butt when I'm in my development environment... Isn't there some easier way? – Tynarus Oct 02 '13 at 01:47
  • There is also `server/classes` where you can put class files. Not sure if it reloads properly during development, though. – Thilo Oct 02 '13 at 01:51
  • Any way I can create a new Java project in Eclipse and have the bin/ changed to server/classes or turn it into a jar automatically and have it put into server/lib then?... I suppose that could work, decently... – Tynarus Oct 02 '13 at 01:54
  • webapps are explicitly forbidden to share class files in servlet spec. You may have to look at upgrading to ear packaging to do it in a standard way - look at tomEE however, this may be an overkill for a task like this. Another way will be to create a custom classloader for your apps -little effort and pain in butt required :) – Akhilesh Singh Oct 02 '13 at 01:55
  • Seems like a lot of pain and hardship for a few subdomains. :\ – Tynarus Oct 02 '13 at 01:59
  • Got the build path set to lib/ in my Tomcat 7 installation folder. Seems to be working with that set and making Eclipse not clean the output folder before building. Thanks for the tips! Not exactly ideal but... Hey, it works. – Tynarus Oct 02 '13 at 02:16
  • @Tynarus use `Maven` for a cleaner setup – coding_idiot Oct 02 '13 at 21:45