deltaspike-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charlee Chitsuk <charlee...@gmail.com>
Subject Re: Could you please help to advise about the Container & Control?
Date Mon, 03 Jun 2013 08:53:22 GMT
Hi All,

I've found some steps to fix it as the following: -

The exception occurs when I'm using

ContextControl ctxCtrl =
BeanProvider.getContextualReference(ContextControl.class);
ctxCtrl.stopContext(RequestScoped.class);

If I'm switching to use the

CdiContainer CdiContainer = CdiContainerLoader.getCdiContainer();
ContextControl contextControl = cdiContainer.getContextControl();
ctxCtrl.stopContext(RequestScoped.class);

There is no any exception. Everything seems fine.

I thought the root cause may be my customized JUnit runner as the
following: -

public class CdiJUnit4Runner extends BlockJUnit4ClassRunner {

static {
CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();
cdiContainer.boot();
ContextControl contextControl = cdiContainer.getContextControl();
contextControl.startContexts();
}
 private final Class<?> klass;

public CdiJUnit4Runner(final Class<?> myKlass) throws InitializationError {
super(myKlass); this.klass = myKlass; }

    @Override
    protected Object createTest() throws Exception {
        Object test = null;
        try {
            test = BeanProvider.getContextualReference(this.klass, true);
            return test;
        } finally {
            test = null;
        }

    }
}

@RunWith(CdiJUnit4Runner.class)
public class MyTest { ... }

Could you please help to advise further about the ContextControl  between
getting it by using the BeanProvider and getting it from CdiContainer?
Thank you very much for your help in advance. I'm looking forward to
hearing from you soon.

-- 
   Best Regards,

   Charlee Chitsuk


2013/5/30 Charlee Chitsuk <charlee.ch@gmail.com>

> Hi All,
>
> I'm using DS version 0.3-incunating together with deltaspike-cdictrl-weld
> and Weld-SE version 1.1.12.Final. I've started the DS by using the
>
> contextControl.startContexts();
>
> with purpose to start all Contexts. When I try to stop the RequestScoped
> by using the
>
> ctxCtrl.stopContext(RequestScoped.class);
>
> There is an exception  as the following: -
>
> java.lang.NullPointerException
> at
> org.jboss.weld.context.bound.BoundRequestContextImpl.dissociate(BoundRequestContextImpl.java:40)
>  at
> org.jboss.weld.context.bound.BoundRequestContextImpl.dissociate(BoundRequestContextImpl.java:13)
> at
> org.apache.deltaspike.cdise.weld.ContextController.stopRequestScope(ContextController.java:156)
>  at
> org.apache.deltaspike.cdise.weld.WeldContextControl.stopRequestScope(WeldContextControl.java:213)
> at
> org.apache.deltaspike.cdise.weld.WeldContextControl.stopContext(WeldContextControl.java:106)
>
>     Please note, If I catch that NullPointerException and try to
> start/stop again, it works without any exception as the following example: -
>
>         try {
>             ctxCtrl.stopContext(RequestScoped.class);
>         } catch (NullPointerException e) {
>             e.printStackTrace();
>         }
>
>         ctxCtrl.startContext(RequestScoped.class);
>
>         ctxCtrl.stopContext(RequestScoped.class);
>         ctxCtrl.startContext(RequestScoped.class);
>
> I'm not sure If I'm doing something wrong or miss understanding. Could you
> please help to advise further?
>
> --
>    Best Regards,
>
>    Charlee Chitsuk
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message