wkennedy / swagger4spring-web

Swagger support for Spring MVC
89 stars 46 forks source link

Issue Starting Application with swagger4spring-web dependency #25

Closed yogi38inxoriant closed 10 years ago

yogi38inxoriant commented 10 years ago

Hi,

Facing issue while starting my application in tomcat after including the dependency.

com.knappsack swagger4spring-web 0.2.1-SNAPSHOT

This is the latest source code which I have downloaded.

Error is as follows :

SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener java.lang.AbstractMethodError: ch.qos.logback.classic.Logger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V at org.apache.commons.logging.impl.SLF4JLocationAwareLog.info(SLF4JLocationAwareLog.java:159) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:272) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)

Could someone please help me out with this issue .

thx, Yogesh

wkennedy commented 10 years ago

Hi there, what version of Tomcat are you running? Also, can you check to see if you have any dependency conflicts?

cabbonizio commented 10 years ago

Hi I would like to comment on this thread as I'm running on Tomcat version 7.0.42 and I get an even worse error that's not very helpful, but perhaps someone could advise.

Dec 02, 2013 1:54:33 PM org.apache.coyote.AbstractProtocolHandler init INFO: Initializing ProtocolHandler ["http-bio-8080"] Dec 02, 2013 1:54:33 PM org.apache.coyote.AbstractProtocolHandler init INFO: Initializing ProtocolHandler ["ajp-bio-8009"] Dec 02, 2013 1:54:33 PM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 959 ms Dec 02, 2013 1:54:33 PM org.apache.catalina.core.StandardService startInternal INFO: Starting service Catalina Dec 02, 2013 1:54:33 PM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet Engine: Apache Tomcat/7.0.12 Dec 02, 2013 1:54:33 PM org.apache.tomcat.util.digester.Digester endElement WARNING: No rules found matching 'Context/Context'. Exception in thread "main"

I know "Exception in thread "main" is nothing to work with :(

I've been trying to get this to work with the following dependency in my pom.xml file:

com.knappsack swagger4spring-web 0.3.0

I'm going to throw in my other dependencies to see if someone can maybe quickly identify where the conflict is based on experience:

org.mybatis mybatis-spring 1.2.0
    <dependency>
        <groupId>org.mybatis</groupId>
        <artifactId>mybatis</artifactId>
        <version>3.2.2</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.0.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>3.2.2.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>3.2.2.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context-support</artifactId>
        <version>3.2.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>3.2.2.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>3.2.3.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>3.2.3.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-oxm</artifactId>
        <version>3.2.3.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>3.2.3.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.7.5</version>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>apache-log4j-extras</artifactId>
        <version>1.1</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>1.7.4</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.jaxrs</groupId>
        <artifactId>jackson-jaxrs-xml-provider</artifactId>
        <version>2.2.2</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.jaxrs</groupId>
        <artifactId>jackson-jaxrs-json-provider</artifactId>
        <version>2.2.2</version>
    </dependency>
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.2.6</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>2.2.5-2</version>
    </dependency>
    <dependency>
        <groupId>javax.transaction</groupId>
        <artifactId>jta</artifactId>
        <version>1.1</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>3.2.2.RELEASE</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>commons-dbcp</groupId>
        <artifactId>commons-dbcp</artifactId>
        <version>1.4</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-all</artifactId>
        <version>1.9.5</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-mock</artifactId>
        <version>2.0.8</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>sqljdbc4</artifactId>
        <version>4.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache</artifactId>
        <version>2.7.2</version>
    </dependency>
    <dependency>
        <groupId>com.googlecode.ehcache-spring-annotations</groupId>
        <artifactId>ehcache-spring-annotations</artifactId>
        <version>1.2.0-M1</version>
    </dependency>
    <dependency>
        <groupId>com.qvc.services</groupId>
        <artifactId>error</artifactId>
        <version>0.0.4-RELEASE</version>
    </dependency>

Any help is greatly appreciated. I was able to run the sample application and it produces some beautiful documentation so I'm very impressed and would really like to use it for my app.

Thanks in advance and let me know if anything else is needed.

Chris

wkennedy commented 10 years ago

If you can, can you give me your pom.xml file? Or just copy and paste everything inside the dependencies tag?

cabbonizio commented 10 years ago

Sure thing! First time using GitHub so hopefully replying to this email directly works. The last dependency in the list is a company specific variant, simply just an error object, doesn’t do much. Hope this helps and thanks so much for the quick response.

   <dependencies>
          <dependency>
                 <groupId>org.mybatis</groupId>
                 <artifactId>mybatis-spring</artifactId>
                 <version>1.2.0</version>
          </dependency>
          <dependency>
                 <groupId>org.mybatis</groupId>
                 <artifactId>mybatis</artifactId>
                 <version>3.2.2</version>
          </dependency>
          <dependency>
                 <groupId>javax.servlet</groupId>
                 <artifactId>javax.servlet-api</artifactId>
                 <version>3.0.1</version>
                 <scope>provided</scope>
          </dependency>
          <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-web</artifactId>
                 <version>3.2.2.RELEASE</version>
          </dependency>
          <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-context</artifactId>
                 <version>3.2.2.RELEASE</version>
          </dependency>
          <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-context-support</artifactId>
                 <version>3.2.4.RELEASE</version>
          </dependency>
          <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-jdbc</artifactId>
                 <version>3.2.2.RELEASE</version>
          </dependency>
          <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-webmvc</artifactId>
                 <version>3.2.3.RELEASE</version>
          </dependency>
          <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-tx</artifactId>
                 <version>3.2.3.RELEASE</version>
          </dependency>
          <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-oxm</artifactId>
                 <version>3.2.3.RELEASE</version>
          </dependency>
          <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-orm</artifactId>
                 <version>3.2.3.RELEASE</version>
          </dependency>
          <dependency>
                 <groupId>org.slf4j</groupId>
                 <artifactId>slf4j-log4j12</artifactId>
                 <version>1.7.5</version>
          </dependency>
          <dependency>
                 <groupId>log4j</groupId>
                 <artifactId>apache-log4j-extras</artifactId>
                 <version>1.1</version>
          </dependency>
          <dependency>
                 <groupId>org.codehaus.jackson</groupId>
                 <artifactId>jackson-mapper-asl</artifactId>
                 <version>1.7.4</version>
          </dependency>
          <dependency>
                 <groupId>com.fasterxml.jackson.jaxrs</groupId>
                 <artifactId>jackson-jaxrs-xml-provider</artifactId>
                 <version>2.2.2</version>
          </dependency>
          <dependency>
                 <groupId>com.fasterxml.jackson.jaxrs</groupId>
                 <artifactId>jackson-jaxrs-json-provider</artifactId>
                 <version>2.2.2</version>
          </dependency>
          <dependency>
                 <groupId>javax.xml.bind</groupId>
                 <artifactId>jaxb-api</artifactId>
                 <version>2.2.6</version>
          </dependency>
          <dependency>
                 <groupId>com.sun.xml.bind</groupId>
                 <artifactId>jaxb-impl</artifactId>
                 <version>2.2.5-2</version>
          </dependency>
          <dependency>
                 <groupId>javax.transaction</groupId>
                 <artifactId>jta</artifactId>
                 <version>1.1</version>
          </dependency>
          <dependency>
                 <groupId>junit</groupId>
                 <artifactId>junit</artifactId>
                 <version>4.11</version>
                 <scope>test</scope>
          </dependency>
          <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-test</artifactId>
                 <version>3.2.2.RELEASE</version>
                 <scope>test</scope>
          </dependency>
          <dependency>
                 <groupId>javax.servlet</groupId>
                 <artifactId>servlet-api</artifactId>
                 <version>2.5</version>
                 <scope>test</scope>
          </dependency>
          <dependency>
                 <groupId>commons-dbcp</groupId>
                 <artifactId>commons-dbcp</artifactId>
                 <version>1.4</version>
                 <scope>test</scope>
          </dependency>
          <dependency>
                 <groupId>org.mockito</groupId>
                 <artifactId>mockito-all</artifactId>
                 <version>1.9.5</version>
                 <scope>test</scope>
          </dependency>
          <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-mock</artifactId>
                 <version>2.0.8</version>
                 <scope>test</scope>
          </dependency>
          <dependency>
                 <groupId>com.microsoft.sqlserver</groupId>
                 <artifactId>sqljdbc4</artifactId>
                 <version>4.0</version>
                 <scope>test</scope>
          </dependency>
          <dependency>
                 <groupId>net.sf.ehcache</groupId>
                 <artifactId>ehcache</artifactId>
                 <version>2.7.2</version>
          </dependency>
          <dependency>
                 <groupId>com.googlecode.ehcache-spring-annotations</groupId>
                 <artifactId>ehcache-spring-annotations</artifactId>
                 <version>1.2.0-M1</version>
          </dependency>
          <dependency>
                 <groupId>com.qvc.services</groupId>
                 <artifactId>error</artifactId>
                 <version>0.0.4-RELEASE</version>
          </dependency>
   </dependencies>

From: Will Kennedy [mailto:notifications@github.com] Sent: Monday, December 02, 2013 2:09 PM To: wkennedy/swagger4spring-web Cc: Christopher Abbonizio Subject: Re: [swagger4spring-web] Issue Starting Application with swagger4spring-web dependency (#25)

If you can, can you give me your pom.xml file? Or just copy and paste everything inside the dependencies tag?

— Reply to this email directly or view it on GitHubhttps://github.com/wkennedy/swagger4spring-web/issues/25#issuecomment-29647347.


This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. If you are not the intended recipient of this e-mail (even if the e-mail address above is yours), (i) you may not use, copy or retransmit it, (ii) please delete this message and (iii) please notify the sender immediately. Any disclosure, copying, or distribution of this message or the taking of any action based on it, is strictly prohibited.

wkennedy commented 10 years ago

I ran into some issues using your dependencies. It looks like there are some version conflicts with some of the transitive dependencies. I was able to get it working by including the guava dependency (although, I'm not sure why...)

    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>15.0</version>
    </dependency>

and commenting out the following dependencies:

    <!--<dependency>-->
        <!--<groupId>org.codehaus.jackson</groupId>-->
        <!--<artifactId>jackson-mapper-asl</artifactId>-->
        <!--<version>1.7.4</version>-->
    <!--</dependency>-->
    <!--<dependency>-->
        <!--<groupId>com.fasterxml.jackson.jaxrs</groupId>-->
        <!--<artifactId>jackson-jaxrs-xml-provider</artifactId>-->
        <!--<version>2.2.2</version>-->
    <!--</dependency>-->
    <!--<dependency>-->
        <!--<groupId>com.fasterxml.jackson.jaxrs</groupId>-->
        <!--<artifactId>jackson-jaxrs-json-provider</artifactId>-->
        <!--<version>2.2.2</version>-->
    <!--</dependency>-->

Maybe give that a try and see if it gets you any further along.

cabbonizio commented 10 years ago

Hi, I tried this and I still got stuck at “Exception in thread "main"”

I tried changing the versions of Spring and other things to see if I can trip it, but to no avail. I’m having some other people try to incorporate your maven dependency in their apps as well. If you have any other thoughts, I would be willing to try. I’m stuck at this point ☹

From: Will Kennedy [mailto:notifications@github.com] Sent: Monday, December 02, 2013 2:48 PM To: wkennedy/swagger4spring-web Cc: Christopher Abbonizio Subject: Re: [swagger4spring-web] Issue Starting Application with swagger4spring-web dependency (#25)

I ran into some issues using your dependencies. It looks like there are some version conflicts with some of the transitive dependencies. I was able to get it working by including the guava dependency (although, I'm not sure why...)

<dependency>

    <groupId>com.google.guava</groupId>

    <artifactId>guava</artifactId>

    <version>15.0</version>

</dependency>

and commenting out the following dependencies:

<!--<dependency>-->

    <!--<groupId>org.codehaus.jackson</groupId>-->

    <!--<artifactId>jackson-mapper-asl</artifactId>-->

    <!--<version>1.7.4</version>-->

<!--</dependency>-->

<!--<dependency>-->

    <!--<groupId>com.fasterxml.jackson.jaxrs</groupId>-->

    <!--<artifactId>jackson-jaxrs-xml-provider</artifactId>-->

    <!--<version>2.2.2</version>-->

<!--</dependency>-->

<!--<dependency>-->

    <!--<groupId>com.fasterxml.jackson.jaxrs</groupId>-->

    <!--<artifactId>jackson-jaxrs-json-provider</artifactId>-->

    <!--<version>2.2.2</version>-->

<!--</dependency>-->

Maybe give that a try and see if it gets you any further along.

— Reply to this email directly or view it on GitHubhttps://github.com/wkennedy/swagger4spring-web/issues/25#issuecomment-29650829.


This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. If you are not the intended recipient of this e-mail (even if the e-mail address above is yours), (i) you may not use, copy or retransmit it, (ii) please delete this message and (iii) please notify the sender immediately. Any disclosure, copying, or distribution of this message or the taking of any action based on it, is strictly prohibited.

wkennedy commented 10 years ago

I'll take a look at it some more, but it's hard to track it down when I can't reproduce it. Let me know if you find anything.

cabbonizio commented 10 years ago

Any special Spring config or versions I need to be on to make this work?

From: Will Kennedy [mailto:notifications@github.com] Sent: Monday, December 02, 2013 4:08 PM To: wkennedy/swagger4spring-web Cc: Christopher Abbonizio Subject: Re: [swagger4spring-web] Issue Starting Application with swagger4spring-web dependency (#25)

I'll take a look at it some more, but it's hard to track it down when I can't reproduce it. Let me know if you find anything.

— Reply to this email directly or view it on GitHubhttps://github.com/wkennedy/swagger4spring-web/issues/25#issuecomment-29657586.


This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. If you are not the intended recipient of this e-mail (even if the e-mail address above is yours), (i) you may not use, copy or retransmit it, (ii) please delete this message and (iii) please notify the sender immediately. Any disclosure, copying, or distribution of this message or the taking of any action based on it, is strictly prohibited.

cabbonizio commented 10 years ago

Hey, guess what? I am much further as a colleague of mine found another article with Swagger that required a minor change to one's XML file:

From: <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">

To: <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">

Changing this allowed my app to successfully start and now I'm onto configuring the documentation controller. Any thoughts on why this change was required? Could you get it run using 3.0 on your side?

wkennedy commented 10 years ago

Thank you for posting your findings. It looks like Tomcat might be getting confused because you are mixing servlet specs. In your Maven dependencies it looks like you want to use the Servlet API version 3

          <dependency>
                 <groupId>javax.servlet</groupId>
                 <artifactId>javax.servlet-api</artifactId>
                 <version>3.0.1</version>
                 <scope>provided</scope>
          </dependency>

but in your web.xml file you are mixing 2.5 and 3. My guess is if you want to use 3.0, try this in your web.xml:

         <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-             app_3_0.xsd">

I tested upgrading my example to Servlet 3 and everything looked okay. Let me know if that helps.

cabbonizio commented 10 years ago

I did try this and still got the out of memory error….only 2.5 seems to work at this point. In any event at least my app starts up well now and runs. Next hurdle is I’m trying to call */documentation/resourceList and its bring back an empty JSON result.

I decided to go the path of creating a DocumentationController (in the same package as my other controllers) and set the base controller package and model package accordingly.

When I call */documentation/resourceList, based on the logging at debug level I can see it churn through all of my models but it doesn’t seem to have any interaction with my controllers. Any thoughts on this? I feel like I’m very close.

In the sample project the ExampleDocumentationController was in a different package than the controllers it was documenting, but not sure if this matters.

Thanks

From: Will Kennedy [mailto:notifications@github.com] Sent: Tuesday, December 03, 2013 12:40 PM To: wkennedy/swagger4spring-web Cc: Christopher Abbonizio Subject: Re: [swagger4spring-web] Issue Starting Application with swagger4spring-web dependency (#25)

Thank you for posting your findings. It looks like Tomcat might be getting confused because you are mixing servlet specs. In your Maven dependencies it looks like you want to use the Servlet API version 3

      <dependency>

             <groupId>javax.servlet</groupId>

             <artifactId>javax.servlet-api</artifactId>

             <version>3.0.1</version>

             <scope>provided</scope>

      </dependency>

but in your web.xml file you are mixing 2.5 and 3. My guess is if you want to use 3.0, try this in your web.xml:

     <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"

        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-             app_3_0.xsd<http://java.sun.com/xml/ns/javaee%20http:/java.sun.com/xml/ns/javaee/web-%20%20%20%20%20%20%20%20%20%20%20%20%20app_3_0.xsd>">

I tested upgrading my example to Servlet 3 and everything looked okay. Let me know if that helps.

— Reply to this email directly or view it on GitHubhttps://github.com/wkennedy/swagger4spring-web/issues/25#issuecomment-29732472.


This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. If you are not the intended recipient of this e-mail (even if the e-mail address above is yours), (i) you may not use, copy or retransmit it, (ii) please delete this message and (iii) please notify the sender immediately. Any disclosure, copying, or distribution of this message or the taking of any action based on it, is strictly prohibited.

aug70 commented 10 years ago

@cabbonizio Added below to quickly see how this project works

        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                    <path>/knappsack</path>
            </configuration>
        </plugin>

and server is ready at http://localhost:8080/knappsack/ in no time