本文介绍了从球衣1.18.1迁移到球衣1.19时NoClassDefFoundError javax/ws/rs/core/Application的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我升级jersey版本时,尝试启动Web应用程序时出现上述异常.我正在使用球衣库实现JAXBContextResolver其中的implements ContextResolver<JAXBContext>.除此以外,我看到:

When I upgraded the version of jersey I am getting the above exception while try to start my web application.I am using the jersey library for implementing JAXBContextResolver which implements ContextResolver<JAXBContext>.In the exception I see:

Caused by: java.lang.NoClassDefFoundError: javax/ws/rs/core/Application.

配置:

<jersey-server.version>1.19</jersey-server.version>
<jersey-core.version>${jersey-server.version}</jersey-core.version>
<jersey-servlet.version>${jersey-server.version}</jersey-servlet.version>
<jersey-json.version>${jersey-server.version}</jersey-json.version>
<jersey-client.version>${jersey-server.version}</jersey-client.version>

代码:

public class JAXBContextResolver implements ContextResolver<JAXBContext> {
private static final Class<?>[] classes = { Customer.class, Model.class,
        User.class, Workspace.class, AuthResponse.class, Category.class,
        CategoryValue.class };
private JAXBContext context;

public JAXBContextResolver() throws Exception {
    context = new JSONJAXBContext(
            JSONConfiguration.natural().humanReadableFormatting(true)
                    .rootUnwrapping(true).build(), classes);
}

public JAXBContext getContext(Class<?> objectType) {
    return context;
  }
}

推荐答案

需要添加jsr311-api的依赖项,然后它才能起作用.

Needs to add dependency of jsr311-api and then it worked.

这篇关于从球衣1.18.1迁移到球衣1.19时NoClassDefFoundError javax/ws/rs/core/Application的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 20:43