Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Compiling a dynamic web app from command line

 
Andreas Markitanis
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • 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
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18169
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
I agree with Martin as my problem was fixed.
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic