0

I have a project with "Omnifaces 3.3" and "weld.servlet.shaded 3.0.5.Final". I need to use a request parameter named "cid" in my application, but using it produces the next exception in Weld:

javax.servlet.ServletException: WELD-000321: No conversation found to restore for id 12312312
javax.faces.webapp.FacesServlet.service(FacesServlet.java:683)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
es.ine.sgtic.web.filter.SessionTimeoutFilter.doFilter(SessionTimeoutFilter.java:38)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)

I'm trying to rename the parameter that uses Weld internally using the next context-param, but it doesn't work, it keeps using "cid":

 servletContext.setInitParameter("WELD_CONTEXT_ID_KEY", "weldCid")

I'm using JSF 2.3 with Spring, so my beans are managed by Spring with the annotation @Component. I've seen other solutions where they Inject @Inject private HttpConversationContext conversationContext; in an application bean, but it isn't available, and Spring doesn't find any implementation of that interface if I try to inject it in a bean.

How can I rename that parameter or get rid of it. I only use WELD in my project because Omnifaces requires it, but I don't really use anything from it.

Thanks.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
maqjav
  • 2,310
  • 3
  • 23
  • 35

1 Answers1

0

After many tests, the only thing that worked was the next listener.

@WebListener
public class MyServletContextListener implements ServletContextListener {

    @Inject
    private HttpConversationContext conversationContext;

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        this.hideConversationScope();
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        // Not used
    }

    private void hideConversationScope() {
        this.conversationContext.setParameterName(UUID.randomUUID().toString());
    }
}

Here the object "conversationContext" was properly initialized and the renamed worked.

maqjav
  • 2,310
  • 3
  • 23
  • 35