0

I want to use Odata – Apache Olingo V4 (4.9.0 latest now) in my Spring Boot application (version 3.1.2). It seems Olingo V4 wants javax Servlet instead of Jakarta Servlet in the handler.
What is the solution here?
Tomcat embed core 9.0.x won't work with Spring Boot 3.1.2 either!

I can't downgrade to previous Spring Boot versions. Tried using Tomcat embed core 9.0.73 but that is not compatible with Spring Boot 3.x

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@RestController
@RequestMapping("odata")
public class ODataController {
    
    @Autowired
    CsdlEdmProvider edmProvider;
    
    @Autowired
    EntityCollectionProcessor collectionProcessor;

    @Autowired
    CustomServiceDocumentProcessor customServiceDocumentProcessor;

    @RequestMapping
    public void process1(HttpServletRequest request, HttpServletResponse response) {
        try {
            OData odata = OData.newInstance();
            ServiceMetadata edm = odata.createServiceMetadata(edmProvider,
                    new ArrayList<>());
            ODataHttpHandler handler = odata.createHandler(edm);
            handler.register(collectionProcessor);
            handler.register(customServiceDocumentProcessor);
            request.setAttribute("requestMapping", "/odata");
            handler.process(request, response); // This must be javax.....
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
greybeard
  • 2,249
  • 8
  • 30
  • 66
Jeni
  • 3
  • 1
  • Use something like https://github.com/nebula-plugins/gradle-jakartaee-migration-plugin, or fork Olingo and build one with jakarta instead of javax (the Olingo JIRA contains multiple patches to this effect). – Mark Rotteveel Aug 03 '23 at 10:52
  • Thank you, I will try something like that. – Jeni Aug 08 '23 at 13:17

0 Answers0