NoClassDefFoundError javax/ws/rs/core/Application while migrating from jersey 1.18.1 to jersey 1.19

余生长醉 提交于 2021-02-05 08:45:15

问题


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.

Configuration:

<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>

Code:

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;
  }
}

回答1:


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



来源:https://stackoverflow.com/questions/34667021/noclassdeffounderror-javax-ws-rs-core-application-while-migrating-from-jersey-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!