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