title: Tests failing in Jenkins but works outside
body: <p>I have a test which tests Stateless Session Bean using OpenEJB. I am using Maven for build management. The test seems to work perfectly fine out of Jenkins (on command line) but fails after I added the job on Jenkins.</p>
  
  <p>More specifically, my test is not able to lookup the EJB in the JNDI and gets following exception.</p>
  
  <pre><code>javax.naming.NameNotFoundException: Name "global/slides/SlideService" not found.
      at org.apache.openejb.core.ivm.naming.IvmContext.federate(IvmContext.java:198)
      at org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:152)
      at org.apache.xbean.naming.context.ContextFlyweight.lookup(ContextFlyweight.java:55)
      at com.diycomputerscience.slides.service.SlideServiceTest.setUp(SlideServiceTest.java:45)
      at junit.framework.TestCase.runBare(TestCase.java:132)
      at junit.framework.TestResult$1.protect(TestResult.java:110)
      at junit.framework.TestResult.runProtected(TestResult.java:128)
      at junit.framework.TestResult.run(TestResult.java:113)
      at junit.framework.TestCase.run(TestCase.java:124)
      at junit.framework.TestSuite.runTest(TestSuite.java:243)
      at junit.framework.TestSuite.run(TestSuite.java:238)
      at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
      at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:236)
      at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:134)
      at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:113)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
      at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
      at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
      at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)
      at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)
  </code></pre>
  
  <p>I wonder if running the tests in Jenkins somehow affects the JNDI? I know that Jenkins uses Maven embedder, but Surefire plugin forks the tests by default and it possibly not running inside the same vm instance as of Jenkins.</p>
  
  <p>I am running the jenkins in foreground (java -jar jenkins.war) and also running with the same user as I am logged in so there is no permissions issue. Also I do not need Window Manager running as my tests do not need to interact with UI unlike Selenium. </p>
  
  <p>The Java and Maven version I am using in both environments is exactly identical too.</p>
  
  <p>Any pointers?</p>