When not to use this server location when using tomcat within Eclipse
Asked Answered
W

3

9

When using tomcat within Eclipse why would I ever not want to use the tomcat installation as checked in the attached image. I always use the "Tomcat Installation" Are there advantages/disadvantages of using the other Tomcat server locations.

enter image description here

Worn answered 20/12, 2011 at 18:11 Comment(0)
R
12

In fact, I always Use Workspace Metadata. When you say Use workspace metadata, Eclipse copies your files (class files, jsps, server.xml, context.xml) to /.metadata/.plugins/org.eclipse.wst.server.core/tmp0. It then starts Tomcat using these files. It does not change the Tomcat installation directory at all. Note that this doesn't copy the tomcat files, just the files which come from your project.

If you choose Use Tomcat Installation, then it copies your files into the Tomcat installation directory, and boots it from there.

If, like me, you're developing multiple projects from multiple workspaces, then this makes a big difference. With Use Workspace Metadata you will never get any interference between workspaces. For instance, it's possible that when rebooting Tomcat, one project will be in a bad state and your logs will be filled with stuff from another project. It's better to have two separate locations, and the workspace is a good place for this.

Rozek answered 20/12, 2011 at 19:40 Comment(0)
R
1

Always try to use use workspace metadata ...

this option delpoys the web app in the workspace directory

~WORKSPACE\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps

so you have different work spaces for different projects , you will have applications deployed in different spaces and this solves ambiguity in deployment.

even if you have singe application, this is recommended

if you select use tomcat installation... , you will have to be careful while dealing with multiple applications as the old application will be overridden by the newly deployed web application.

when you select use custom location ... then you need to be more careful while handling multiple applications as you manually give the locations for deployment

Reckless answered 19/4, 2017 at 19:23 Comment(0)
P
0

I'll add a little bit to Matthew Farwell's explanation.

If you see the Server Locations area grayed out, you must first remove all applications you've added to the server configuration and clean the working directory. It seems that if you don't clean the working directory, you'll get some startup error when you Start or Debug the server. Once you do that, your will then be able to change Server Locations. You then add the application you removed back to the server. You can add then either before or after starting the server.

When you use an Eclipse Tomcat server I observed that the "server.xml" file gets slightly modified. It gets some "Context" elements added to the server.xml. If you later switch back to using the metadata, those added "Context" elements get removed. So it's not exactly true to say that it just makes a copy. It makes a copy with some minor changes to the configuration files.

And lastly, if you right click on you server configuration and select properties, you get a dialog box that lets you "switch location". Making the change there, does not seem to be the same thing as changing "server location". Your still using the metadata location (with a different tmp directory). I was only able to get it to switch to the Tomcat installation by double clicking on the server configuration. That brings a the configuration page and where you can change server locations. It's probably because I really don't understand what the "switch location" in the property page does. It confused me and I thought it might confuse others.

Peekaboo answered 30/11, 2023 at 2:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.