3

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?

Jens Peters
  • 2,075
  • 1
  • 22
  • 30
  • It may not be the case. Check out [Updating Jersey 2 in GlassFish 4](http://blog.dejavu.sk/2014/01/21/updating-jersey-2-in-glassfish-4/) – Paul Samsotha Mar 03 '16 at 10:25
  • I do not want to update the Glassfish modules. But how is Glassfish handling libraries that come with an WAR / included in webapp? Is there a way to show Glassfish classpath für an application? – Jens Peters Mar 03 '16 at 10:34

3 Answers3

3

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!

Jens Peters
  • 2,075
  • 1
  • 22
  • 30
0

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.

Jens Peters
  • 2,075
  • 1
  • 22
  • 30
-1

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.

Mike
  • 4,852
  • 1
  • 29
  • 48
  • That is no viable option, because of customers running their own glassfish and do not want to replace included libraries. – Jens Peters Mar 03 '16 at 13:31
  • 2
    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. – OndroMih Mar 03 '16 at 14:11
  • Thank you, this is exactly what I want to know! – Jens Peters Mar 03 '16 at 14:17