[jboss-as7-dev] If you see a NPE in your unit tests during an InitialContext reference...

Scott Marlow smarlow at redhat.com
Tue Aug 16 23:54:04 EDT 2011


Perhaps your on a branch and synced up with AS7 master as I just did. 
Or your on master and have some @Ignore tests that you occasionally use 
(and also just synced with the latest master commits).

It looks like this was already fixed in all of the active unit tests 
(thank you!).  For disabled tests or on your branches, you might need to 
add "@ArquillianResource" around your InitialContext variables.  You can 
probably also delete your assignment to the InitialContext variable as well.

Good code:

     @ArquillianResource InitialContext iniCtx;


This code will get a NPE when it uses iniCtx:

     private static InitialContext iniCtx;

     @BeforeClass
     public static void beforeClass() throws NamingException {
         iniCtx = new InitialContext();
     }

Hope this helps.

Scott


More information about the jboss-as7-dev mailing list