ContextNotActiveException when calling EJB remotely using JNDI

Posted on

I have an interceptor around my beans into which I inject a SessionScoped bean. This works fine for my web services and rest calls. For integration tests I have a helper bean (singleton) with @Remote methods. I call these methods from within my tests using JNDI to, for example, setup test data etc. When I put the same interceptor around this helper bean I am getting a ContextNotActiveException when jBoss tries to inject the SessionScoped bean into the interceptor.
Is there a way around this ?

My JNDI context on the client is created as follows:

        final Properties properties = new Properties();
        properties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
        return new InitialContext(properties);