Hey guys,

first time on a mailing list, please bear with me.

I was trying to test request scoped beans using meecrowave-junit, and the
test kept crashing with the following exception:

javax.enterprise.context.ContextNotActiveException: WebBeans context with
scope type annotation @RequestScoped does not exist within current thread
at
org.apache.webbeans.container.BeanManagerImpl.getContext(BeanManagerImpl.java:329)
at
org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.getContextualInstance(NormalScopedBeanInterceptorHandler.java:89)
at
org.apache.webbeans.intercept.RequestScopedBeanInterceptorHandler.getContextualInstance(RequestScopedBeanInterceptorHandler.java:76)
at
org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.get(NormalScopedBeanInterceptorHandler.java:71)
...

While digging, I came across MeecrowaveExtension:getScopes, and while
stepping through I'm realizing that the returned optional will always
contain null, because
- this method is only called in beforeEach, afterEach, therefore
context.getElement() will always return a method instance
- method instances will never have a MeecrowaveConfig annotation, since
that annotation is only allowed for types (MeecrowaveConfig:L35)

Overriding the MeecrowaveConfig annotation with a local copy which has the
annotation targets {TYPE, METHOD} (instead of TYPE only) allows me to
annotate the tested method with @MeecrowaveConfig(scopes =
RequestScoped.class), which seems to be the intended behavior.

Is this a known bug? Or am I missing something else?

best,
Waldemar

Reply via email to