Can I put my jars in subdirectories of ear/lib?

Solution Unverified - Updated -

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP) 7.x
  • Red Hat JBoss Enterprise Application Platform (EAP) 6.x
  • Red Hat JBoss Enterprise Application Platform (EAP) 5.x

Issue

I know I can put jars in ear/lib and they will be on my application's classpath, but is it possible to organize them into subdirectories of ear/lib and still be picked up?

Resolution

No. The documentation at https://docs.oracle.com/cd/E21764_01/web.1111/e13706/libraries.htm#WLPRG328 says that only jars directly in ear/lib will be made visible:

Library Directories

The Java EE platform provides several mechanisms for applications to use optional packages and shared libraries. Libraries can be bundled with an application or may be installed separately for use by any application. An EAR file may contain a directory that contains libraries packaged in JAR files. The library-directory element of the EAR file's deployment descriptor contains the name of this directory. If a library-directory element isn't specified, or if the EAR file does not contain a deployment descriptor, the directory named lib is used. An empty library-directory element may be used to specify that there is no library directory. All files in this directory (but not in subdirectories) with a .jar extension must be made available to all components packaged in the EAR file, including application clients.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments