gpt4 book ai didi

Java - java.lang.NoClassDefFoundError : com/google/inject/internal/util/$Preconditions

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:42:06 25 4
gpt4 key购买 nike

我正在为 druid 开发一个扩展将 jclouds 用于 Rackspace 云文件,我遇到了 Google guice 问题,我对 Java 不是很有信心。

我已经看到了 this question , 但似乎 guice 版本之间没有冲突。

这是正在执行的代码:

@Provides
@LazySingleton
public CloudFilesApi getCloudFilesApi(final CloudFilesAccountConfig config) {
log.info("Provider: " + config.getProvider());
log.info("Username: " + config.getUserName());
log.info("Api key: " + config.getApiKey());
ContextBuilder cb = ContextBuilder.newBuilder(config.getProvider());
log.info("Context builder built.");
cb = cb.credentials(config.getUserName(), config.getApiKey());
log.info("Context builder authenticated.");
CloudFilesApi cfa = cb.buildApi(CloudFilesApi.class);
log.info("Cloud Files Api built.");
return cfa;
}

这是日志:

2015-08-26T13:15:53,663 INFO [main] io.druid.guice.JsonConfigurator - Loaded class[class io.druid.storage.cloudfiles.CloudFilesAccountConfig] from props[druid.cloudfiles.] as [io.druid.storage.cloudfiles.CloudFilesAccountConfig@32d70ac]
2015-08-26T13:15:53,664 INFO [main] io.druid.storage.cloudfiles.CloudFilesStorageDruidModule - Provider: rackspace-cloudfiles-us
2015-08-26T13:15:53,664 INFO [main] io.druid.storage.cloudfiles.CloudFilesStorageDruidModule - Username: <value>
2015-08-26T13:15:53,665 INFO [main] io.druid.storage.cloudfiles.CloudFilesStorageDruidModule - Api key: <value>
2015-08-26T13:15:54,425 INFO [main] io.druid.storage.cloudfiles.CloudFilesStorageDruidModule - Context builder built.
2015-08-26T13:15:54,425 INFO [main] io.druid.storage.cloudfiles.CloudFilesStorageDruidModule - Context builder authenticated.
Exception in thread "main" com.google.inject.CreationException: Guice creation errors:

1) Error injecting constructor, java.lang.NoClassDefFoundError: com/google/inject/internal/util/$Preconditions
at io.druid.guice.FireDepartmentsProvider.<init>(FireDepartmentsProvider.java:41)
while locating io.druid.guice.FireDepartmentsProvider
at io.druid.guice.RealtimeModule.configure(RealtimeModule.java:79)
while locating java.util.List<io.druid.segment.realtime.FireDepartment>
for parameter 0 at io.druid.segment.realtime.RealtimeMetricsMonitor.<init>(RealtimeMetricsMonitor.java:42)
while locating io.druid.segment.realtime.RealtimeMetricsMonitor
at io.druid.server.metrics.MetricsModule.getMonitorScheduler(MetricsModule.java:78)
at io.druid.server.metrics.MetricsModule.getMonitorScheduler(MetricsModule.java:78)
while locating com.metamx.metrics.MonitorScheduler
at io.druid.server.metrics.MetricsModule.configure(MetricsModule.java:63)
while locating com.metamx.metrics.MonitorScheduler annotated with @com.google.inject.name.Named(value=ForTheEagerness)

1 error
at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:448)
at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:184)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110)
at com.google.inject.Guice.createInjector(Guice.java:96)
at com.google.inject.Guice.createInjector(Guice.java:73)
at com.google.inject.Guice.createInjector(Guice.java:62)
at io.druid.initialization.Initialization.makeInjectorWithModules(Initialization.java:412)
at io.druid.cli.GuiceRunnable.makeInjector(GuiceRunnable.java:55)
at io.druid.cli.ServerRunnable.run(ServerRunnable.java:37)
at io.druid.cli.Main.main(Main.java:91)
Caused by: java.lang.NoClassDefFoundError: com/google/inject/internal/util/$Preconditions
at org.nnsoft.guice.rocoto.configuration.ConfigurationModule.configure(ConfigurationModule.java:64)
at com.google.inject.AbstractModule.configure(AbstractModule.java:62)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:230)
at com.google.inject.spi.Elements.getElements(Elements.java:103)
at com.google.inject.spi.Elements.getElements(Elements.java:94)
at org.nnsoft.guice.rocoto.Rocoto.expandVariables(Rocoto.java:52)
at org.nnsoft.guice.rocoto.Rocoto.expandVariables(Rocoto.java:47)
at org.jclouds.config.BindPropertiesToExpandedValues.configure(BindPropertiesToExpandedValues.java:45)
at com.google.inject.AbstractModule.configure(AbstractModule.java:62)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:230)
at com.google.inject.spi.Elements.getElements(Elements.java:103)
at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:136)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:104)
at com.google.inject.Guice.createInjector(Guice.java:96)
at com.google.inject.Guice.createInjector(Guice.java:84)
at org.jclouds.ContextBuilder.expandProperties(ContextBuilder.java:382)
at org.jclouds.ContextBuilder.buildInjector(ContextBuilder.java:317)
at org.jclouds.ContextBuilder.buildApi(ContextBuilder.java:644)
at org.jclouds.ContextBuilder.buildApi(ContextBuilder.java:636)
at io.druid.storage.cloudfiles.CloudFilesStorageDruidModule.getCloudFilesApi(CloudFilesStorageDruidModule.java:68)
[...]

我也不明白为什么没有打印字符串 "Cloud Files Api built."

classpathlib 目录:

user@host:/opt/druid# ls lib | grep guice
guice-4.0-beta.jar
guice-assistedinject-3.0.jar
guice-multibindings-4.0-beta.jar
guice-servlet-4.0-beta.jar
jersey-guice-1.17.1.jar

更新 1

可能与this issue有关?我要尝试将 Google guice 降级到 3.0。

更新 2

我将 Google guice 降级到 3.0,现在我有:

user@host:/opt/druid# ls lib | grep guice
guice-3.0.jar
guice-assistedinject-3.0.jar
guice-multibindings-3.0.jar
guice-servlet-3.0.jar
jersey-guice-1.17.1.jar

现在错误改变了:

    2015-08-26T14:22:06,978 INFO [main] io.druid.guice.JsonConfigurator - Loaded class[class io.druid.storage.cloudfiles.CloudFilesAccountConfig] from props[druid.cloudfiles.] as [io.druid.storage.cloudfiles.CloudFilesAccountConfig@273f1cb3]
2015-08-26T14:22:06,979 INFO [main] io.druid.storage.cloudfiles.CloudFilesStorageDruidModule - Provider: rackspace-cloudfiles-us
2015-08-26T14:22:06,980 INFO [main] io.druid.storage.cloudfiles.CloudFilesStorageDruidModule - Username: viralizecloud
2015-08-26T14:22:06,980 INFO [main] io.druid.storage.cloudfiles.CloudFilesStorageDruidModule - Api key: df185fe598ed99ef27a247a21b578c3a
2015-08-26T14:22:07,782 INFO [main] io.druid.storage.cloudfiles.CloudFilesStorageDruidModule - Context builder built.
2015-08-26T14:22:07,783 INFO [main] io.druid.storage.cloudfiles.CloudFilesStorageDruidModule - Context builder authenticated.
Exception in thread "main" com.google.inject.CreationException: Guice creation errors:

1) Error injecting constructor, java.lang.VerifyError: Cannot inherit from final class
at io.druid.guice.FireDepartmentsProvider.<init>(FireDepartmentsProvider.java:41)
while locating io.druid.guice.FireDepartmentsProvider
at io.druid.guice.RealtimeModule.configure(RealtimeModule.java:79)
while locating java.util.List<io.druid.segment.realtime.FireDepartment>
for parameter 0 at io.druid.segment.realtime.RealtimeMetricsMonitor.<init>(RealtimeMetricsMonitor.java:42)
while locating io.druid.segment.realtime.RealtimeMetricsMonitor
at io.druid.server.metrics.MetricsModule.getMonitorScheduler(MetricsModule.java:78)
at io.druid.server.metrics.MetricsModule.getMonitorScheduler(MetricsModule.java:78)
while locating com.metamx.metrics.MonitorScheduler
at io.druid.server.metrics.MetricsModule.configure(MetricsModule.java:63)
while locating com.metamx.metrics.MonitorScheduler annotated with @com.google.inject.name.Named(value=ForTheEagerness)

1 error
at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:435)
at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:183)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:109)
at com.google.inject.Guice.createInjector(Guice.java:95)
at com.google.inject.Guice.createInjector(Guice.java:72)
at com.google.inject.Guice.createInjector(Guice.java:62)
at io.druid.initialization.Initialization.makeInjectorWithModules(Initialization.java:412)
at io.druid.cli.GuiceRunnable.makeInjector(GuiceRunnable.java:55)
at io.druid.cli.ServerRunnable.run(ServerRunnable.java:37)
at io.druid.cli.Main.main(Main.java:91)
Caused by: java.lang.VerifyError: Cannot inherit from final class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2595)
at java.lang.Class.getDeclaredConstructors(Class.java:1914)
at com.google.inject.spi.InjectionPoint.forConstructorOf(InjectionPoint.java:243)
at com.google.inject.internal.ConstructorBindingImpl.create(ConstructorBindingImpl.java:96)
at com.google.inject.internal.InjectorImpl.createUninitializedBinding(InjectorImpl.java:629)
at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:845)
at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:772)
at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:256)
at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:205)
at com.google.inject.internal.InjectorImpl.getInternalFactory(InjectorImpl.java:853)
at com.google.inject.internal.FactoryProxy.notify(FactoryProxy.java:46)
at com.google.inject.internal.ProcessedBindingData.runCreationListeners(ProcessedBindingData.java:50)
at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:133)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:106)
at com.google.inject.Guice.createInjector(Guice.java:95)
at org.jclouds.ContextBuilder.buildInjector(ContextBuilder.java:402)
at org.jclouds.ContextBuilder.buildInjector(ContextBuilder.java:326)
at org.jclouds.ContextBuilder.buildApi(ContextBuilder.java:644)
at org.jclouds.ContextBuilder.buildApi(ContextBuilder.java:636)
at io.druid.storage.cloudfiles.CloudFilesStorageDruidModule.getCloudFilesApi(CloudFilesStorageDruidModule.java:68)
[...]

最佳答案

查看类路径:

guice-4.0-beta.jar
guice-assistedinject-3.0.jar

您使用的是 Guice v4.0b,但使用的是 AssistedInject Guice 扩展的 v3.0。您应该一次将它们从一个版本升级到另一个版本。听起来您将所有内容都放回了 v3.0,这确实有效,但您可以改为升级 AssistedInject 扩展。

关于Java - java.lang.NoClassDefFoundError : com/google/inject/internal/util/$Preconditions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32228350/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com