Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Tomcat: Adding elements to generated <Context> when "Run On Server"
Tomcat: Adding elements to generated <Context> when "Run On Server" [message #71060] Wed, 02 February 2005 22:40 Go to next message
Eclipse UserFriend
Originally posted by: ian45.darwinsys.com

I am trying to use Eclipse Web Tools Platform (wtp-1.0M2) to update an
existing web app. I have gotten the app checked out from my local CVS as a
"Dynamic Web Project" (and committed the resulting dot files back into my
local CVS, and reaarranged the directory structure to be the way WTP wants
things, and so on).

The project is almost working, except for one thing.

Tomcat 5 configuration consists of multiple "Context Fragment" files, one
per J2EE "web application". Each <Context> element in Tomcat configuration
corresponds one-to-one with a J2EE web applciation root.

My problem is that, to access the JDBC database using a DataSource, I need
to have Tomcat resources inside the <Context> XML element of the Tomcat
Context Fragment (e.g., the generated file
conf/Catalina/localhost/foo.xml); things like Realms, Resources and
ResourceParams (server.xml stuff, not web.xml stuff). That is to say, the
Context Fragment file needs to look like this (I've left out a LOT of
detail): <Context ...> <Realm .../> <Resource .../> <ResourceParams .../>
</Context>

If I manually insert these elements and reload the web app using the
Tomcat Manager app, then my web app actually works fine (well, not totally
fine or I wouldn't need to maintain it :-), but at least I can access the
database). So I know I'm on the right track :-) and have all my syntax
down pat.

But whenever I restart the server from Eclipse (Using "Run On Server"),
WTP re-creates the Tomcat Context Fragment, with nothing inside it (just
the minimum required attributes so Tomcat can find the web app).

I didn't see any dialogs or menus for creating or specifying Context
nested entries, so I assume either that support is not in place yet, or
that there is a fixed filename you can create that would get inserted into
the middle of the Context fragment. Or, that the WTP maintainers have
somehow found a way to make Tomcat recognize these elements in the main
server.xml file, but my experience has been that Tomcat ignores Realm and
Resources unless they are between the <Context> tag and the corresponding
</Context> tag.

Thanks if anyone can either help, or confirm that I am just a tiny bit too
bleeeding edge for the state of the tools at this time.
Re: Tomcat: Adding elements to generated <Context> when "Run On Server" [message #71139 is a reply to message #71060] Thu, 03 February 2005 01:01 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1354
Registered: July 2009
Senior Member
See: https://bugs.eclipse.org/bugs/show_bug.cgi?id=82812

This support was added after M2. If you downloaded the SDK version WTP M2,
I believe the patch can be applied to the source for the
org.eclipse.jst.server.tomcat.core plug-in that it contains.

Larry


"Ian Darwin" <ian45@darwinsys.com> wrote in message
news:ctrkt0$nnn$1@www.eclipse.org...
> I am trying to use Eclipse Web Tools Platform (wtp-1.0M2) to update an
> existing web app. I have gotten the app checked out from my local CVS as a
> "Dynamic Web Project" (and committed the resulting dot files back into my
> local CVS, and reaarranged the directory structure to be the way WTP wants
> things, and so on).
>
> The project is almost working, except for one thing.
>
> Tomcat 5 configuration consists of multiple "Context Fragment" files, one
> per J2EE "web application". Each <Context> element in Tomcat configuration
> corresponds one-to-one with a J2EE web applciation root.
>
> My problem is that, to access the JDBC database using a DataSource, I need
> to have Tomcat resources inside the <Context> XML element of the Tomcat
> Context Fragment (e.g., the generated file
> conf/Catalina/localhost/foo.xml); things like Realms, Resources and
> ResourceParams (server.xml stuff, not web.xml stuff). That is to say, the
> Context Fragment file needs to look like this (I've left out a LOT of
> detail): <Context ...> <Realm .../> <Resource .../> <ResourceParams .../>
> </Context>
>
> If I manually insert these elements and reload the web app using the
> Tomcat Manager app, then my web app actually works fine (well, not totally
> fine or I wouldn't need to maintain it :-), but at least I can access the
> database). So I know I'm on the right track :-) and have all my syntax
> down pat.
>
> But whenever I restart the server from Eclipse (Using "Run On Server"),
> WTP re-creates the Tomcat Context Fragment, with nothing inside it (just
> the minimum required attributes so Tomcat can find the web app).
>
> I didn't see any dialogs or menus for creating or specifying Context
> nested entries, so I assume either that support is not in place yet, or
> that there is a fixed filename you can create that would get inserted into
> the middle of the Context fragment. Or, that the WTP maintainers have
> somehow found a way to make Tomcat recognize these elements in the main
> server.xml file, but my experience has been that Tomcat ignores Realm and
> Resources unless they are between the <Context> tag and the corresponding
> </Context> tag.
>
> Thanks if anyone can either help, or confirm that I am just a tiny bit too
> bleeeding edge for the state of the tools at this time.
>
Re: Tomcat: Adding elements to generated <Context> when "Run On Server" [message #71159 is a reply to message #71060] Thu, 03 February 2005 01:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: user.host.domain

I see now that there is a New Connection wizard under the Server Explorer,
though it doesn't support PostGresQL or MySQL yet so I can't fully test
it. But I don't see how that is intended to handle all the possible things
you could put into a <Context> entry with all their variations, so I'm not
yet ready to assume that that is how you are supposed to create Realms and
ResourceParam and Resource entries. Is there another way?
Re: Tomcat: Adding elements to generated <Context> when "Run On Server" [message #71178 is a reply to message #71139] Thu, 03 February 2005 01:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: user.host.domain

Larry Isaacs wrote:

> See: https://bugs.eclipse.org/bugs/show_bug.cgi?id=82812

> This support was added after M2. If you downloaded the SDK version WTP M2,
> I believe the patch can be applied to the source for the
> org.eclipse.jst.server.tomcat.core plug-in that it contains.

Wow - that's just what is needed - thanks Larry (and everyone else)!!

Ian D
Re: Tomcat: Adding elements to generated <Context> when "Run On Server" [message #71389 is a reply to message #71159] Thu, 03 February 2005 14:51 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1354
Registered: July 2009
Senior Member
I haven't played much with the Server Explorer, though I wouldn't surprised
if it didn't support configuration to the detail that is implemented within
Tomcat contexts. At the moment, you just edit the META-INF/context.xml as
you would for inclusion of this file in the war you would deploy. The child
elements of the context are included in the server.xml that WTP's Tomcat
will run with. Not yet implemented is resource listening such that
modifying the META-INF/context.xml will cause appropriate servers to be
informed that the associated webapp module needs to be re-published.

Larry


"Ian Darwin" <user@host.domain> wrote in message
news:ctrtlj$l3f$1@www.eclipse.org...
> I see now that there is a New Connection wizard under the Server Explorer,
> though it doesn't support PostGresQL or MySQL yet so I can't fully test
> it. But I don't see how that is intended to handle all the possible things
> you could put into a <Context> entry with all their variations, so I'm not
> yet ready to assume that that is how you are supposed to create Realms and
> ResourceParam and Resource entries. Is there another way?
>
Re: Tomcat: Adding elements to generated <Context> when "Run On Server" [message #71634 is a reply to message #71178] Fri, 04 February 2005 15:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: stevejluke.comcat.net

Ian Darwin wrote:
> Larry Isaacs wrote:
>
>> See: https://bugs.eclipse.org/bugs/show_bug.cgi?id=82812
>
>
>> This support was added after M2. If you downloaded the SDK version
>> WTP M2,
>> I believe the patch can be applied to the source for the
>> org.eclipse.jst.server.tomcat.core plug-in that it contains.
>
>
> Wow - that's just what is needed - thanks Larry (and everyone else)!!
>
> Ian D
>


I am having the same problem, but I am not exactly sure what to do with
the patch. I downloaded the patch from that bug report, and installed
the SDK version of WTP M2, but I do not know how to apply the patch. I
tried to import the org.eclipse.jst.server.tomcat.core plugin as a
Plugin Project and then apply the patch to it, which seemed to work.
But when I restarted eclipse, the new context is still not copied over...

Any help would be appreciated.
Steve Luke
Re: Tomcat: Adding elements to generated <Context> when "Run On Server" [message #71731 is a reply to message #71634] Fri, 04 February 2005 17:31 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1354
Registered: July 2009
Senior Member
You can test the updated plug-in by running the o.e.jst.server.tomcat.core
project as an "Eclipse Application".

To get it into your base installation, execute File-> Export -> Jar file on
the project. Include just the source directory. You don't need
"plugin.xml", etc. in the jar. Go to the installed
o.e.jst.server.tomcat.core plug-in and rename the original tomcatcore.jar.
Then replace it with the exported one and name it tomcatcore.jar. Finally
restart Eclipse.

HTH,
Larry

"stevejluke" <stevejluke@comcat.net> wrote in message
news:cu04g3$8j6$1@www.eclipse.org...
> Ian Darwin wrote:
> > Larry Isaacs wrote:
> >
> >> See: https://bugs.eclipse.org/bugs/show_bug.cgi?id=82812
> >
> >
> >> This support was added after M2. If you downloaded the SDK version
> >> WTP M2,
> >> I believe the patch can be applied to the source for the
> >> org.eclipse.jst.server.tomcat.core plug-in that it contains.
> >
> >
> > Wow - that's just what is needed - thanks Larry (and everyone else)!!
> >
> > Ian D
> >
>
>
> I am having the same problem, but I am not exactly sure what to do with
> the patch. I downloaded the patch from that bug report, and installed
> the SDK version of WTP M2, but I do not know how to apply the patch. I
> tried to import the org.eclipse.jst.server.tomcat.core plugin as a
> Plugin Project and then apply the patch to it, which seemed to work.
> But when I restarted eclipse, the new context is still not copied over...
>
> Any help would be appreciated.
> Steve Luke
Re: Tomcat: Adding elements to generated <Context> when "Run On Server" [message #71750 is a reply to message #71634] Fri, 04 February 2005 17:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: nobody.no.domain

> I am having the same problem, but I am not exactly sure what to do with
> the patch. I downloaded the patch from that bug report, and installed
> the SDK version of WTP M2, but I do not know how to apply the patch. I
> tried to import the org.eclipse.jst.server.tomcat.core plugin as a
> Plugin Project and then apply the patch to it, which seemed to work.
> But when I restarted eclipse, the new context is still not copied over...

Now that I have the patch installed too, it doesn't actually work for me.
A brief reading of the patch seems to imply that the Context entry must be
listed in server.xml as well as in MetaData/context.xml, though I'm not
clear
on all the API used so I can't be sure (it also works differently
depending on
whether you have TC4, 5.0 or 5.5).

Steve, I tried replying to you by email but your domain/isp/whatever is
downright new-mail-contact-hostile. If that isn't a real email please
don't use it (I've set mine to one which is obviously not intended to be
replied to, being only there because "news-portal" requires something in
that field; yours looks real but evidently is not).
Re: Tomcat: Adding elements to generated <Context> when "Run On Server" [message #71787 is a reply to message #71750] Fri, 04 February 2005 17:56 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1354
Registered: July 2009
Senior Member
To get it to work, add a META-INF/context.xml to the webapp project like you
would for creating a war you intend to deploy to some "production" Tomcat.
Then add that project to the desired Tomcat server. The context.xml will be
added to the runtime server.xml the next time the server is "published".
This isn't the server.xml you see under the "Servers" project. For the
default configuration of Tomcat servers, this runtime server.xml will appear
in a subdirectory of
"<workspace>/.metadata/.plugins/org.eclipse.wst.server.core ". You can
manually "publish" the server by right-clicking on the server in the Servers
view, and selecting "Publish".

After modifying a context.xml, you need to have the server re-published to
get the changes to take effect. Due to some bugs in M2, a little extra
effort is required to force this. The most straight forward way I've found
is to right-click on the server and select "Add and remove projects...".
Remove the project and save. Execute "Add and remove projects..." again and
re-add the project, then save. At next startup, the automatic "publish"
should include your context.xml updates. At least this works for me.

Larry


"Ian Darwin" <nobody@no.domain> wrote in message
news:cu0bl0$etf$1@www.eclipse.org...
> > I am having the same problem, but I am not exactly sure what to do with
> > the patch. I downloaded the patch from that bug report, and installed
> > the SDK version of WTP M2, but I do not know how to apply the patch. I
> > tried to import the org.eclipse.jst.server.tomcat.core plugin as a
> > Plugin Project and then apply the patch to it, which seemed to work.
> > But when I restarted eclipse, the new context is still not copied
over...
>
> Now that I have the patch installed too, it doesn't actually work for me.
> A brief reading of the patch seems to imply that the Context entry must be
> listed in server.xml as well as in MetaData/context.xml, though I'm not
> clear
> on all the API used so I can't be sure (it also works differently
> depending on
> whether you have TC4, 5.0 or 5.5).
>
> Steve, I tried replying to you by email but your domain/isp/whatever is
> downright new-mail-contact-hostile. If that isn't a real email please
> don't use it (I've set mine to one which is obviously not intended to be
> replied to, being only there because "news-portal" requires something in
> that field; yours looks real but evidently is not).
>
Re: Tomcat: Adding elements to generated <Context> when "Run On Server" [message #71805 is a reply to message #71787] Fri, 04 February 2005 18:41 Go to previous message
Eclipse UserFriend
Originally posted by: stevejluke.comcast.net

Ian Darwin<nobody@no.domain> said
"Steve, I tried replying to you by email but your domain/isp/whatever
is downright new-mail-contact-hostile."

Woops, yeah, that's my bad. I forgot an 's' in the domain name when
setting up the newsgroup reader. Should be fixed now.


But why I REALLY Posted!

Larry Isaacs<Larry.Isaacs@sas.com> said
"this runtime server.xml will appear
in a subdirectory of
"<workspace>/.metadata/.plugins/org.eclipse.wst.server.core ".
"

Ahh! So it doesn't really work like deploying on a tomcat Server where
the META-INF/context.xml gets copied to
TOMCAT-HOME>/conf/Catalina/localhost/<APP-NAME>.xml. That, and
<WORKSPACE>/Servers/server.xml was where I was looking (and getting the
same minimal <Context .../> tag). I checked the path you showed me and
the changes are taking place.

Thank You.
Steven Luke
Previous Topic:How to setup eclipse with tomcat 5.5
Next Topic:Local DTD for web.xml
Goto Forum:
  


Current Time: Fri Apr 26 08:00:30 GMT 2024

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

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

Back to the top