Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » Eclipse WTP Context root change, Tomcat and the WAR file
Eclipse WTP Context root change, Tomcat and the WAR file [message #760013] Wed, 30 November 2011 17:45 Go to next message
Russell Bateman is currently offline Russell Bateman
Messages: 3138
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

If I change the context root of a web application (I'm running Tomcat
and I switch from my long and ugly project name to something nicer via
Properties -> Web Project Settings -> Context root:), I see a
publish.dat on the path
..metadata/.plugins/org.eclipse.wst.server.core/publish that changes when
I clean and republish the project. I assume that's what makes it so I
can type a different URI to get to my application.

This said then, when I export my application to WAR, then examine the
WAR (jar -xf ugly-project-name.war), I see nothing added to my web.xml
or any other file that would suggest to Tomcat that the context root is
something other than the <display-name> element in web.xml, which is
still the old project name.

Where's this information hiding?

Thanks!
Re: Eclipse WTP Context root change, Tomcat and the WAR file [message #760015 is a reply to message #760013] Wed, 30 November 2011 18:14 Go to previous messageGo to next message
Russell Bateman is currently offline Russell Bateman
Messages: 3138
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 30-Nov-11 15:45, Russell Bateman wrote:
> If I change the context root of a web application (I'm running Tomcat
> and I switch from my long and ugly project name to something nicer via
> Properties -> Web Project Settings -> Context root:), I see a
> publish.dat on the path
> .metadata/.plugins/org.eclipse.wst.server.core/publish that changes when
> I clean and republish the project. I assume that's what makes it so I
> can type a different URI to get to my application.
>
> This said then, when I export my application to WAR, then examine the
> WAR (jar -xf ugly-project-name.war), I see nothing added to my web.xml
> or any other file that would suggest to Tomcat that the context root is
> something other than the <display-name> element in web.xml, which is
> still the old project name.
>
> Where's this information hiding?
>
> Thanks!

Sorry, I didn't mean to say that the solution should be in web.xml, but
META-INF/context.xml which I would have expected. Whatever the case, I
can see nothing inside my WAR file that will have the stated effect.

How does Eclipse cause this to happen? (Or, what am I missing?)
Re: Eclipse WTP Context root change, Tomcat and the WAR file [message #760018 is a reply to message #760015] Wed, 30 November 2011 18:22 Go to previous messageGo to next message
Russell Bateman is currently offline Russell Bateman
Messages: 3138
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 30-Nov-11 16:14, Russell Bateman wrote:
> On 30-Nov-11 15:45, Russell Bateman wrote:
>> If I change the context root of a web application (I'm running Tomcat
>> and I switch from my long and ugly project name to something nicer via
>> Properties -> Web Project Settings -> Context root:), I see a
>> publish.dat on the path
>> .metadata/.plugins/org.eclipse.wst.server.core/publish that changes when
>> I clean and republish the project. I assume that's what makes it so I
>> can type a different URI to get to my application.
>>
>> This said then, when I export my application to WAR, then examine the
>> WAR (jar -xf ugly-project-name.war), I see nothing added to my web.xml
>> or any other file that would suggest to Tomcat that the context root is
>> something other than the <display-name> element in web.xml, which is
>> still the old project name.
>>
>> Where's this information hiding?
>>
>> Thanks!
>
> Sorry, I didn't mean to say that the solution should be in web.xml, but
> META-INF/context.xml which I would have expected. Whatever the case, I
> can see nothing inside my WAR file that will have the stated effect.
>
> How does Eclipse cause this to happen? (Or, what am I missing?)

I guess one answer is to name the exported WAR file carefully to what I
did in the Web Project Settings above? But, this sort-of defeats the
purpose of having such a settings (which would only be to tell Eclipse
to disregard the project name during development). When exporting to
WAR, the default name proposed is still the "long, ugly" one of course.
Re: Eclipse WTP Context root change, Tomcat and the WAR file [message #760169 is a reply to message #760018] Thu, 01 December 2011 09:13 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry Isaacs
Messages: 1304
Registered: July 2009
Senior Member
On 11/30/2011 6:22 PM, Russell Bateman wrote:
> On 30-Nov-11 16:14, Russell Bateman wrote:
>> On 30-Nov-11 15:45, Russell Bateman wrote:
>>> If I change the context root of a web application (I'm running Tomcat
>>> and I switch from my long and ugly project name to something nicer via
>>> Properties -> Web Project Settings -> Context root:), I see a
>>> publish.dat on the path
>>> .metadata/.plugins/org.eclipse.wst.server.core/publish that changes when
>>> I clean and republish the project. I assume that's what makes it so I
>>> can type a different URI to get to my application.
>>>
>>> This said then, when I export my application to WAR, then examine the
>>> WAR (jar -xf ugly-project-name.war), I see nothing added to my web.xml
>>> or any other file that would suggest to Tomcat that the context root is
>>> something other than the <display-name> element in web.xml, which is
>>> still the old project name.
>>>
>>> Where's this information hiding?
>>>
>>> Thanks!
>>
>> Sorry, I didn't mean to say that the solution should be in web.xml, but
>> META-INF/context.xml which I would have expected. Whatever the case, I
>> can see nothing inside my WAR file that will have the stated effect.
>>
>> How does Eclipse cause this to happen? (Or, what am I missing?)
>
> I guess one answer is to name the exported WAR file carefully to what I
> did in the Web Project Settings above? But, this sort-of defeats the
> purpose of having such a settings (which would only be to tell Eclipse
> to disregard the project name during development). When exporting to
> WAR, the default name proposed is still the "long, ugly" one of course.

When the WTP Tomcat plug-ins publish a project to the Tomcat server,
some "adjustments" are made to the server configuration that gets
published. One of those adjustments is to ensure that the context is
served according to the project's "Context root" setting. Also, note
that the published server configuration makes no use of any
auto-deployment features, i.e. it's more equivalent to an automated
"manual" deployment.

The name of the exported war comes from the "deploy-name" attribute
found in the ".settings/org.eclipse.wst.common.component" of the
project. It typically matches the project name, which helps ensure that
no two project are using the same "deploy-name".

Many WTP major versions ago, there would be problems if "deploy-name" !=
"project name". Some pieces of code would use the project name to "ID"
project and others would use the "deploy-name". If they were not the
same, some operations wouldn't be able to find the project if given an
"ID" based on the wrong name. It has been so long, I don't know if this
is still a problem. You could try modifying the "deploy-name" to see
what happens, and if it hurts, don't do that. I would recommend
removing the project from all servers and publishing them before making
such a change. I believe the Tomcat plug-ins use the "deploy-name" for
the name of the directory the project is published to. There is no
provision for remembering what the old value was, so if you don't remove
it from the server first, an old un-served copy of the project will be
left behind on the server.

Your alternative is to keep project name as the war file name and
manually deploy the war, or expanded directory of it, on the Tomcat
server. That will allow you to control the "context root" regardless of
the name of the war or directory.

Cheers,
Larry
Re: Eclipse WTP Context root change, Tomcat and the WAR file [message #760215 is a reply to message #760169] Thu, 01 December 2011 10:53 Go to previous message
Russell Bateman is currently offline Russell Bateman
Messages: 3138
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

Thanks for these additional explanations, Larry.

Best,

Russ
Previous Topic:How to add CSS autocomplete in web pages in eclipse
Next Topic:Packaging http://www.w3.org/2003/05/soap-envelope/ to WTP plugins
Goto Forum:
  


Current Time: Fri Aug 01 22:37:06 EDT 2014

Powered by FUDForum. Page generated in 0.02204 seconds