Fwd: BeanManager cannot be located in context

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Fwd: BeanManager cannot be located in context


I'm trying to implement JUnit tests for Stripes actions, but i get this error :

[DEBUG] Running CDI dependency injection for instance of UserRankingActionBean
[ERROR] BeanManager cannot be located in context. Either you are using an archive with no beans.xml, or the BeanManager has not been produced.

The ActionBean call a CDI Object (injected with @Inject annotation), in debug mode the service injected by CDI is Null.

This is my TestFixure class :

public class TestFixture {

  private static MockServletContext context;

  public static MockServletContext getServletContext() {

    // Instantiate MockServletContext
    context = new MockServletContext("test");

    // Add the configuration params
    Map<String, String> filterParams = new HashMap<String, String>();
    filterParams.put("ActionResolver.Packages", "xxx");
    filterParams.put("Extension.Packages", "com.samaxes.stripes.inject");
    filterParams.put("ExceptionHandler.Class", "xxx");
    filterParams.put("Interceptor.Classes", "xxx");

    context.addFilter(StripesFilter.class, "StripesFilter", filterParams);
    context.addFilter(DynamicMappingFilter.class, "DynamicMappingFilter", filterParams);

    // Add the configuration file
    context.addInitParameter("contextConfigLocation", "/WEB-INF/applicationContext.xml");

    // Add the Stripes Dispatcher
    context.setServlet(DispatcherServlet.class, "StripesDispatcher", null);

    return context;

And my Test class i use :

MockServletContext ctx = TestFixture.getServletContext();
MockRoundtrip trip = new MockRoundtrip(ctx, XXXActionBean.class);



Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
&#149; 3 signs your SCM is hindering your productivity
&#149; Requirements for releasing software faster
&#149; Expert tips and advice for migrating your SCM now
Stripes-users mailing list
[hidden email]