隨筆 - 32, 文章 - 1, 評(píng)論 - 5, 引用 - 0
          數(shù)據(jù)加載中……

          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í),將其覆蓋了。

          posted on 2010-12-09 18:24 colorfire 閱讀(3218) 評(píng)論(0)  編輯  收藏


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 措勤县| 靖安县| 凤台县| 邳州市| 乌拉特中旗| 丘北县| 寿宁县| 伊宁县| 长垣县| 马山县| 柞水县| 万载县| 临泉县| 东至县| 兴国县| 抚远县| 四平市| 驻马店市| 安康市| 富蕴县| 蕉岭县| 宁远县| 通许县| 舒城县| 房山区| 工布江达县| 河池市| 衢州市| 玉龙| 塔河县| 大新县| 依兰县| 水富县| 尚志市| 资兴市| 彩票| 海安县| 邵东县| 修文县| 高尔夫| 天台县|