Exception with Api method returning custom model
I'm stuck with simple, small Swagger app. With dependency on swagger-jersey2-jaxrs in version 1.5.0-M2 (also tested 1.5.0-M1, 1.5.1-M1, 1.5.1-M2, 1.5.3-M1) when deploying project to Glassfish 4.1 I'm getting
Severe: Exception while invoking class com.sun.enterprise.web.WebApplication start method
java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.AnnotationIntrospector.findPropertyIndex(Lcom/fasterxml/jackson/databind/introspect/Annotated;)Ljava/lang/Integer;
My classes:
@ApplicationPath("/rest")
public class RestApplication extends Application {
public RestApplication() {
BeanConfig beanConfig = new BeanConfig();
beanConfig.setVersion("1.0.2");
beanConfig.setSchemes(new String[]{"http"});
beanConfig.setHost("localhost:8080");
beanConfig.setBasePath("/SwaggerTest/api");
beanConfig.setResourcePackage("com.example.swaggertest.facade");
beanConfig.setScan(true);
}
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> resources = new HashSet<>();
resources.add(TestFacade.class);
resources.add(com.wordnik.swagger.jaxrs.listing.ApiListingResource.class);
resources.add(com.wordnik.swagger.jaxrs.listing.SwaggerSerializers.class);
return resources;
}
}
@Path("/test")
@Api
public class TestFacade {
@GET
@ApiOperation(value = "lorem ipsum")
public Mock test() {
return new Mock();
}
}
@XmlRootElement
public class Mock {
private String s;
public String getS() {
return s;
}
public void setS(String s) {
this.s = s;
}
}
Everything is good when Mock class is empty, without any properties (s in this case).
Am I missing something?
That's a problem with Glassfish 4.1 as it includes an old version of Jackson that supersedes the one provided with swagger-core.
To solve it, you'll have to:
- Download Glassfish-4.1 b13
- Replace all the Jackson jars under the common lib with version 2.42
Ok, thank you for the response. It's sad that Glassfish does it.
It would be great if that info would appear in wiki.
Issue to close.
Hello guys,
I'm having the same problem and I would like to solve this without change the jars inside the glassfish. Because if I do that in the production environment it's possible to happens anothers issuing with other applications.
There's another way to solve this?
Thank you.
I'm afraid there's no way around it, as far as I know.
And yes, you should always test such changes in some testing environment before changing in production ;)
It's not a good news, but thank you.
Thanks! I had the same problem. Replacing the five jackson jars (annoations, core, databind, jaxrs-base, jaxrs-json-provider) in the /glassfish/modules folder with the version 2.8.5 solved the problem.
@Kiolali could you paste your pom.xml?
I just annotated Path with @ApiModelProperty(hidden = true) it started working i am not sure its wrong or right?