Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » Context Root ignored?
icon5.gif  Context Root ignored? [message #523874] Mon, 29 March 2010 17:00 Go to next message
John is currently offline JohnFriend
Messages: 3
Registered: March 2010
Junior Member
I'm using Eclipse for Java EE dev's and publishing to my external Tomcat webapps directory (not in the metadata). I set my context root (project properties > web project settings) to something different from the default but my project is still getting published to the default context root, incidentally the project name. I'm publishing to a Tomcat v6.0 Server on my local machine, which is set to "take control of Tomcat installation".

I can reproduce this on a brand new, empty Dynamic Web Project. Is this a bug or am I missing something here? Thanks a ton everyone!

- John


- John
Re: Context Root ignored? [message #523893 is a reply to message #523874] Mon, 29 March 2010 13:26 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1313
Registered: July 2009
Senior Member
John wrote:
> I'm using Eclipse for Java EE dev's and publishing to my external Tomcat
> webapps directory (not in the metadata). I set my context root (project
> properties > web project settings) to something different from the
> default but my project is still getting published to the default context
> root, incidentally the project name. I'm publishing to a Tomcat v6.0
> Server on my local machine, which is set to "take control of Tomcat
> installation".
>
> I can reproduce this on a brand new, empty Dynamic Web Project. Is this
> a bug or am I missing something here? Thanks a ton everyone!
>
> - John

The context root is what you will need to use in the URL. The directory
to which the webapp is copied is taken from the deploy-name found in the
".settings/org.eclipse.wst.common.component" file in your project, which
must remain the same as your project name. There is no problem having
the context root different from the deploy-name, other than if you
publish to "webapps" (instead of "wtpwebapps"), you will get two copies
of the webapp served. One webapp will correctly use the context root
you have specified, and the other will use the deploy-name (assuming
auto-deploy is enabled). Avoiding this is one of the reasons
"wtpwebapps" is the default publish directory.

Cheers,
Larry
Re: Context Root ignored? [message #523902 is a reply to message #523893] Mon, 29 March 2010 19:04 Go to previous messageGo to next message
John is currently offline JohnFriend
Messages: 3
Registered: March 2010
Junior Member
Heh, aaahhh. I just discovered that, too. Sorry, new at this ;P

Thanks a ton!


- John
Re: Context Root ignored? [message #523904 is a reply to message #523893] Mon, 29 March 2010 19:09 Go to previous messageGo to next message
John is currently offline JohnFriend
Messages: 3
Registered: March 2010
Junior Member
Oh wait, one more question then. What exactly is wtpwebapps and how is it different from webapps (default in tomcat)? I changed it to webapps because that's what Tomcat was using, or so I thought.

Thanks again.


- John
Re: Context Root ignored? [message #523946 is a reply to message #523904] Mon, 29 March 2010 23:24 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1313
Registered: July 2009
Senior Member
John wrote:
> Oh wait, one more question then. What exactly is wtpwebapps and how is
> it different from webapps (default in tomcat)? I changed it to webapps
> because that's what Tomcat was using, or so I thought.
>
> Thanks again.

See the Tomcat FAQ [1] for details about the WTP Tomcat support. The
auto-deploy feature typically enabled for "webapps" creates more
problems for published project management than it solves. It is easier
for the WTP Tomcat support to manage the published projects if
auto-deployment isn't in the picture. So "wtpwebapps" is simply a
different folder where auto-deployment doesn't occur.

Cheers,
Larry

[1] http://wiki.eclipse.org/WTP_Tomcat_FAQ
Re: Context Root ignored? [message #540324 is a reply to message #523893] Tue, 15 June 2010 16:02 Go to previous messageGo to next message
Stephan Naecker is currently offline Stephan NaeckerFriend
Messages: 2
Registered: June 2010
Junior Member
Hey there,

I decided to reanimate this post cause I thought it was the easiest way to reference it. I hope somebody still have an eye on it, because I have the some problem, not for the Tomcat but for the JBoss AS.

I think I understood that there is a context root and a deployment folder. The context root is part of the URL to access the web application. The deployment folder is the folder that JBoss uses to serve the requests for that application.

But after changing for example context root of project A to B, I still have to enter http://localhost:8080/A to access it.

So, how can I set a context root different from the Eclipse project name?

Stephan
Re: Context Root ignored? [message #540332 is a reply to message #540324] Tue, 15 June 2010 16:54 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1313
Registered: July 2009
Senior Member
On 6/15/2010 12:02 PM, Stephan Naecker wrote:
> Hey there,
>
> I decided to reanimate this post cause I thought it was the easiest way
> to reference it. I hope somebody still have an eye on it, because I have
> the some problem, not for the Tomcat but for the JBoss AS.
>
> I think I understood that there is a context root and a deployment
> folder. The context root is part of the URL to access the web
> application. The deployment folder is the folder that JBoss uses to
> serve the requests for that application.
>
> But after changing for example context root of project A to B, I still
> have to enter http://localhost:8080/A to access it.
>
> So, how can I set a context root different from the Eclipse project name?
>
> Stephan

The problem is that the JBoss server adapter within WTP relies on
auto-deployment to serve the webapp. This means the context root for
the webapp is determined by the name of the WAR file created, which is
derived from the deploy-name. If you don't want to rename the project,
you can add the Web project to an EAR project. In the application.xml
of the EAR project, an alternate name for the webapp can be specified.
Deploy the EAR project and you can access the webapp with the alternate
context root. You might also try the JBoss AS Tools. The JBoss server
adapter it provides is better integrated and likely doesn't have this
problem.

Cheers,
Larry
Re: Context Root ignored? [message #540802 is a reply to message #540332] Thu, 17 June 2010 12:25 Go to previous messageGo to next message
Stephan Naecker is currently offline Stephan NaeckerFriend
Messages: 2
Registered: June 2010
Junior Member
Thanks Larry!

I tried the JBoss AS Tools, but without success. So I thought about my project structure and naming and now I 'm able to avoid the problem that left me facing the context root problem.
Re: Context Root ignored? [message #557733 is a reply to message #540802] Wed, 08 September 2010 15:51 Go to previous message
Ed Missing name is currently offline Ed Missing nameFriend
Messages: 15
Registered: August 2010
Junior Member
Sorry to necro this thread but it is exactly what i am dealing with.

I need to be able to change the behavior of publish to use the context root as the war file name instead of the project name. I am publishing to Resin using the resin plugin, but the resin plugin is just using the default publish behavior.

I hate to say it, but it wasn't the smartest way to set this up. In a large environment, more often than not, internal project names won't match the web root context. If the default publish behavior can be changed, fine, but it certainly is not obvious where to do that.

This is one of those choices that needs to be part of the project settings. Please advice on how to make that change.
Previous Topic:tomcat and WTP: How to get class files from dependent projectsinto WEB-INF/lib
Next Topic:Trouble getting SSI to work
Goto Forum:
  


Current Time: Sun Dec 21 23:25:43 GMT 2014

Powered by FUDForum. Page generated in 0.08170 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software