swagger-api / swagger-parser

Swagger Spec to Java POJOs
http://swagger.io
Apache License 2.0
786 stars 531 forks source link

java.lang.NoSuchMethodError (SwaggerDeserializer) #356

Closed neeasthana closed 7 years ago

neeasthana commented 7 years ago

Hello I am having trouble running the sample code provided in the readme. I have included all dependencies and imported the proper libraries. Is there a reason I am getting this error for the Pet Store example. Any insight would be appreciated.

The following line produces a java.lang.NoSuchMethodError:

package ibm;

import io.swagger.parser.SwaggerParser;
import io.swagger.models.Swagger;

public class Test {

    public static void main(String[] args) {
        Swagger swagger = new SwaggerParser().read("http://petstore.swagger.io/v2/swagger.json");
        System.out.println(swagger.toString());
    }

}

Stack Trace:

14:17:52.803 [main] INFO io.swagger.parser.Swagger20Parser - reading from http://petstore.swagger.io/v2/swagger.json
Exception in thread "main" java.lang.NoSuchMethodError: io.swagger.models.parameters.AbstractSerializableParameter.setDefault(Ljava/lang/Object;)V
    at io.swagger.parser.util.SwaggerDeserializer.parameter(SwaggerDeserializer.java:480)
    at io.swagger.parser.util.SwaggerDeserializer.parameters(SwaggerDeserializer.java:416)
    at io.swagger.parser.util.SwaggerDeserializer.operation(SwaggerDeserializer.java:335)
    at io.swagger.parser.util.SwaggerDeserializer.path(SwaggerDeserializer.java:220)
    at io.swagger.parser.util.SwaggerDeserializer.paths(SwaggerDeserializer.java:185)
    at io.swagger.parser.util.SwaggerDeserializer.parseRoot(SwaggerDeserializer.java:106)
    at io.swagger.parser.util.SwaggerDeserializer.deserialize(SwaggerDeserializer.java:36)
    at io.swagger.parser.Swagger20Parser.convertToSwagger(Swagger20Parser.java:128)
    at io.swagger.parser.Swagger20Parser.read(Swagger20Parser.java:97)
    at io.swagger.parser.SwaggerParser.read(SwaggerParser.java:64)
    at io.swagger.parser.SwaggerParser.read(SwaggerParser.java:52)
    at ibm.Test.main(Test.java:9)
fehguy commented 7 years ago

Can you please share what dependencies you're using?

neeasthana commented 7 years ago
<dependencies>

        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-parser</artifactId>
            <version>1.0.23</version>
        </dependency>

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.2.2</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.2.2</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.neo4j</groupId>
            <artifactId>neo4j-ogm-core</artifactId>
            <version>${neo4j.ogm.version}</version>
        </dependency>

        <dependency>
            <groupId>org.neo4j</groupId>
            <artifactId>neo4j-ogm-api</artifactId>
            <version>${neo4j.ogm.version}</version>
        </dependency>

        <dependency>
            <groupId>org.neo4j</groupId>
            <artifactId>neo4j-ogm-compiler</artifactId>
            <version>${neo4j.ogm.version}</version>
        </dependency>

        <dependency>
            <groupId>org.neo4j</groupId>
            <artifactId>neo4j-ogm-http-driver</artifactId>
            <version>${neo4j.ogm.version}</version>
        </dependency>

        <dependency>
            <groupId>org.neo4j</groupId>
            <artifactId>neo4j-ogm-bolt-driver</artifactId>
            <version>${neo4j.ogm.version}</version>
        </dependency>

        <dependency>
            <groupId>org.neo4j</groupId>
            <artifactId>neo4j-ogm-embedded-driver</artifactId>
            <version>${neo4j.ogm.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-neo4j</artifactId>
            <version>4.1.3.RELEASE</version>
        </dependency>

        <!-- spring-boot -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot</artifactId>
            <version>1.4.1.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-neo4j</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>

        <dependency>
            <groupId>com.voodoodyne.jackson.jsog</groupId>
            <artifactId>jackson-jsog</artifactId>
            <version>1.1</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-commons</artifactId>
            <version>1.12.0.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>2.3</version>
        </dependency>

        <!-- test scoped beans only -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>
fehguy commented 7 years ago

Please re-pull from master, you'll probably have to exclude swagger-core dependencies from springfox as they're out of date with the parser version you're using.