• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Compiling a dynamic web app from command line

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When using eclipse, compiling the web app and running it on a server is relatively straight-forward. Eclipse knows where the apache tomcat libraries are ( such as servlet-api.jar etc)

If you're writing an ant script to compile the classes from the command line... I get an error which I understand where it comes from...basically...javac complains because it cannot find the javax.* libraries.

adding the servlet-api.jar under WEB-INF/lib resolved the problem but now Tomcat complains with the following:

INFO: validateJarFile(/Library/Tomcat/apache-tomcat-6.0.20/wtpwebapps/iSquirrel/WEB-INF/lib/servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class

anyone knows how to fix this?
Generally, what needs to be included in WEB-INF/lib so that the web app compiles correctly using command-line? I would suspect that the tomcat jar files are not needed as long as you include them in the classpath when compiling?

Thanks a lot
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Correct, and in fact including them in WEB-INF/lib creates an error. As you saw.
 
Andreas Markitanis
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So to fix the error...do I simply add the tomcat lib classpath when compiling via the ant script?

thanks
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Martijn Verburg wrote:Yes



No.

You can't add a library directory to a classpath in Java and use what's in the jars in that directory. That's not how the JVM works. It won't automatically search the jars.

However, in most cases, for a J2EE build, if you include $TOMCAT_HOME/lib/jsp-api.jar and $TOMCAT_HOME/lib/servlet-api.jar to your compile classpath that's all you need. You don't need every jar in $TOMCAT_HOME/lib.
 
Andreas Markitanis
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with Martin as my problem was fixed.
 
Martijn Verburg
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To be clear here I agree with Tim, my flippant yes response was simply because I mis-interpreted by what you meant as TOMCAT CLASSPATH. Tim is in fact correct in that you should have specific JARs in your CLASSPATH as opposed to an entire folder.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic