Can MyFaces + CDI be used on WebLogic 12c?

旧街凉风 提交于 2019-12-04 00:33:07

I'm afraid there is no way to do it. The weld glue code needs to be there. Those tiny little integration layer that is part of the wls deployable libraries for jsf isn't available for myfaces ....

There are quite a few things which are not clear in your example. E.g. what package is the @RequestScoped from? Is it the javax.enterprise.context.RequestScoped (should work) or the javax.faces.bean.RequestScoped (will not work)? If you are using CDI beans only (and no javax.faces.bean stuff) then the only way the JSF container and the CDI container integrate with each other is actually the Unified Expression Language javax.el.ELResolver. And this must work out of the box.

org.apache.myfaces.webapp.StartupServletContextListener is not really needed imo. All you need is to set the FacesServlet.

The problematic spot might be that the JSF EG got forced to use the ServletContainerInitializer [1] to blindly activate the JSF impl, even if the app does not use JSF at all. This is hard to get around as the servlet-3.0 spec only defines how to automatically activate those features but there is NO way to disable them again.

[1] http://docs.oracle.com/javaee/6/api/javax/servlet/ServletContainerInitializer.html

Just wondering, did you try enabling weld servlet within your app?

The reason I asked is because of this statement:

I read somewhere (can't remember where) that whenever you decide to switch JSF implementation you're responsible for integrating JSF/CDI yourself

Which is fairly accurate. The container is the one that does the whole combined layering of the JSF impl and CDI impl together. If you replace it with your own JSF impl, you are bypassing what the container gives you. If you haven't yet, I would strongly recommend you to try enabling Weld Servlet in your app to see if CDI boots up w/ the custom JSF impl.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!