简体   繁体   English

java.lang.NoClassDefFoundError:使用dropwizard时io / dropwizard / jetty / RequestLogFactory

[英]java.lang.NoClassDefFoundError: io/dropwizard/jetty/RequestLogFactory when using dropwizard

When I changed from Hibernate to JDBI, and tried to launch my application, error below occured 当我从Hibernate更改为JDBI并尝试启动我的应用程序时,发生以下错误

java.lang.NoClassDefFoundError: io/dropwizard/jetty/RequestLogFactory java.lang.NoClassDefFoundError:io / dropwizard / jetty / RequestLogFactory

Stack trace says, that the cause of this problem is in my configuration class, at the class definition. 堆栈跟踪说,此问题的原因是在我的配置类中的类定义中。 But i have no idea what's wrong. 但是我不知道怎么了。 Anyone had this problem? 有人遇到这个问题吗?

MyConfiguration.java MyConfiguration.java

import com.fasterxml.jackson.annotation.JsonProperty;
import io.dropwizard.Configuration;
import io.dropwizard.db.DataSourceFactory;
import org.hibernate.validator.constraints.NotEmpty;

import javax.validation.constraints.NotNull;

public class MyConfiguration extends Configuration {

    @JsonProperty
    @NotNull
    private DataSourceFactory database;

    @JsonProperty
    @NotEmpty
    private String someString;


    public DataSourceFactory getDataSourceFactory() {
        return database;
    }

    public String getSomeString() {
        return someString;
    }
}

EDIT I'm using dropwizard 1.0.0 and RequestLogFactory is neither in the given package nor Intellij couldn't find that class. 编辑我正在使用dropwizard 1.0.0和RequestLogFactory既不在给定的包中,也不是Intellij找不到该类。

You aren't using the RequestLogFactory directly, but it seems one of the classes you're importing is and that jar needs to be present on your classpath for these classes you're importing to work appropriately at runtime. 您没有直接使用RequestLogFactory,但是似乎您要导入的类之一,并且需要在您的类路径中显示jar,以便您导入的这些类在运行时正常工作。 You should track down the jar which you need to include on your classpath that includes the RequestLogFactory class. 您应该跟踪需要在包含RequestLogFactory类的类路径上包含的jar。

My best guess would be you're missing an import statement for the RequestLogFactory class: 我最好的猜测是您缺少RequestLogFactory类的import语句:

import com.fasterxml.jackson.annotation.JsonProperty;
import io.dropwizard.Configuration;
import io.dropwizard.db.DataSourceFactory;
import org.hibernate.validator.constraints.NotEmpty;

import javax.validation.constraints.NotNull;

You probably need to include: 您可能需要包括:

import io.dropwizard.jetty.RequestLogFactory;

or simply (if you have more classes inside of jetty): 或简单地(如果您在码头内有更多班级):

import io.dropwizard.jetty.*;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 dropwizard异常:java.lang.NoClassDefFoundError - dropwizard exception: java.lang.NoClassDefFoundError NoClassDefFoundError:使用DropWizard时的org / eclipse / jetty / io / ByteBufferPool - NoClassDefFoundError: org/eclipse/jetty/io/ByteBufferPool when using DropWizard Dropwizard-线程“ main”中的异常java.lang.NoClassDefFoundError:com / google / common / collect / ImmutableMap $ Builder - Dropwizard - Exception in thread “main” java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableMap$Builder 使用Maven时出现Java.lang.NoClassDefFoundError - Java.lang.NoClassDefFoundError when using Maven 使用控制台时出现java.lang.NoClassDefFoundError - java.lang.NoClassDefFoundError when using console 将jetty 7更新为jetty 8:java.lang.NoClassDefFoundError:javax / servlet / FilterRegistration - Updating jetty 7 to jetty 8 : java.lang.NoClassDefFoundError: javax/servlet/FilterRegistration java.lang.NoClassDefFoundError:io/jsonwebtoken/SignatureAlgorithm - java.lang.NoClassDefFoundError: io/jsonwebtoken/SignatureAlgorithm Java.lang.NoClassDefFoundError:org/eclipse/jetty/util/component/ContainerLifeCycle - Java.lang.NoClassDefFoundError: org/eclipse/jetty/util/component/ContainerLifeCycle 使用EJB客户端jar时的java.lang.NoClassDefFoundError - java.lang.NoClassDefFoundError when using EJB client jar 使用Firebase时Android应用错误java.lang.NoClassDefFoundError - Android app error java.lang.NoClassDefFoundError when using firebase
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM