users@glassfish.java.net

Re: Where to put libraries ??

From: Sivakumar Thyagarajan <Sivakumar.Thyagarajan_at_Sun.COM>
Date: Mon, 14 Jan 2008 15:30:59 +0500

Hi

>
> I have a GF2 server with some EJB modules that requires JDBC
> resources that uses postgres drivers. Then I have copied the
> postgres drives into the "domain1/lib" dir.

Placing the libraries in domain-dir/lib makes it available in the common classloader and hence visible to all applications deployed in that server instance.

>
> Now I have JAR library package E which works as my "data layer"
> using JPA to persist and query. This package need another postgres
> driver. Also, this package is used by a web application A.
>
> When I deploy the web application A in the server I was copied the
> postgres driver required by the package E in the
> "domain1/lib/applibs".
> The problem is that I get a "no suitable driver found" message. If
> I remove the driver in "domain1/lib/appplib" the same message is
> recived.
> On the other side, if I remove the above files and copy the drivers
> into de GF server lib directori "gf_dir/lib" all works fine.


domain-dir/applibs is available to enable application specific classloading as explained in https://glassfish.dev.java.net/nonav/javaee5/docs/DG/beade.html#gatej

Merely adding a jar to applibs does not make it available to the application. The application
has to be deployed with the --libraries attribute. I think that was missing in your setup. If
you expect the jars to be used by all applications you could place the E package in domain-dir/lib as well.

Please see
http://blogs.sun.com/sivakumart/entry/classloaders_in_glassfish_an_attempt
for more information.