I'm trying to implement a custom CDI scope and I thought it's the easiest to start by extending the existing @SessionScoped
. I started by following this tutorial. However, when visiting an XHTML page which references a CDI bean with my scope, this leads to
org.jboss.weld.context.ContextNotActiveException: WELD-001303: No active contexts for scope type myscope.MyScoped
at org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:687)
at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:740)
at org.jboss.weld.el.AbstractWeldELResolver.lookup(AbstractWeldELResolver.java:107)
at org.jboss.weld.el.AbstractWeldELResolver.getValue(AbstractWeldELResolver.java:90)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:188)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:116)
at com.sun.el.parser.AstValue.getBase(AstValue.java:151)
at com.sun.el.parser.AstValue.getTarget(AstValue.java:170)
at com.sun.el.parser.AstValue.invoke(AstValue.java:272)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UIViewAction.broadcast(UIViewAction.java:562)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
... 31 more
My annotation is
@Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
@NormalScope
public @interface MyScoped {
}
My context is
public class MyScopeContext extends HttpRequestContextImpl {
@Override
public Class<? extends Annotation> getScope() {
return MyScoped.class;
}
}
(note that I inherit from org.jboss.weld.context.http.HttpSessionContextImpl
.)
And my Extension is
public class MyScopeExtension implements Extension {
public void afterBeanDiscovery(@Observes AfterBeanDiscovery event, BeanManager manager) {
event.addContext(new MyScopeContext());
}
}
I'm running on GlassFish 4.1 with javax:javaee-web-api:7.0
and org.jboss.weld:weld-core:1.1.29.Final
on the classpath.
I'm almost sure I made some basic error, but what is it?
Aucun commentaire:
Enregistrer un commentaire