Project compiles fine in Eclipse but not with ant file


I am making a simple java-based web application using Eclipse and Tomcat.  The Eclipse project compiles without any problem in Eclipse, using the compilation capability provided within Eclipse.  But, when I try to compile use an Ant build file (build.xml) within the Eclipse project, it tells me that it cannot find the servlet package when Eclipse was able to.  This package is definitely recognised by Eclipse because when I remove the jar file from Eclipse, the Eclipse compiler complains.  I am very stuck on this, help would be much appreciated.  Here is the compile error from the Ant build:


Buildfile: C:\TenantLife\workspace\RABProj\build.xml
init:
compile:
    [javac] Compiling 8 source files to C:\apache-tomcat-5.5.16\webapps\bikestore\war\WEB-INF\classes
    [javac] C:\apache-tomcat-5.5.16\webapps\bikestore\src\com\springbook\BikesController.java:6: package javax.servlet.http does not exist
    [javac] import javax.servlet.http.HttpServletResponse;
    [javac] ^
    [javac] C:\apache-tomcat-5.5.16\webapps\bikestore\src\com\springbook\BikesController.java:7: package javax.servlet.http does not exist
    [javac] import javax.servlet.http.HttpServletRequest;
    [javac] ^
    [javac] C:\apache-tomcat-5.5.16\webapps\bikestore\src\com\springbook\BikesController.java:21: cannot resolve symbol
    [javac] symbol  : class HttpServletRequest
    [javac] location: class com.springbook.BikesController
    [javac] public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
    [javac] ^
    [javac] C:\apache-tomcat-5.5.16\webapps\bikestore\src\com\springbook\BikesController.java:21: cannot resolve symbol
    [javac] symbol  : class HttpServletResponse
    [javac] location: class com.springbook.BikesController
    [javac] public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
    [javac] ^
    [javac] C:\apache-tomcat-5.5.16\webapps\bikestore\src\com\springbook\EditBikeController.java:20: cannot resolve symbol
    [javac] symbol  : class HttpServletRequest
    [javac] location: class com.springbook.EditBikeController
    [javac] public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
    [javac] ^
    [javac] C:\apache-tomcat-5.5.16\webapps\bikestore\src\com\springbook\EditBikeController.java:20: cannot resolve symbol
    [javac] symbol  : class HttpServletResponse
    [javac] location: class com.springbook.EditBikeController
    [javac] public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
    [javac] ^
    [javac] C:\apache-tomcat-5.5.16\webapps\bikestore\src\com\springbook\SubmitBikeController.java:21: cannot resolve symbol
    [javac] symbol  : class HttpServletRequest
    [javac] location: class com.springbook.SubmitBikeController
    [javac] public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
    [javac] ^
    [javac] C:\apache-tomcat-5.5.16\webapps\bikestore\src\com\springbook\SubmitBikeController.java:21: cannot resolve symbol
    [javac] symbol  : class HttpServletResponse
    [javac] location: class com.springbook.SubmitBikeController
    [javac] public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
    [javac] ^
    [javac] 8 errors

BUILD FAILED
C:\TenantLife\workspace\RABProj\build.xml:41: Compile failed; see the compiler error output for details.

Total time: 2 seconds


tlDeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
Make sure servlet.jar is in the *Ant* build path (classpath)
Mick BarryJava DeveloperCommented:
add servlet.jar to <ant>/lib

where <ant> is where you have ant installed

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tlDeveloperAuthor Commented:

It turned out there was typo in the build.xml file where someone wrote servlet.jar instead of servlet-api.jar (which was the correct file name).  The eclipse project was using a different jar file altogether and compiled for that reason.  I appreciate all the advice, it really helped me get unstuck (I was looking in all the wrong places for something to be wrong).

CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

CEHJCommented:
tlDeveloper, why in that case did you accept that answer, which in any case wasn't right?
tlDeveloperAuthor Commented:

Both sets of comments were helpful in pointing me in the right direction of finding the problem.  I would have liked to accept answers for both people to give both credit but the site does not allow it, sorry.  Thank you for the help though.

CEHJCommented:
>>but the site does not allow it, sorry.

It does in fact, and can be corrected now as well.
tlDeveloperAuthor Commented:

I'd be happy to accept your answer as well, how do I do that?  Thanks again for the help.

CEHJCommented:
You don't need to do anything yet. A page editor will post in this Q. soon
Mayank SAssociate Director - Product EngineeringCommented:
objects, CEHJ - are you subscribed to Venabili's PE notifier 6 or not?

http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21765176.html
CEHJCommented:
I am
CEHJCommented:
:-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.