Как разрешить конфликт пакетов между joda-time и org.joda
Когда я запускаю свое приложение, 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 построить MANIFEST.MF
только пакет времени joda, как это:
org.joda.time;version="[2.3,3)",org.joda.time.format;version="[2.3,3)"
Поэтому при запуске приложения они конфликтуют.
1 ответ
Зачем вам нужны эти две связки? Я попытался установить com.springsource.org.hibernate.validator с joda-time, и все выглядит так, как ожидалось. С другой стороны, если вы считаете, что удаление com.springsource.org.joda.time - плохая идея, вы можете удалить joda-time и использовать только com.springsource.org.joda.time.
В качестве альтернативы вы можете сделать пакет, включающий joda-time и com.springsource.org.joda.time. Используя плагин BND bundle, вы можете сделать что-то вроде этого:
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.joda</groupId>
<artifactId>com.springsource.org.joda.time</artifactId>
<version>1.6.0</version>
<scope>compile</scope>
</dependency>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${bundle-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<instructions>
<_failok>true</_failok>
...
<Export-Package>org.joda.time*</Export-Package>
<Embed-Dependency>*;scope=compile</Embed-Dependency>
...
</instructions>
</configuration>
</plugin>
Надеюсь, поможет!