BuildPath Issue

S

Sahil Dave

Hi All

i am trying to create a simple web application. The project's
build.xml looks like this:

<project name="DemoApp" default="all">
<property environment="env" />
<property name="build.dir" location="build" />
<property name="root.dir" location="." />
<property name="src.dir" value="src" />
<property name="web.dir" value="WebContent/WEB-INF" />

<target name="all" depends="compile"/>
<target name="compile">
<mkdir dir="${web.dir}/classes"/>
<javac fork="yes" executable="${env.JAVA5_HOME}/bin/javac.exe"
destdir="${web.dir}/classes">
<src>
<pathelement path="${src.dir}" />
</src>
</javac>
</target>
</project>

When i try to run the ant build, compilation fails, reporting that
javax.servlet package not found.
I have checked in the project build path, on the 'libraries' tab, the
api.jar for J2EE is present.
I am using the weblogic9.2 app server, and the api.jar is the one that
comes along with it.

Any pointers or suggestions
 
L

Lew

Hi All

i am trying to create a simple web application. The project's
build.xml looks like this:

<project name="DemoApp" default="all">
        <property environment="env" />
        <property name="build.dir" location="build" />
        <property name="root.dir" location="." />
        <property name="src.dir" value="src" />
        <property name="web.dir" value="WebContent/WEB-INF" />

        <target name="all" depends="compile"/>
        <target name="compile">
                <mkdir dir="${web.dir}/classes"/>
                <javac fork="yes" executable="${env.JAVA5_HOME}/bin/javac.exe"
destdir="${web.dir}/classes">
                        <src>
                                <pathelement path="${src.dir}" />
                        </src>
                </javac>
        </target>
</project>

When i try to run the ant build, compilation fails, reporting that
javax.servlet package not found.
I have checked in the project build path, on the 'libraries' tab, the
api.jar for J2EE is present.
I am using the weblogic9.2 app server, and the api.jar is the one that
comes along with it.

Any pointers or suggestions

I spent five minutes googling for "ant build.xml web project" and the
third hit was
<http://tomcat.apache.org/tomcat-4.1-doc/appdev/build.xml.txt>
which is old because Tomcat is up to rev 6.0 so I experimented and
came up with
<http://tomcat.apache.org/tomcat-6.0-doc/appdev/build.xml.txt>

whence comes this gem:

<!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->
<!-- <pathelement location="${foo.jar}"/> -->

<!-- Include all elements that Tomcat exposes to applications -->
<fileset dir="${catalina.home}/bin">
<include name="*.jar"/>
</fileset>
<pathelement location="${catalina.home}/lib"/>
<fileset dir="${catalina.home}/lib">
<include name="*.jar"/>
</fileset>
</path>

That path in turn is referenced by the compile task. In other words,
you have to include the Java EE JARs (in this example, Tomcat's) in
the classpath actually used by the Ant build.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top