在maven安装期间出现奇怪的异常,但是建立成功

时间:2014-03-28 08:35:45

标签: java maven apache-karaf osgi-bundle

在做maven安装时会弹出一些奇怪的异常

 [WARNING] Exception while updating local OBR: Unable to read repository xml: file:/home/.m2/repository/repository.xml
 org.apache.maven.plugin.MojoExecutionException: Unable to read repository xml: file:/home/.m2/repository/repository.xml
    at org.apache.felix.obrplugin.ObrUpdate.parseRepositoryXml(ObrUpdate.java:324)
    at org.apache.felix.obrplugin.ObrInstall.execute(ObrInstall.java:143)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.xmlpull.v1.XmlPullParserException: unexpected type (position:END_DOCUMENT null@1:0 in java.io.InputStreamReader@34d475c1) 
    at org.kxml2.io.KXmlParser.exception(Unknown Source)
    at org.kxml2.io.KXmlParser.nextTag(Unknown Source)
    at org.apache.felix.bundlerepository.impl.PullParser.parseRepository(PullParser.java:43)
    at org.apache.felix.bundlerepository.impl.DataModelHelperImpl.repository(DataModelHelperImpl.java:147)
    at org.apache.felix.bundlerepository.impl.DataModelHelperImpl.repository(DataModelHelperImpl.java:118)
    at org.apache.felix.obrplugin.ObrUpdate.parseRepositoryXml(ObrUpdate.java:316)
... 22 more

这是我在给maven install时获得的例外。它适用于所有项目。我正在用maven编译 OSGI-BUNDLES 。更改settings.xml也无济于事。由于此错误,我无法在Karaf中部署我的捆绑包。似乎.m2/repository/repository.xml是空的。

2 个答案:

答案 0 :(得分:2)

发生的任何Mojo异常都是由于在mvn安装期间没有正确下载某些jar的问题。

尝试删除.m2本地存储库并再次执行干净构建,看看是否再次面临同样的问题。

还尝试检查Java verson与您使用的Maven版本的兼容性,这也会导致问题。依赖性检查也可以一段时间解决它,因为您可能忘记在pom.xml中添加正确的依赖项

答案 1 :(得分:0)

[WARNING] Exception while updating local OBR: Unable to read repository xml: file:/home/.m2/repository/repository.xml

在我的机器上,这是因为我的用户对 repository.xml 的权限被神秘地删除了。当我恢复它们时,错误消失了,一切都按预期运行。