eclipse你不知道的.classpath
題目是噱頭,用的人都知道。我想說(shuō)的是classpath中不太注意的classpathentry excluding。
昨天在跑junit測(cè)試時(shí),報(bào)錯(cuò)提示springframe.test.jar多次加載。 nnd,前天跑還一切正常,今天切了一下版本,又切回來(lái),就不行了。
java.lang.IllegalStateException: Unable to dynamically start generated unit test bundle
at org.springframework.osgi.test.AbstractOnTheFlyBundleCreatorTests.postProcessBundleContext(AbstractOnTheFlyBundleCreatorTests.java:527)
at org.springframework.osgi.test.AbstractConfigurableBundleCreatorTests.postProcessBundleContext(AbstractConfigurableBundleCreatorTests.java:223)
at org.springframework.osgi.test.AbstractOsgiTests.startup(AbstractOsgiTests.java:262)
at org.springframework.osgi.test.AbstractOsgiTests.prepareTestExecution(AbstractOsgiTests.java:374)
at org.springframework.osgi.test.AbstractOsgiTests.runBare(AbstractOsgiTests.java:203)
at org.springframework.osgi.test.AbstractOsgiTests$1.protect(AbstractOsgiTests.java:184)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at org.springframework.osgi.test.AbstractOsgiTests.run(AbstractOsgiTests.java:181)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.osgi.framework.BundleException: Cannot import a package more than once "org.springframework.osgi.test"
at org.eclipse.osgi.internal.resolver.StateBuilder.checkImportExportSyntax(StateBuilder.java:533)
at org.eclipse.osgi.internal.resolver.StateBuilder.validateHeaders(StateBuilder.java:185)
at org.eclipse.osgi.internal.resolver.StateBuilder.createBundleDescription(StateBuilder.java:49)
at org.eclipse.osgi.internal.resolver.StateObjectFactoryImpl.createBundleDescription(StateObjectFactoryImpl.java:32)
at org.eclipse.osgi.internal.baseadaptor.BaseStorage.updateState(BaseStorage.java:1112)
at org.eclipse.osgi.internal.baseadaptor.BundleInstall.commit(BundleInstall.java:128)
at org.eclipse.osgi.framework.internal.core.Framework.installWorkerPrivileged(Framework.java:965)
at org.eclipse.osgi.framework.internal.core.Framework$2.run(Framework.java:854)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.framework.internal.core.Framework.installWorker(Framework.java:905)
at org.eclipse.osgi.framework.internal.core.Framework.installBundle(Framework.java:849)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.installBundle(BundleContextImpl.java:234)
at org.springframework.osgi.test.AbstractOnTheFlyBundleCreatorTests.installAndStartBundle(AbstractOnTheFlyBundleCreatorTests.java:539)
at org.springframework.osgi.test.AbstractOnTheFlyBundleCreatorTests.postProcessBundleContext(AbstractOnTheFlyBundleCreatorTests.java:524)
15 more

找了一個(gè)小時(shí)都沒(méi)找到原因。
項(xiàng)目背景是該模塊使用的是osgi框架,框架中包含spring的所有包。但是在編譯時(shí),需要單獨(dú)把測(cè)試包加進(jìn)來(lái)。
根據(jù)問(wèn)題,我懷疑是classpath,但是如果去掉jar包引用,連編譯都編譯不過(guò)去。
最后翻到eclipse的.classpath文件才找到原因,classpathentry excluding這家伙被覆蓋掉了。
excluding標(biāo)簽是保證項(xiàng)目在啟動(dòng)時(shí)不會(huì)講指定的目錄jar加載到內(nèi)存,只做編譯引用。
我在切換版本時(shí),將其覆蓋了。
昨天在跑junit測(cè)試時(shí),報(bào)錯(cuò)提示springframe.test.jar多次加載。 nnd,前天跑還一切正常,今天切了一下版本,又切回來(lái),就不行了。




































找了一個(gè)小時(shí)都沒(méi)找到原因。
項(xiàng)目背景是該模塊使用的是osgi框架,框架中包含spring的所有包。但是在編譯時(shí),需要單獨(dú)把測(cè)試包加進(jìn)來(lái)。
根據(jù)問(wèn)題,我懷疑是classpath,但是如果去掉jar包引用,連編譯都編譯不過(guò)去。
最后翻到eclipse的.classpath文件才找到原因,classpathentry excluding這家伙被覆蓋掉了。
excluding標(biāo)簽是保證項(xiàng)目在啟動(dòng)時(shí)不會(huì)講指定的目錄jar加載到內(nèi)存,只做編譯引用。
我在切換版本時(shí),將其覆蓋了。
posted on 2010-12-09 18:24 colorfire 閱讀(3218) 評(píng)論(0) 編輯 收藏