How to use 3rd party libraries in glassfish?

后端 未结 6 777
余生分开走
余生分开走 2020-12-03 04:00

I need to connect to a MongoDB instance from my EJB3 application, running on glassfish 3.0.1. The Mongo project provides a set of drivers, and I\'m able to use them in a sta

6条回答
  •  萌比男神i
    2020-12-03 04:24

    You could put shared libs to lib/ext of your domain. commons-logging and jdbc drivers are often added in this domain path.

    Common Class Loader

    GlassFish v2 has a well defined Class Loader hierarchy which identifies the common class loader as the proper way to deal with shared libraries. So to make a long story short, putting you libraries and other framework JARs in domains/domain1/lib is all you need to do.

    lib/, not lib/ext

    The person asking me the question had tried putting the libraries in domains/domain1/lib/ext which triggered an interesting ClassNotFoundError for core Java EE classes such as javax.servlet.http.HttpServlet. Shing Wai Chan was quick to explain that domains/domain1/lib/ext is part of -Djava.ext.dirs which makes any of its JARs be considered as a JDK extension which means web app frameworks placed there will be loaded before webcontainer implementation classes as they are higher up in the classloader delegation chain.

提交回复
热议问题