问题
We want to integrate latest Jersey Version in Glassfish 4.1.
Glassfish provides Jersey 2.21.0 implementations, so we added Jersey 2.22.2 to WEB-INF/lib. It seams to work with new version.
But is this the correct solution? Will Glassfish always put the libraries in WEB-INF before its own to the classpath?
回答1:
If it is not an option to modify glassfish installation, you still may force glassfish to consider the libs in your web app before the global ones. You just need to provide file glassfish-web.xml in your application along standard web.xml in WEB-INF. Set delegate="false" in the class-loader element of the glassfish-web.xml file. For more documentation, see Glassfish Deployment Guide, section C - Elements of the GlassFish Server Deployment Descriptors.
Thanks to OndrejM!
回答2:
Finally I can say there is no way to replace the Jersey stuff in Glassfish with newer versions. Even if using delegate="false" it will prefer its included version. While reading the deployment manual I recognized a little notice. The notice says that there are some libraries that will be fixed as delegate will not work (For avoiding side effecty I think.
回答3:
GlassFish will prefer its own implementation over ones provided with an application.
Replacing the appropriate GlassFish module is a viable option.
An alternative would be to use Payara Server, which is derived from GlassFish and is released every 3 months, so has more up-to-date modules. The Jersey version currently in Payara Server is 2.22.1, which is only one minor version below your target and may be enough.
来源:https://stackoverflow.com/questions/35769351/glassfish-4-1-latest-jersey-version