Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » How to make Eclipse put jars into WEB-INF/lib?
How to make Eclipse put jars into WEB-INF/lib? [message #214251] Sat, 24 May 2008 18:45 Go to next message
David M. Karr is currently offline David M. KarrFriend
Messages: 143
Registered: July 2009
Senior Member
Eclipse 3.3.2.

It seems like I've battled with this before, but it escapes me now.

I have a dynamic web project that I've assembled from an existing WAR.
I'm trying to figure out how to get the required jars for the project to
actually deploy into WEB-INF/lib when the WAR is constructed. The project
has no errors in Eclipse, but when I export the WAR, the WEB-INF/lib
directory is empty.

In the Eclipse project, I have a "lib" subdirectory that contains all the
jars, and I've put all of those jars into the build path.

I've tried to use the "J2EE Module Dependencies" page, because I thought
this controlled what goes into WEB-INF/lib. In that dialog, I selected
all the jars for this project and clicked OK. When I then go back into
this dialog, all of those jars are unselected again.

When I export the project to a WAR file, it leaves the WEB-INF/lib
directory empty.

I tried to deploy the project to Tomcat 6.0.14, but the context root is
never available (gets 404). I see no deployment errors in the Tomcat
console.
Re: How to make Eclipse put jars into WEB-INF/lib? [message #214274 is a reply to message #214251] Tue, 27 May 2008 01:50 Go to previous messageGo to next message
Ken is currently offline KenFriend
Messages: 10
Registered: July 2009
Junior Member
David Karr wrote:
> Eclipse 3.3.2.
>
> It seems like I've battled with this before, but it escapes me now.
>
> I have a dynamic web project that I've assembled from an existing WAR.
> I'm trying to figure out how to get the required jars for the project to
> actually deploy into WEB-INF/lib when the WAR is constructed. The
> project has no errors in Eclipse, but when I export the WAR, the
> WEB-INF/lib directory is empty.
>
> In the Eclipse project, I have a "lib" subdirectory that contains all
> the jars, and I've put all of those jars into the build path.
>
> I've tried to use the "J2EE Module Dependencies" page, because I thought
> this controlled what goes into WEB-INF/lib. In that dialog, I selected
> all the jars for this project and clicked OK. When I then go back into
> this dialog, all of those jars are unselected again.
>
> When I export the project to a WAR file, it leaves the WEB-INF/lib
> directory empty.
>
> I tried to deploy the project to Tomcat 6.0.14, but the context root is
> never available (gets 404). I see no deployment errors in the Tomcat
> console.
>
hi,David

when you import a project in J2EE Module Dependencies, it will only
import compiled source in Dependencies project and without the jars in
that project, in common, it's not need a folder to add the jars, you can
copy the jars to WEB-INF/lib, eclipse will add them to classpath
automatically when you export it to war package.
Re: How to make Eclipse put jars into WEB-INF/lib? [message #214298 is a reply to message #214251] Tue, 27 May 2008 08:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mauro.molinari.cardinis.com

David Karr ha scritto:
> When I export the project to a WAR file, it leaves the WEB-INF/lib
> directory empty.

Try to have a look at the Order and Export tab of the Jaba Build Path
property page for your project: you may need to check the JARs you want
to export.

Mauro.
Re: How to make Eclipse put jars into WEB-INF/lib? [message #214337 is a reply to message #214251] Tue, 27 May 2008 13:36 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1310
Registered: July 2009
Senior Member
David Karr wrote:
> Eclipse 3.3.2.
>
> It seems like I've battled with this before, but it escapes me now.
>
> I have a dynamic web project that I've assembled from an existing WAR.
> I'm trying to figure out how to get the required jars for the project to
> actually deploy into WEB-INF/lib when the WAR is constructed. The
> project has no errors in Eclipse, but when I export the WAR, the
> WEB-INF/lib directory is empty.
>
> In the Eclipse project, I have a "lib" subdirectory that contains all
> the jars, and I've put all of those jars into the build path.
>
> I've tried to use the "J2EE Module Dependencies" page, because I thought
> this controlled what goes into WEB-INF/lib. In that dialog, I selected
> all the jars for this project and clicked OK. When I then go back into
> this dialog, all of those jars are unselected again.

For me, the selected jars stayed checked. As you have surmised, just
including the jars in the build path doesn't by itself mark them for
inclusion in WEB-INF/lib. Using the "J2EE Module Dependencies" page is
the correct approach. However, it's not clear why they won't stay
checked. You might check the Error Log view to see if something related
is present. You could also try creating a new project, copy the lib
directory, and see if you can duplicate this issue in the new project.
If not, you can compare the ".classpath" and
".settings/org.eclipse.wst.common.component" files to see what the
differences are. You could also try removing the jars from build path
and adding them on the J2EE Module Dependencies page, which will
automatically include them on the build path as well as include them in
WEB-INF/lib.

Cheers,
Larry

>
> When I export the project to a WAR file, it leaves the WEB-INF/lib
> directory empty.
>
> I tried to deploy the project to Tomcat 6.0.14, but the context root is
> never available (gets 404). I see no deployment errors in the Tomcat
> console.
>
Re: How to make Eclipse put jars into WEB-INF/lib? [message #214419 is a reply to message #214337] Wed, 28 May 2008 07:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mauro.molinari.cardinis.com

Larry Isaacs ha scritto:
> For me, the selected jars stayed checked. As you have surmised, just
> including the jars in the build path doesn't by itself mark them for
> inclusion in WEB-INF/lib. Using the "J2EE Module Dependencies" page is
> the correct approach. However, it's not clear why they won't stay
> checked. You might check the Error Log view to see if something related
> is present. You could also try creating a new project, copy the lib
> directory, and see if you can duplicate this issue in the new project.
> If not, you can compare the ".classpath" and
> ".settings/org.eclipse.wst.common.component" files to see what the
> differences are. You could also try removing the jars from build path
> and adding them on the J2EE Module Dependencies page, which will
> automatically include them on the build path as well as include them in
> WEB-INF/lib.

Hi Larry,
just for my curiosity. In this post you're suggesting to add JARs to
classpath and then to check them in J2EE Module Dependencies to have
them deployed to WEB-INF/lib.
In my own experience, however, I learnt to follow a different approach.
I simply put my JARs in WEB-INF/lib of WebContent: those JARs are
automatically added to classpath (through Web App Libraries) AND
deployed to WEB-INF/lib (I don't know if they are also exported to the
WAR, as David asked). I prefer this approach for two main reasons:
1) it sounds more clean to me: I think the "Web App Libraries" Library
in build path was actually designed for this purpose
2) the J2EE Module Dependencies property page is almost unusable: it's
full of bugs, because sometimes things don't get checked, sometimes they
don't get unchecked and sometimes there seem to be synchronization
problems between that view and the Java Build Path property page.

Because of 1), in the past I wondered what J2EE Module Dependencies was
made for... then I understood that it's useful when you have
inter-project dependencies: when you define a Dynamic Web Project to
depend on another project, that project is used to build the Dynamic Web
Project, but its classes are not deployed to WEB-INF/lib of the Dynamic
Web Project. Adding the required project to J2EE Module Dependencies
causes WTP to make a JAR of it to deploy in WEB-INF/lib.

Correct me if I'm wrong in my approach: I would appreciate your opinion
on this very much.

Mauro.
Re: How to make Eclipse put jars into WEB-INF/lib? [message #214427 is a reply to message #214419] Wed, 28 May 2008 13:51 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1310
Registered: July 2009
Senior Member
Mauro Molinari wrote:
> Larry Isaacs ha scritto:
>> For me, the selected jars stayed checked. As you have surmised, just
>> including the jars in the build path doesn't by itself mark them for
>> inclusion in WEB-INF/lib. Using the "J2EE Module Dependencies" page
>> is the correct approach. However, it's not clear why they won't stay
>> checked. You might check the Error Log view to see if something
>> related is present. You could also try creating a new project, copy
>> the lib directory, and see if you can duplicate this issue in the new
>> project. If not, you can compare the ".classpath" and
>> ".settings/org.eclipse.wst.common.component" files to see what the
>> differences are. You could also try removing the jars from build path
>> and adding them on the J2EE Module Dependencies page, which will
>> automatically include them on the build path as well as include them
>> in WEB-INF/lib.
>
> Hi Larry,
> just for my curiosity. In this post you're suggesting to add JARs to
> classpath and then to check them in J2EE Module Dependencies to have
> them deployed to WEB-INF/lib.

Actually, don't add them to the build path. Just add them on the J2EE
Module Dependencies page and they will be included in the build path in
addition to WEB-INF/lib. These jars will also appear in the "Web App
Libaries" library.

> In my own experience, however, I learnt to follow a different approach.
> I simply put my JARs in WEB-INF/lib of WebContent: those JARs are
> automatically added to classpath (through Web App Libraries) AND
> deployed to WEB-INF/lib (I don't know if they are also exported to the
> WAR, as David asked). I prefer this approach for two main reasons:
> 1) it sounds more clean to me: I think the "Web App Libraries" Library
> in build path was actually designed for this purpose

This approach is perfectly fine. The main disadvantage is that if you
have a set of webapps, you duplicate the jars in each project. Having
the projects use the same jars can be a plus in certain situations,
though it means the projects are no longer completely self contained.

> 2) the J2EE Module Dependencies property page is almost unusable: it's
> full of bugs, because sometimes things don't get checked, sometimes they
> don't get unchecked and sometimes there seem to be synchronization
> problems between that view and the Java Build Path property page.

I've never had a problem with this feature and would be interested in
trying to figure out what brings your issues about. I may not encounter
problems because I work on "development tooling", which means I work on
improvements to Eclipse that will help with with Web application
development. I don't work on webapps long term. Thus, I'm typically
creating new projects rather than migrating a project through various
versions of Eclipse and WTP, where maybe something a little "odd" about
the project may cause an issue like you have experienced. It also means
I don't work on web projects with a team, where one team member changes
a project in source control in a way that is only valid on that
developer's system and causes subtle problems for others in the team.

>
> Because of 1), in the past I wondered what J2EE Module Dependencies was
> made for... then I understood that it's useful when you have
> inter-project dependencies: when you define a Dynamic Web Project to
> depend on another project, that project is used to build the Dynamic Web
> Project, but its classes are not deployed to WEB-INF/lib of the Dynamic
> Web Project. Adding the required project to J2EE Module Dependencies
> causes WTP to make a JAR of it to deploy in WEB-INF/lib.
>
> Correct me if I'm wrong in my approach: I would appreciate your opinion
> on this very much.

This is a feature that needs to work. If you know of use cases where it
doesn't, please open a bug report in Bugzilla so it can be tracked. If
you are happy doing things the current way, then I wouldn't bother
changing. However, if you would benefit by this feature not having
problems in your use case, then it might be worth investigating.

Cheers,
Larry

>
> Mauro.
Re: How to make Eclipse put jars into WEB-INF/lib? [message #214474 is a reply to message #214427] Thu, 29 May 2008 07:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mauro.molinari.cardinis.com

Thank you very much Larry for your reply!

I will try to track down problems I encounter with the JEE Module
Dependencies property page, although it's not that easy because they
usually are difficult to reproduce in an unconditional way.
However, I can state for sure that:
1) we're not sharing entire projects within our team: we just share code
and then assembly it in our own workspace by ourselves. This would open
a huge discussion, however the two main reasons are that not all the
team members use Eclipse and that our webapp is made of many different
modules inter-dependent from each other, so sharing an entire project is
not enough flexible
2) I saw problems even when the workspace started as a new one (not
migrated from a previous version of Eclipse)

Mauro.
Re: How to make Eclipse put jars into WEB-INF/lib? [message #214499 is a reply to message #214474] Thu, 29 May 2008 12:57 Go to previous message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1310
Registered: July 2009
Senior Member
Mauro Molinari wrote:
> Thank you very much Larry for your reply!
>
> I will try to track down problems I encounter with the JEE Module
> Dependencies property page, although it's not that easy because they
> usually are difficult to reproduce in an unconditional way.
> However, I can state for sure that:
> 1) we're not sharing entire projects within our team: we just share code
> and then assembly it in our own workspace by ourselves. This would open
> a huge discussion, however the two main reasons are that not all the
> team members use Eclipse and that our webapp is made of many different
> modules inter-dependent from each other, so sharing an entire project is
> not enough flexible
> 2) I saw problems even when the workspace started as a new one (not
> migrated from a previous version of Eclipse)
>
> Mauro.

If you experience the problem again, feel free to ask for help at that
point. The first step would be to examine the contents of the
..classpath and .settings/org.eclipse.wst.common.component files to see
if something is amiss.

Cheers,
Larry
Previous Topic:Change deploy path from "projectName" to something else
Next Topic:localhost:8080 absent if server is in eclipse
Goto Forum:
  


Current Time: Mon Nov 24 08:26:35 GMT 2014

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

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