Search code examples
objectifyjakarta-migration

How to convert Objectify 6.0.9 to Jakarta namespace


I am upgrading a project from java 8 to java 17, which uses the Jakarta namespace and I make use of Objectify java library to communicate with Google datastore, but the problem is that Objectify 6.0.9 uses javax.servlet.* which does not exist in java 17.

I have searched for a Jakarta version of the Objectify library in the maven repo without success, please how do I convert the Objectify library from javax.servlet.* to jakarta.servlet.* ?


Solution

  • The servlet package is only used by ObjectifyFilter, which is two lines of real code:

    https://github.com/objectify/objectify/blob/master/src/main/java/com/googlecode/objectify/ObjectifyFilter.java

    Just roll your own filter. All you need is this:

    try (Closeable closeable = ObjectifyService.begin()) {
        chain.doFilter(request, response);
    }
    

    At some point a future version of Objectify will switch to jakarta.*, but it no doubt cause trouble for other users so I'll probably err on being a little too late rather than too early. Google says they're turning down GAE/Java8 at the end of this year so that's probably a good time.