The reason for this is that it gives you the flexibility to provide libs at different visibility levels.
The folder glassfish/lib
contains the libs which should be available for the whole server and all domains.
The folder glassfish/domains/domain1/lib
contains only the libs which are available for domain1
.
If you had a domain2
, the folder glassfish/domains/domain2/lib
would contain the libs which are required for domain2
.
Now, as an example, if you have some libs which are required by domain1
and domain2
, you can put them in the folder glassfish/lib
, so they are available for the whole server and therefore for both domains.
Another example, if you have two domains, and both domains require a different version of the same lib, you have to put the specific versions into glassfish/domains/domain1/lib
and glassfish/domains/domain2/lib
accordingly.
As a consequence of this, you can always put your libs into glassfish/lib
if you only have a single domain.
See also: