No qualifying bean of type 'javax.faces.push.PushContext' available
Hi,
We are using Joinfaces 4.0.5 with MyFaces 2.3.3. Since 2.3, JSF allows the usage of Websockets. Those can (according to Joinfaces documentation) be enabled with
joinfaces.jsf.enable-websocket-endpoint=true
If I add a controller bean with the following content, the error message from the title occurs.
@Named
@ViewScoped
public class Controller {
private PushContext pushContext;
@Inject
public Controller( @Push final PushContext pushContext ) {
this.pushContext = pushContext;
}
...
}
Once enabled, the AbstractFacesInitializer creates the Websocket, but it seems that there is no implementation of the PushContext available in the Spring context. It seems to me that usually the PushContextFactoryBean is responsible to create the contexts, but in Joinfaces the factory is not active. I would assume that some similar (Spring) bean factory is required.
I can as always share a minimal example if you need it.
Best regards
Nils
Hi,
I tried to create the push context via Spring:
@Bean
@Push
@Scope ( ConfigurableBeanFactory.SCOPE_PROTOTYPE )
public PushContext pushContext( final InjectionPoint ip ) {
final Push push = ip.getAnnotation( Push.class );
final String channel = push.channel( ).isEmpty( ) ? ip.getMember( ).getName( ) : push.channel( );
return new PushContextImpl( channel );
}
However, this is not sufficient - the WebsocketComponentRenderer throws a NPE while trying to access further beans from the uninitialized CDI-Utils.
The PushContext implementations of both MyFaces and Mojarra heavily depend on CDI.
Hi @larsgrefer,
it's not possible to register the missing beans in Spring?
Kind regards Oliver
org.apache.myfaces.push.cdi.PushContextImpl itself heavily depends on CDI.
Ok, I see :-(
Hi everyone, in this case which alternatives are you using?
and considering that JSF is getting more and more dependent on CDI, do you think JoinFaces will be able to keep up?
You could try If PushContext works when including org.joinfaces:weld-spring-boot-starter
Including weld CDI does also not work.
Any idea of how we can get PushContext working?
Because JSF 2.3 Websocket rely heavily on CDI you have to make your Controller instantied by your CDI container (e.g WELD) and not by Spring. I have been able to make it work by excluding my JSF controllers from the Spring component scan and having my PushContext injected properly. Note that you have now two CDI containers (Spring & WELD) working side by side with your JSF controllers managed by WELD and not Spring.
@cdumarcey can you give some working example? tried to exclude my controller by defining fitlers in @ComponentScan annotation. But haven't succeed, it looks like it ignores it, and I get an exception about No qualifying bean of type 'javax.faces.push.PushContext'
I also need to integrate Push notifications in my JoinFaces application, and get a No qualifying bean of type 'org.omnifaces.cdi.PushContext' error.
Is there any example on how to make this work . Please help