With what to replace com.sun.jersey.guice.spi.container.servlet.GuiceContainer in Jersey version 2?

172 Views Asked by At

I have a Java web application using Google Guice as a framework which is currently on Java 8, and I need to upgrade it to Java 17. I am currently replacing all old classes from com.sun.jersey version 1.19.4 to org.glassfish.jersey.core version 2.35 which is compatible with Java 17. I have a class which extends GuiceServletContextListener, and in this class I configure jersey. So I have this statement declared in the class which uses GuiceContainer from import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;

            serve("/test/*").with(GuiceContainer.class, jerseyParams);

The GuiceContainer is not available in jersey version 2. So I do not know how to replace it with something else in order for the application to run.Or do I need to implement something custom in order for this serve to work

I tried looking for feasible solutions or ideas on how to replace the GuiceContainer but I could not find anything which could help me in any way. I could not find anything similar on stackOverflow.

1

There are 1 best solutions below

0
jan.supol On

Jersey 2 relies on HK2 with injection. It is the HK2-Guice bridge that serves as a support for Guice integration if needed in Jersey 2.