0
votes

I am building the java project using Ant and I am using Ivy for the dependency management. There are two options in ant build for resolving the dependencies during the deployment. One is the lib mode, if this mode is enabled, all the dependent jars will be downloaded into project's WEB-INF/lib folder. Other is manifest mode which does not download any jar. During deployment, MANIFEST.MF (which has the class-paths to all the dependent jars) file will be used for resolving the jars. Project is running properly when it is in lib mode, but when manifest is enabled, the build is successful but the deployment fails.

Please tell me how to fix this or what could be the reasons for this?

Note: Tomcat server is VWL enabled by default.

Thanks in advance.

1
Your jar must be placed somewhere, where the classpath mentioned in MENIFEST.MF, If jars not in your war lib than they must be in your container lib [tomcat or jboss lib]Naveen Ramawat
Thanks for the reply Naveen. I checked class path in manifest and the jar exists in that path only. So there should not be any problem with the path, I guess tomcat is not using this manifest file. Do you mean jars must be either of the lib folders?sairam
what is that path ? is it your war lib or webserver lib location ? if out of that location than they must be set in your system class_path env variableNaveen Ramawat
That may not be a good idea, just for a specific project, we cannot modify system class-path. It is given that if the mode is set to manifest, it takes the path value from manifest file and resolve the problem. Now the problem is, it is not taking that class-path. Those jars are in one shared location that is out of libs.sairam
I doubt that class loader will pick jars from outside the container. But you may try.Naveen Ramawat

1 Answers

0
votes

Without an example one must speculate what your code looks like. The following example demonstrates the use of the ANT manifestclasspath task to construct a classpath suitable for a jar manifest file. The ivy "retrieve" task populates a relative direcotory containing the jars:

  <target name="build" depends="compile">
    <ivy:retrieve pattern="${dist.dir}/lib/[artifact].[ext]"/>

    <manifestclasspath property="jar.classpath" jarfile="${dist.jar}">
      <classpath>
        <fileset dir="${dist.dir}/lib" includes="*.jar"/>
      </classpath>
    </manifestclasspath>

    <jar destfile="${dist.jar}" basedir="${build.dir}/classes">
      <manifest>
        <attribute name="Main-Class" value="${dist.main.class}"/>
        <attribute name="Class-Path" value="${jar.classpath}"/>
      </manifest>
    </jar>
  </target>

The following is a detailed example: