Skip to Content

Built-in support for importing jars from WEB-INF/lib?

Posted in

Hi all,

I'm trying to use Ant4Eclipse to build a Dynamic Web Project. Everything works (awesome!) except that ant4eclipse complains about missing jdtClassPathLibary entries. These appear to come from the built-in Eclipse classpath entries for WEB-INF/lib and MANIFEST.MF:

  BUILD FAILED
  org.ant4eclipse.lib.core.exception.Ant4EclipseException: Exception whilst resolving the classpath 
  entry '[EclipseClasspathEntry: path: org.eclipse.jst.j2ee.internal.module.container entryKind: 0 
  outputLocation: null exported: false]' of project 'sample': '

  No 'jdtClassPathLibrary' defined for library entry 'org.eclipse.jst.j2ee.internal.module.container'.
  To resolve this problem, please define a 'jdtClassPathLibrary' element inside your ant build file:

  <ant4eclipse:jdtClassPathLibrary name="org.eclipse.jst.j2ee.internal.module.container">
    <fileset dir="..."/>
  </ant4eclipse:jdtClassPathLibrary >

Here are the relevant entries from my .classpath:

  <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
  <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>

Google turned up an old Ant4Eclipse FAQ, which says the following:

The Web App Libraries container is a dynamic container that is introduced with the Web Tools Platform (WTP). It is used to automatically add all libraries from a project's WEB-INF/lib folder to the classpath (as an application server would do at runtime). Ant4eclipse is able to provide a default value for this kind of classpath container (org.eclipse.jst.j2ee.internal.web.container) if no Path or Property is specified for such a container in your classpath."

Is this behavior no longer supported? Do I need to manually define a jdtClassPathLibrary for the built-in Web App Libraries container? It is straightforward enough to manually import everything under WEB-INF/lib, and we don't use MANIFEST.MF (EAR Libraries) currently, but it seems hacky to have to define these manually via jdtClassPathLibrary.

Any advice would be appreciated!
-G

Hi there, Using the

Hi there,

Using the 'jdtClassPathLibrary' is not hacky and would solve your problem ;-)
Since we currently don't support the WTP we're not accessing the related classpath information. Webprojects are slightly differently organized than usual java projects, so it would require to process the facets, too.
It's basically just a matter of convenience and I already filed an issue to support this:

http://www.javakontor.org:8080/jira/browse/AE-153

Nevertheless it's just a matter of time when I got the chance to work on it (I can't give an estimate when).

Best regards

Daniel Kasmeroglu

Thanks!

Hi Daniel,

Great, thanks for the quick response! I'll go ahead and follow your advice.

For reference, here are the rules I ended up adding:

  <!-- EAR Libraries: resolves any jars in META-INF/MANIFEST.MF/Class-Path: -->
  <ant4eclipse:jdtClassPathLibrary name="org.eclipse.jst.j2ee.internal.module.container">
    <!-- add any JARs from MANIFEST.MF manually here -->
  </ant4eclipse:jdtClassPathLibrary>
 
  <!-- Web App Libraries: resolves any jars in WEB-INF/lib -->
  <ant4eclipse:jdtClassPathLibrary name="org.eclipse.jst.j2ee.internal.web.container">
    <fileset dir="${basedir}/WebContent/WEB-INF/lib" includes="*"/>
  </ant4eclipse:jdtClassPathLibrary>

Thanks!
-Gordon