如何解决joda-time和org.joda

时间:2015-09-05 03:50:34

标签: java maven osgi jodatime

当我启动我的应用程序时,virgo抛出这样的异常:

[2015-09-05 11:27:53.254]  TCP Connection(2)-127.0.0.1 <DE0002E> Installation of bundle 'com.onboard.web.api' version '3.0.0.SNAPSHOT' failed. org.eclipse.virgo.kernel.osgi.framework.UnableToSatisfyBundleDependenciesException: Unable to satisfy dependencies of bundle 'com.onboard.web.api' at version '3.0.0.SNAPSHOT': Cannot resolve: com.onboard.web.api
Resolver report:
    Uses violation: <Import-Package: org.springframework.format.datetime.joda; version="0.0.0"> in bundle <com.onboard.web.api_3.0.0.SNAPSHOT[1441423661083]>
        Found conflicts:
            package        'org.joda.time_1.6.0' in bundle 'com.springsource.org.joda.time_1.6.0[89]' used by 'org.springframework.format.datetime.joda_3.1.0.RELEASE' in bundle 'org.springframework.context_3.1.0.RELEASE[60]'
            conflicts with 'org.joda.time_2.3.0' in bundle 'joda-time_2.3.0[147]' used by 'com.onboard.service.github_3.0.0.SNAPSHOT' in bundle 'com.onboard.service.github_3.0.0.SNAPSHOT[189]'
            package        'org.joda.time_1.6.0' in bundle 'com.springsource.org.joda.time_1.6.0[89]' used by 'org.springframework.format.datetime.joda_3.1.0.RELEASE' in bundle 'org.springframework.context_3.1.0.RELEASE[60]'
            conflicts with 'org.joda.time_2.3.0' in bundle 'joda-time_2.3.0[147]' used by 'com.onboard.service.github_3.0.0.SNAPSHOT' in bundle 'com.onboard.service.github_3.0.0.SNAPSHOT[189]'
            package        'org.joda.time.format_1.6.0' in bundle 'com.springsource.org.joda.time_1.6.0[89]' used by 'org.springframework.format.datetime.joda_3.1.0.RELEASE' in bundle 'org.springframework.context_3.1.0.RELEASE[60]'
            conflicts with 'org.joda.time.format_2.3.0' in bundle 'joda-time_2.3.0[147]' imported by bundle 'com.onboard.web.api_3.0.0.SNAPSHOT[1441423661083]'
            package        'org.joda.time.format_1.6.0' in bundle 'com.springsource.org.joda.time_1.6.0[89]' used by 'org.springframework.format.datetime.joda_3.1.0.RELEASE' in bundle 'org.springframework.context_3.1.0.RELEASE[60]'
            conflicts with 'org.joda.time.format_2.3.0' in bundle 'joda-time_2.3.0[147]' imported by bundle 'com.onboard.web.api_3.0.0.SNAPSHOT[1441423661083]'
            package        'org.springframework.core.convert.converter_3.1.0.RELEASE' in bundle 'org.springframework.core_3.1.0.RELEASE[61]' used by 'org.springframework.format.datetime.joda_3.1.0.RELEASE' in bundle 'org.springframework.context_3.1.0.RELEASE[60]'
            conflicts with 'org.springframework.core.convert.converter_3.1.0.RELEASE' in bundle 'org.springframework.core_3.1.0.RELEASE[112]' used by 'org.springframework.web.servlet.tags_3.1.0.RELEASE' in bundle 'org.springframework.web.servlet_3.1.0.RELEASE[168]'
            package        'org.springframework.core.convert.converter_3.1.0.RELEASE' in bundle 'org.springframework.core_3.1.0.RELEASE[61]' used by 'org.springframework.format.datetime.joda_3.1.0.RELEASE' in bundle 'org.springframework.context_3.1.0.RELEASE[60]'
            conflicts with 'org.springframework.core.convert.converter_3.1.0.RELEASE' in bundle 'org.springframework.core_3.1.0.RELEASE[112]' used by 'org.springframework.web.servlet.config.annotation_3.1.0.RELEASE' in bundle 'org.springframework.web.servlet_3.1.0.RELEASE[168]'
            package        'org.joda.time_1.6.0' in bundle 'com.springsource.org.joda.time_1.6.0[89]' used by 'org.springframework.format.datetime.joda_3.1.0.RELEASE' in bundle 'org.springframework.context_3.1.0.RELEASE[111]'
            conflicts with 'org.joda.time_2.3.0' in bundle 'joda-time_2.3.0[147]' used by 'com.onboard.service.github_3.0.0.SNAPSHOT' in bundle 'com.onboard.service.github_3.0.0.SNAPSHOT[189]'
            package        'org.joda.time_1.6.0' in bundle 'com.springsource.org.joda.time_1.6.0[89]' used by 'org.springframework.format.datetime.joda_3.1.0.RELEASE' in bundle 'org.springframework.context_3.1.0.RELEASE[111]'
            conflicts with 'org.joda.time_2.3.0' in bundle 'joda-time_2.3.0[147]' used by 'com.onboard.service.github_3.0.0.SNAPSHOT' in bundle 'com.onboard.service.github_3.0.0.SNAPSHOT[189]'
            package        'org.joda.time.format_1.6.0' in bundle 'com.springsource.org.joda.time_1.6.0[89]' used by 'org.springframework.format.datetime.joda_3.1.0.RELEASE' in bundle 'org.springframework.context_3.1.0.RELEASE[111]'
            conflicts with 'org.joda.time.format_2.3.0' in bundle 'joda-time_2.3.0[147]' imported by bundle 'com.onboard.web.api_3.0.0.SNAPSHOT[1441423661083]'
            package        'org.joda.time.format_1.6.0' in bundle 'com.springsource.org.joda.time_1.6.0[89]' used by 'org.springframework.format.datetime.joda_3.1.0.RELEASE' in bundle 'org.springframework.context_3.1.0.RELEASE[111]'
            conflicts with 'org.joda.time.format_2.3.0' in bundle 'joda-time_2.3.0[147]' imported by bundle 'com.onboard.web.api_3.0.0.SNAPSHOT[1441423661083]'

    Uses violation: <Import-Package: org.hibernate.validator.constraints.impl; version="0.0.0"> in bundle <com.onboard.web.api_3.0.0.SNAPSHOT[1441423661083]>
         Resolver reported uses conflict for import constrained to bundle <com.springsource.org.hibernate.validator> constrained bundle version range "[4.2.0.Final,4.2.0.Final]"

at org.eclipse.virgo.kernel.install.pipeline.stage.resolve.internal.QuasiResolveStage.process(QuasiResolveStage.java:46)
at org.eclipse.virgo.kernel.install.pipeline.internal.StandardPipeline.doProcessGraph(StandardPipeline.java:62)
at org.eclipse.virgo.kernel.install.pipeline.internal.CompensatingPipeline.doProcessGraph(CompensatingPipeline.java:73)
at org.eclipse.virgo.kernel.install.pipeline.stage.AbstractPipelineStage.process(AbstractPipelineStage.java:41)
at org.eclipse.virgo.kernel.install.pipeline.internal.StandardPipeline.doProcessGraph(StandardPipeline.java:62)
at org.eclipse.virgo.kernel.install.pipeline.stage.AbstractPipelineStage.process(AbstractPipelineStage.java:41)
at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.driveInstallPipeline(PipelinedApplicationDeployer.java:359)
at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.doInstall(PipelinedApplicationDeployer.java:185)
at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.install(PipelinedApplicationDeployer.java:140)
at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.deploy(PipelinedApplicationDeployer.java:253)
at org.eclipse.virgo.kernel.deployer.management.StandardDeployer.deploy(StandardDeployer.java:52)
at sun.reflect.GeneratedMethodAccessor111.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:75)
at sun.reflect.GeneratedMethodAccessor81.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:279)
at com.sun.jmx.mbeanserver.ConvertingMethod.invokeWithOpenReturn(ConvertingMethod.java:193)
at com.sun.jmx.mbeanserver.ConvertingMethod.invokeWithOpenReturn(ConvertingMethod.java:175)
at com.sun.jmx.mbeanserver.MXBeanIntrospector.invokeM2(MXBeanIntrospector.java:117)
at com.sun.jmx.mbeanserver.MXBeanIntrospector.invokeM2(MXBeanIntrospector.java:54)
at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:237)
at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:138)
at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:252)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1487)
at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:97)
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1328)
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1420)
at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:848)
at sun.reflect.GeneratedMethodAccessor110.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)
at sun.rmi.transport.Transport$1.run(Transport.java:177)
at sun.rmi.transport.Transport$1.run(Transport.java:174)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

我发现我有两个依赖关系:

<dependency>
  <groupId>com.onboard</groupId>
  <artifactId>com.onboard.domain.model</artifactId>
</dependency>
<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>com.springsource.org.hibernate.validator</artifactId>
  <version>4.2.0.Final</version>
</dependency>

模型依赖joda-time:

<dependency>
  <groupId>joda-time</groupId>
  <artifactId>joda-time</artifactId>
  <version>2.3</version>
</dependency>

和hibernate.validator依赖org.joda:

<dependency>
  <groupId>org.joda</groupId>
  <artifactId>com.springsource.org.joda.time</artifactId>
  <version>1.6.0</version>
  <scope>compile</scope>
</dependency>

Joda-time的版本是2.3,org.joda的版本是1.6.0。 Joda-time和org.joda都提供了包org.joda.time...。但maven bundle plugin构建MANIFEST.MF只有joda time包,如下所示:

org.joda.time;version="[2.3,3)",org.joda.time.format;version="[2.3,3)"

因此,当应用程序启动时,它们会发生冲突。

1 个答案:

答案 0 :(得分:0)

为什么你需要这两个捆绑? 我尝试用joda-time安装com.springsource.org.hibernate.validator,它看起来像预期的那样工作。另一方面,如果您认为删除com.springsource.org.joda.time是一个坏主意,您可以删除joda-time并仅使用com.springsource.org.joda.time。

另外,你可以创建一个包含joda-time和com.springsource.org.joda.time的包。 使用BND捆绑插件,您可以制作类似的内容:

=IF(G:G = "Wipeout", "187.50",
IF(G:G = "Glass Beach", "197.50",
IF(G:G = "Lifeguard Stand 2", "187.50",
IF(G:G = "Misty Bike", "187.50",
IF(G:G = "Sunset Surf", "187.50",
IF(G:G = "Grand Waves", "187.50",
IF(G:G = "Flight", "187.50",
IF(G:G = "Foggy Beach", "187.50",
IF(G:G = "The Cold Shore", "187.50",
IF(G:G = "Palm Tree", "187.50",
IF(G:G = "Pelican", "417.50",
IF(G:G = "Lifeguard Stand", "187.50", ""))))))))))))

希望它有所帮助!