WELD-001303 No active contexts for scope type javax.faces.bean.ViewScoped

Splash Forums Rewrite Users WELD-001303 No active contexts for scope type javax.faces.bean.ViewScoped

This topic contains 19 replies, has 4 voices, and was last updated by  Roycenek 3 years, 6 months ago.

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
  • #18186



    My site used JSF1.2 and Mojara Scales in the past to deliver (basic) pretty urls. When migrating to JSF2+, wrapping the HttpServletRequest isn’t possible anymore. So I started using Rewrite.

    My setup is Glassfish 3.1.2, Richfaces 4.1, JSF2.1, Weld 1.1.4, SeamFaces 3.1.0 and Rewrite Alpha11.

    Besides for Rewrite, I use Seam Faces because it enables @ViewScoped to be CDI-managed. Actually @ConversationScoped doesn’t do everything I want and @ViewScoped is the closest to what a4j:keepAlive did in RichFaces 3.3 in the past. Easier migration for me.

    With simple URLs, Rewrite works perfect.

    Example: .addRule(Join.path(“/blog/”).to(“/public/blogList.jsf”))

    The only issue I have is exception swallowing. I read other posts on this forum, and I @HandlesExceptions them now. Annoying but I’ll survive.

    Now I’m trying to inject arguments:

    .addRule(Join.path(“/blog/id/{id}/”).to(“/public/blogList.jsf”).where(“id”).bindsTo(El.property(“blogView.id”, LongConverter.class)))

    The blogView is @ViewScoped. And that’s where it blows up. I’ve searched, I’m out of ideas. Lincoln, Christian, do you have any hint?

    INFO: WELD-001303 No active contexts for scope type javax.faces.bean.ViewScoped

    GRAVE: org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type javax.faces.bean.ViewScoped

    at org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:598)

    at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:71)

    at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:79)

    at com.suntriprecords.v2.site.content.BlogViewHandler$Proxy$_$$_WeldClientProxy.setId(BlogViewHandler$Proxy$_$$_WeldClientProxy.java)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    at java.lang.reflect.Method.invoke(Method.java:597)

    at javax.el.BeanELResolver.setValue(BeanELResolver.java:442)

    at javax.el.CompositeELResolver.setValue(CompositeELResolver.java:394)

    at com.sun.el.parser.AstValue.setValue(AstValue.java:217)

    at com.sun.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:291)

    at org.jboss.weld.el.WeldValueExpression.setValue(WeldValueExpression.java:64)

    at com.ocpsoft.rewrite.cdi.CdiExpressionLanguageProvider.setValue(CdiExpressionLanguageProvider.java:123)

    at com.ocpsoft.rewrite.cdi.CdiExpressionLanguageProvider.submitValue(CdiExpressionLanguageProvider.java:74)

    at com.ocpsoft.rewrite.bind.El$ElProperty.submit(El.java:321)

    at com.ocpsoft.rewrite.bind.Bindings$BindingOperation.perform(Bindings.java:310)

    at com.ocpsoft.rewrite.servlet.impl.DefaultHttpRewriteProvider.rewrite(DefaultHttpRewriteProvider.java:42)

    at com.ocpsoft.rewrite.servlet.impl.DefaultHttpRewriteProvider.rewrite(DefaultHttpRewriteProvider.java:31)

    at com.ocpsoft.rewrite.servlet.RewriteFilter.rewrite(RewriteFilter.java:207)

    at com.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:171)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)

    at org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)

    at org.jboss.solder.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:72)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)

    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)

    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)

    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)

    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)

    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)

    at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)

    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)

    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)

    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)

    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)

    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)

    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)

    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)

    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)

    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)

    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)

    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)

    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)

    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)

    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)

    at java.lang.Thread.run(Thread.java:662)


    Yes. Rewrite operates in a ServletFilter, meaning that JSF has not yet begun its lifecycle, thus, the bean does not yet exist because as the exception suggests, the context has not yet been started.

    You would need to add a deferred injection in order for this to work. In fact, that’s a feature we need. You’d have to cache the values to be injected, then do the injection in a PhaseListener. We should add this functionality to Rewrite JSF Integration.

    Is this something you’d be interested in prototyping?



    In fact, you can see how this was implemented for PhaseAction, because the PrettyPhaseListener already does the exact same type of caching. You could even add a feature that allows you to specify in which Phase you want the injection to occur!



    Thank you. Of course. I remember the Rewrite code now…

    Yes I’m interested in adding that feature, but for a ton of reasons including a small baby, my pull req might not show up as fast as expected… count me in.




    I’m on it. It took me some time…to find some time.

    There’s (too) few comments but OK one can understand what does what in a decent time.

    Now I’d prefer to ask you if you would do what I’m planning on doing. Not only do I know how some prefer to have the code designed in a specific way, but I may not have seen a more obvious way of doing it either.

    First, having a mechanism like what RewritePhaseListener/PhaseAction do is piece of cake.

    However it’s harder to find a way to “insert” the deferred behavior without changing some code in rewrite-servlet. I don’t want to touch the RewriteProvider#rewrite > Operation#perform > Binding#submit mechanic, neither duplicate it of course. So I’ve been thinking of having a “fake” ExpressionLanguageProvider which would defer params bindings till the “ad-hoc” PhaseListener kicks in, but the CdiExpressionLanguageProvider is already in the way…Yet I think I’ll need to modify both the Cdi and Faces integration projects anyway. So that may be a good approach.

    What do you think?



    There’s actually a smarter solution…


    My thoughts:

    You shouldn’t need to change RewriteServlet at all – what are you trying to do that makes you think we should change code there?

    Why not just add an Operation called “DefferredInjection,” which would add itself to a Request parameter – that could later be retrieved by RewritePhaseListener, which would perform the injection during the right JSF phase.

    I think that the Operation#perform() > Binding#submit mechanism is exactly what you want here, but you can re-use what was already done.

    What is your smarter solution? :)

    BTW. This code should all go in the integration-faces module, I think! Just take a look at what PhaseAction does, then you can pretty much copy that and create PhaseInjection Thoughts?




    My smarter solution is more or less what you’re describing.

    Once the bindings are in the request, it’s piece of cake, as I said earlier.

    What’s supposed to happen before was more problematic to me. I just couldn’t figure out initally how/where to instanciate the new operation nicely, so I was tempted to fall back on ambiguous solutions (either build some weird ExpressionLanguageProvider, or add some “defferred” test in the Bindings machinery…)

    Thing is, at first I tried to embrace the code quickly to get started, but it took me a while to actually “wire” it. Things are getting better.




    pull req done.


    Woot! Will review tomorrow morning, need to sleep! Thanks very much :)

    Pull requests are better than Christmas :p




    Hi Lincon and fabmars, I try to start project with rewrite on AS7, when try to run get

    JBWEB000284: Exception starting filter OCPsoft Rewrite Filter: org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type javax.enterprise.context.RequestScoped

    please advice


    Hi jlgranda,

    Could you please start a new thread for this problem? It is related but different.

    Your exception means that you are doing potentially non-threadsafe access of a request scoped bean.




    Tnahk you Lincoln, by the moment, I’m removed rewritte support in my project.



    Oh, shame on you. No, just kidding, you may not need it actually. But it’s a wonderful addon to many web-based apps :)



    This problem is easy to solve (I know the answer,) but all I ask is that you start a separate thread for your new topic :)



Viewing 15 posts - 1 through 15 (of 20 total)

The forum ‘Rewrite Users’ is closed to new topics and replies.

Comments are closed.