O'Reilly logo

Harnessing Hibernate by James Elliott, Ryan Fowler, Timothy M. O'Brien

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Add Stripes

To make our project work in a web context, there are a couple things we want to change in our compile task. Up to this point, we’ve been using Ant to start our applications, so Ant has been providing appropriate class paths to our code. So far this has worked great, but Tomcat’s class loader management is complicated enough that it’ll be easiest to just copy our dependencies into the WEB-INF/lib directory of our application. We also want the compile task to place files in WEB-INF so Tomcat can find them. See Example 14-9.

Example 14-9. Compile task updated for web application

...
<property name="source.root" value="src"/>
<property name="class.root" value="webapp/WEB-INF/classes"/> 1
<property name="data.dir" value="webapp/WEB-INF/data"/> 2
...
<target name="compile" depends="prepare"
        description="Compiles all Java classes">
  <javac srcdir="${source.root}"
         destdir="${class.root}"
         debug="on"
         optimize="off"
         deprecation="on">
    <classpath refid="project.class.path"/>
  </javac>
  <filter token="docroot" value="${basedir}/webapp" /> 3
  <copy todir="webapp/WEB-INF" filtering="true" overwrite="true">
    <fileset dir="src" includes="applicationContext.xml" />
  </copy> 
  <copy todir="webapp/WEB-INF/lib" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required