Deploying an application with existing library as jar file created with ANT


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Deploying an application with existing library as jar file created with ANT

  1. #1
    Join Date
    Jul 2005
    Posts
    3

    Deploying an application with existing library as jar file created with ANT

    Hello All,

    I am having some trouble with a web application I am deploying to Tomcat. I have an custom library that works perfectly as a jar file included in the lib directory if I include all the jars that that library depends on into the lib directory also. What I would like to do is bundle the required jar files into my libraries jar file, but it failes to work when I do that.

    Any thoughts? Does Tomcat prevent this?

    I am using ANT to create my jar file, but when I look at the contents of my jar file it includes all the requested directories.

    My build.xml looks like this:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <project name="myapp" basedir="." default="jar">
    <property name="classes.dir" value="./classes"/>
    <property name="jar.dir" value="."/>
    <property name="java_lib.dir" value="../../../../../Program Files/Java/lib"/>

    <target name="jar">
    <jar destfile="${jar.dir}/${ant.project.name}.jar">
    <fileset dir="classes"/>
    <fileset dir="${java_lib.dir}" includes="jai_codec.jar.jar"/>
    <fileset dir="${java_lib.dir}" includes="xercesImpl.jar"/>
    <fileset dir="${java_lib.dir}" includes="mysql-connector-java-3.1.8-bin.jar"/>
    <fileset dir="${java_lib.dir}" includes="xmlParserAPIs.jar"/>
    <fileset dir="${java_lib.dir}" includes="mlibwrapper_jai.jar"/>
    <fileset dir="${java_lib.dir}" includes="xml-apis.jar"/>
    <fileset dir="${java_lib.dir}" includes="jai_core.jar"/>
    </jar>
    </target>
    <target name="run" depends="jar">
    <java jar="${jar.dir}/${ant.project.name}.jar" fork="true"/>
    </target>
    <target name="clean-build" depends="jar"/>
    <target name="main" depends="run"/>
    </project>

    Like I said...it includes these jar files in my jar file, but will not function properly with my tomcat app. If I exclude these jar files and include them seperately then everything works.

    NOTE: I do not access any of these libraries directly from any servlets, only from my classes.

    Thanks,
    J-Rod


  2. #2
    Join Date
    Aug 2003
    Posts
    313
    Though it has been a while since I worked with jar files and especially building custom ANT files, you might take a look at the classpath attribute in manifest files. If I remember, it goes something like:
    Code:
    Class-Path: /lib/xercesImpl.jar
    Or something like that. Take a look at: http://java.sun.com/j2se/1.3/docs/gu...n%20Attributes

    Hope this helps.
    ~evlich

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center