Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » tomcat and WTP: How to get dependent libraries into WEB-INF/lib
tomcat and WTP: How to get dependent libraries into WEB-INF/lib [message #552136] Wed, 11 August 2010 04:11 Go to next message
fatelephant is currently offline fatelephantFriend
Messages: 7
Registered: August 2010
Junior Member
Hi I am trying to use eclipse (Helios) WTP to develop/deploy my webapp on tomcat.
I created a Dynamic Web Project (projectA) and Created a new Tomcat Server and deployed the Dynamic Web Project on this server. Works great. However if I add any dependent libraries to projectA (e.g. Hibernate/Spring etc) these libraries are not getting automatically copied to the WEB-INF/lib directory. I am having to go to the file system and having to manually copy these to WEB-INF/lib for the tomcatServer (that I start from within eclipse) to find these. Any way of getting all my dependent external jars automatically deployed?

Thanks,
Re: tomcat and WTP: How to get dependent libraries into WEB-INF/lib [message #552266 is a reply to message #552136] Wed, 11 August 2010 13:45 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1310
Registered: July 2009
Senior Member
On 8/11/2010 12:11 AM, shyam.maniyedath@gmail.com wrote:
> Hi I am trying to use eclipse (Helios) WTP to develop/deploy my webapp
> on tomcat.
> I created a Dynamic Web Project (projectA) and Created a new Tomcat
> Server and deployed the Dynamic Web Project on this server. Works great.
> However if I add any dependent libraries to projectA (e.g.
> Hibernate/Spring etc) these libraries are not getting automatically
> copied to the WEB-INF/lib directory. I am having to go to the file
> system and having to manually copy these to WEB-INF/lib for the
> tomcatServer (that I start from within eclipse) to find these. Any way
> of getting all my dependent external jars automatically deployed?
> Thanks,
>

How you added the dependent libraries would matter. You likely have
some warnings in the Problems view related to these libraries. If so,
the Quick Fix for these warnings should fix this issue.

Cheers,
Larry
Re: tomcat and WTP: How to get dependent libraries into WEB-INF/lib [message #552275 is a reply to message #552266] Wed, 11 August 2010 14:45 Go to previous messageGo to next message
fatelephant is currently offline fatelephantFriend
Messages: 7
Registered: August 2010
Junior Member
Larry,

Thanks this works great!! Really appreciate it.
The problems view is not shown by default and I had to go to Windows->Show View and add that.
I was adding the library by going Project->Properties->Libraries Tab->Add External Jar. I also tried exporting it in the Order and Export tab and that did not help.
What is the right way to add these libraries so that the warning is automatically resolved?

Anyways, once again, thanks for your help Most useful.

-
Re: tomcat and WTP: How to get dependent libraries into WEB-INF/lib [message #552288 is a reply to message #552275] Wed, 11 August 2010 15:17 Go to previous messageGo to next message
fatelephant is currently offline fatelephantFriend
Messages: 7
Registered: August 2010
Junior Member
I did some googling and it seems the right way to add these libraries is via "J2EE Module dependencies". I am not able to see this menu item/context-menu-item at all. Is there a way to enable that for Tomcat? Or does that only work for Websphere?

Thank you.
Re: tomcat and WTP: How to get dependent libraries into WEB-INF/lib [message #552303 is a reply to message #552288] Wed, 11 August 2010 15:38 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1310
Registered: July 2009
Senior Member
On 8/11/2010 11:17 AM, fatelephant wrote:
> I did some googling and it seems the right way to add these libraries is
> via "J2EE Module dependencies". I am not able to see this menu
> item/context-menu-item at all. Is there a way to enable that for Tomcat?
> Or does that only work for Websphere?
>
> Thank you.

The "J2EE Module Dependencies" is no longer present in WTP 3.2. It has
replacement is the "Deployment Assembly" page. However, the exact
mission of that page with respect to runtime dependency management is
still under discussion. For now, I think it's best to use the Problems
view approach, which means it isn't automatic.

Cheers,
Larry
Re: tomcat and WTP: How to get dependent libraries into WEB-INF/lib [message #552317 is a reply to message #552303] Wed, 11 August 2010 17:22 Go to previous messageGo to next message
fatelephant is currently offline fatelephantFriend
Messages: 7
Registered: August 2010
Junior Member
Thank you for your response!!
Re: tomcat and WTP: How to get dependent libraries into WEB-INF/lib [message #554964 is a reply to message #552317] Tue, 24 August 2010 23:20 Go to previous messageGo to next message
Dean Hiller is currently offline Dean HillerFriend
Messages: 46
Registered: July 2009
Member
I am upgrading from galileo and this seems to have broke everything Sad Sad. I have a project with no errors/problems in the problems tab right now(ie. added jars to build path). I then tried to add some of those same jars to Module Assembly...they don't show up in that Web Apps folder in the build path though. Lastly, they are not deployed to WEB-INF/lib so Module Assembly doesn't seem to do anything.

Also, it would be fantastic in eclipse(not just WTP) if we could just specify something like all my jars are in this one folder so if I add remove jars, Ant AND Eclipse both pick it up rather than I have to go into eclipse and add another jar(same with WTP)...for some reason, they like to make us work in this area while ant made that nice and clean with a simple pattern. (note: I don't mind having to just refresh the project after adding 10 jars...I do mind having to go in and add the 10 jars).

My current .settings/*.component file is like so...

<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="portal">
<wb-resource deploy-path="/" source-path="/src/main/webapp"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<dependent-module archiveName="activation-1.1.jar" deploy-path="/" handle=" module:/classpath/lib/portal/src/libinclude/activation-1.1.j ar ">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="context-root" value="portal"/>
<property name="java-output-path"/>
</wb-module>
</project-modules>

it does not deploy activation-1.1.jar Sad Sad
Re: tomcat and WTP: How to get dependent libraries into WEB-INF/lib [message #555010 is a reply to message #554964] Wed, 25 August 2010 07:36 Go to previous messageGo to next message
Mauro Molinari is currently offline Mauro MolinariFriend
Messages: 280
Registered: July 2009
Senior Member
Il 25/08/2010 1.20, Dean Hiller ha scritto:
> Also, it would be fantastic in eclipse(not just WTP) if we could just
> specify something like all my jars are in this one folder so if I add
> remove jars, Ant AND Eclipse both pick it up rather than I have to go

You simply need to put your JARs in WebContent/WEB-INF/lib to achieve
this. The Module Assembly Page is really useful for other things, IMHO.

Mauro.
Re: tomcat and WTP: How to get dependent libraries into WEB-INF/lib [message #555103 is a reply to message #554964] Wed, 25 August 2010 13:09 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1310
Registered: July 2009
Senior Member
On 8/24/2010 7:20 PM, Dean Hiller wrote:
> I am upgrading from galileo and this seems to have broke everything :(
> :(. I have a project with no errors/problems in the problems tab right
> now(ie. added jars to build path). I then tried to add some of those
> same jars to Module Assembly...they don't show up in that Web Apps
> folder in the build path though. Lastly, they are not deployed to
> WEB-INF/lib so Module Assembly doesn't seem to do anything.
>
> Also, it would be fantastic in eclipse(not just WTP) if we could just
> specify something like all my jars are in this one folder so if I add
> remove jars, Ant AND Eclipse both pick it up rather than I have to go
> into eclipse and add another jar(same with WTP)...for some reason, they
> like to make us work in this area while ant made that nice and clean
> with a simple pattern. (note: I don't mind having to just refresh the
> project after adding 10 jars...I do mind having to go in and add the 10
> jars).
>
> My current .settings/*.component file is like so...
>
> <?xml version="1.0" encoding="UTF-8"?>
> <project-modules id="moduleCoreId" project-version="1.5.0">
> <wb-module deploy-name="portal">
> <wb-resource deploy-path="/" source-path="/src/main/webapp"/>
> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
> <dependent-module archiveName="activation-1.1.jar" deploy-path="/"
> handle=" module:/classpath/lib/portal/src/libinclude/activation-1.1.j ar ">
> <dependency-type>uses</dependency-type>
> </dependent-module>
> <property name="context-root" value="portal"/>
> <property name="java-output-path"/>
> </wb-module>
> </project-modules>
>
> it does not deploy activation-1.1.jar :( :(

Right now, your *.component file is set to put the activation-1.1.jar in
the root of your web application (i.e. deploy-path="/") instead of
WEB-INF/lib. At the moment, the WTP code handling this isn't smart
enough to know that activation-1.1.jar should *not* be automatically
included in your project's build classpath if not mapped to WEB-INF/lib.
If it was smart enough, you probably would have already realized
something wasn't right with this jar. If you use the Deployment
Assembly page to change the deploy-path to "/WEB-INF/lib", I believe it
will behave as you expect.

Perhaps a better way to add such jar(s) (better as in better supported
in the future) is to add them using the Java Build Path Libraries tab
and export the jar(s) in the Order and Export tab. Then switch to the
Problems view. A warning will appear related to the jar(s). Use the
Quick Fix to mark the jar(s) for inclusion in WEB-INF/lib. This
approach puts the jar in the .classpath file and adds an attribute to
that entry to mark it for inclusion in the web application when
published or exported.

Cheers,
Larry
Re: tomcat and WTP: How to get dependent libraries into WEB-INF/lib [message #555663 is a reply to message #555103] Fri, 27 August 2010 14:03 Go to previous messageGo to next message
Mauro Molinari is currently offline Mauro MolinariFriend
Messages: 280
Registered: July 2009
Senior Member
Il 25/08/2010 15.09, Larry Isaacs ha scritto:
> Perhaps a better way to add such jar(s) (better as in better supported
> in the future) is to add them using the Java Build Path Libraries tab
> and export the jar(s) in the Order and Export tab. Then switch to the
> Problems view. A warning will appear related to the jar(s). Use the
> Quick Fix to mark the jar(s) for inclusion in WEB-INF/lib. This approach
> puts the jar in the .classpath file and adds an attribute to that entry
> to mark it for inclusion in the web application when published or exported.

Larry,
isnt' there another "official" way to do this, except for the quick fix?
I usually put my JARs in WEB-INF/lib directly to have WTP automatically
add them to the build path and publish.

Mauro.
Re: tomcat and WTP: How to get dependent libraries into WEB-INF/lib [message #555695 is a reply to message #555663] Fri, 27 August 2010 16:55 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1310
Registered: July 2009
Senior Member
On 8/27/2010 10:03 AM, Mauro Molinari wrote:
> Il 25/08/2010 15.09, Larry Isaacs ha scritto:
>> Perhaps a better way to add such jar(s) (better as in better supported
>> in the future) is to add them using the Java Build Path Libraries tab
>> and export the jar(s) in the Order and Export tab. Then switch to the
>> Problems view. A warning will appear related to the jar(s). Use the
>> Quick Fix to mark the jar(s) for inclusion in WEB-INF/lib. This approach
>> puts the jar in the .classpath file and adds an attribute to that entry
>> to mark it for inclusion in the web application when published or
>> exported.
>
> Larry,
> isnt' there another "official" way to do this, except for the quick fix?
> I usually put my JARs in WEB-INF/lib directly to have WTP automatically
> add them to the build path and publish.
>
> Mauro.

That's the simplest way, but results in jar duplication, which is why I
think many want to reference the jar where it already exists. For those
with multiple projects that they want to ensure are all using the same
version of a particular jar, having only one copy of the jar on the
system helps ensure that.

Cheers,
Larry
Re: tomcat and WTP: How to get dependent libraries into WEB-INF/lib [message #555917 is a reply to message #555695] Mon, 30 August 2010 08:10 Go to previous message
Mauro Molinari is currently offline Mauro MolinariFriend
Messages: 280
Registered: July 2009
Senior Member
Il 27/08/2010 18.55, Larry Isaacs ha scritto:
> That's the simplest way, but results in jar duplication, which is why I
> think many want to reference the jar where it already exists. For those
> with multiple projects that they want to ensure are all using the same
> version of a particular jar, having only one copy of the jar on the
> system helps ensure that.

To solve this problem I do the following. It's not very elegant but it
works.

I create a Java project containing all the JARs I want to share.
Then, in all my dynamic web projects that need to use those JARs, I
create a linked "lib" folder in WEB-INF that points to the shared
project folder.

In this way, if I want to update JARs from the CVS I simply need to
operate on the shared JARs project. Whenever I update files in it
(including adding new ones), the linked "lib" folders in the DWPs gets
updated automatically and so does the buildpath of each DWP.

I find this more confortable than the old buggy JEE Module Dependencies
project of the new Module Assembly Page (which is great for mapping more
"WebContent" folders, though).

Mauro.
Previous Topic:WTP Axis - Client code generation
Next Topic:Source bundles for WTP Webpage editor
Goto Forum:
  


Current Time: Mon Nov 24 04:13:05 GMT 2014

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

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