I moved a single java source file from project A to project B and updated all of my package imports in project A to point to the new package structure which project B has. Everything compiles fine. Here is what happens when I run my JUnit tests (which we use spring-test for our dependency injection). One thing I do notice is that all of the dependencies of project B are added to the classpath as well - both project A & B do share some of the same dependencies (most of the spring dependencies). Not sure if this has anything to do with it or not. Here is the stack trace I get for each and every test execution that I run:
[11/26/2012 08:38:43 | ERROR | Test worker | TestContextManager.java:324]: Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@4c3212a8] to prepare test instance [org.tiaa.atom.content.fatwire.FatwireCoherenceSnippetCacheTester@6b66faac]
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:157) ~[org.springframework.test-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109) ~[org.springframework.test-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75) ~[org.springframework.test-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321) ~[org.springframework.test-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:211) [org.springframework.test-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:288) [org.springframework.test-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) [junit-4.10.jar:na]
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:290) [org.springframework.test-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) [org.springframework.test-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) [junit-4.10.jar:na]
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) [junit-4.10.jar:na]
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) [junit-4.10.jar:na]
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) [junit-4.10.jar:na]
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) [junit-4.10.jar:na]
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) [junit-4.10.jar:na]
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) [junit-4.10.jar:na]
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) [org.springframework.test-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30) [junit-4.10.jar:na]
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) [org.springframework.test-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.junit.runners.ParentRunner.run(ParentRunner.java:300) [junit-4.10.jar:na]
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) [org.springframework.test-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:55) [gradle-plugins-1.2.jar:1.2]
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:42) [gradle-plugins-1.2.jar:1.2]
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:75) [gradle-plugins-1.2.jar:1.2]
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:49) [gradle-plugins-1.2.jar:1.2]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0_35]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[na:1.6.0_35]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0_35]
at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_35]
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) [gradle-messaging-1.2.jar:1.2]
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) [gradle-messaging-1.2.jar:1.2]
at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32) [gradle-messaging-1.2.jar:1.2]
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93) [gradle-messaging-1.2.jar:1.2]
at $Proxy2.processTestClass(Unknown Source) [na:na]
at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:103) [gradle-plugins-1.2.jar:1.2]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0_35]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[na:1.6.0_35]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0_35]
at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_35]
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) [gradle-messaging-1.2.jar:1.2]
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) [gradle-messaging-1.2.jar:1.2]
at org.gradle.messaging.remote.internal.TypeCastDispatch.dispatch(TypeCastDispatch.java:30) [gradle-messaging-1.2.jar:1.2]
at org.gradle.messaging.remote.internal.WorkerProtocol.handleIncoming(WorkerProtocol.java:53) [gradle-messaging-1.2.jar:1.2]
at org.gradle.messaging.remote.internal.WorkerProtocol.handleIncoming(WorkerProtocol.java:31) [gradle-messaging-1.2.jar:1.2]
at org.gradle.messaging.remote.internal.ProtocolStack$ProtocolStage.handleIncoming(ProtocolStack.java:167) [gradle-messaging-1.2.jar:1.2]
at org.gradle.messaging.remote.internal.ProtocolStack$BottomStage.handleIncoming(ProtocolStack.java:277) [gradle-messaging-1.2.jar:1.2]
at org.gradle.messaging.remote.internal.ProtocolStack$BottomConnection$1.run(ProtocolStack.java:299) [gradle-messaging-1.2.jar:1.2]
at org.gradle.messaging.remote.internal.ProtocolStack$ExecuteRunnable.dispatch(ProtocolStack.java:120) [gradle-messaging-1.2.jar:1.2]
at org.gradle.messaging.remote.internal.ProtocolStack$ExecuteRunnable.dispatch(ProtocolStack.java:116) [gradle-messaging-1.2.jar:1.2]
at org.gradle.messaging.dispatch.AsyncDispatch.dispatchMessages(AsyncDispatch.java:132) [gradle-messaging-1.2.jar:1.2]
at org.gradle.messaging.dispatch.AsyncDispatch.access$000(AsyncDispatch.java:33) [gradle-messaging-1.2.jar:1.2]
at org.gradle.messaging.dispatch.AsyncDispatch$1.run(AsyncDispatch.java:72) [gradle-messaging-1.2.jar:1.2]
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66) [gradle-base-services-1.2.jar:1.2]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [na:1.6.0_35]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [na:1.6.0_35]
at java.lang.Thread.run(Thread.java:662) [na:1.6.0_35]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘mbeanServer’: Invocation of init method failed; nested exception is javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455) ~[org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) ~[org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) ~[org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) ~[org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) ~[org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) ~[org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) ~[org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567) ~[org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913) ~[org.springframework.context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464) ~[org.springframework.context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:103) ~[org.springframework.test-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1) ~[org.springframework.test-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.test.context.support.DelegatingSmartContextLoader.loadContext(DelegatingSmartContextLoader.java:228) ~[org.springframework.test-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:124) ~[org.springframework.test-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:148) ~[org.springframework.test-3.1.1.RELEASE.jar:3.1.1.RELEASE]
… 55 common frames omitted
Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645) ~[na:1.6.0_35]
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288) ~[na:1.6.0_35]
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325) ~[na:1.6.0_35]
at javax.naming.InitialContext.lookup(InitialContext.java:392) ~[na:1.6.0_35]
at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154) ~[org.springframework.context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87) ~[org.springframework.context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152) ~[org.springframework.context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178) ~[org.springframework.context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95) ~[org.springframework.context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105) ~[org.springframework.context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:201) ~[org.springframework.context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:187) ~[org.springframework.context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514) ~[org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452) ~[org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
… 69 common frames omitted
org.tiaa.atom.content.fatwire.FatwireCoherenceSnippetCacheTester > testSettingCacheRefreshIntervalTwice FAILED
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘mbeanServer’: Invocation of init method failed; nested exception is javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
Caused by:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial