Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring + JAX.RS - context loaded twice
    text
    copied!<p>I am developing application that serves REST API for clients, to do this I decided to use <code>JAX-RS</code> implementation <code>Jersey</code> and <code>Spring</code> for some dependency injection.</p> <p>Today I noticed in my logs, that my application context seems to be loaded twice, for example:</p> <pre><code>2013-12-21 22:18:55 INFO ContextLoader:272 - Root WebApplicationContext: initialization started 2013-12-21 22:18:55 INFO ContextLoader:272 - Root WebApplicationContext: initialization started </code></pre> <p>I looked through similiar posts, but seeing my <code>web.xml</code> file, I can't seem to find the culprit:</p> <pre><code>&lt;web-app 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" version="3.0"&gt; &lt;display-name&gt;Spring MVC Application&lt;/display-name&gt; &lt;servlet&gt; &lt;servlet-name&gt;RestPowtorkiServlet&lt;/servlet-name&gt; &lt;servlet-class&gt;org.glassfish.jersey.servlet.ServletContainer&lt;/servlet-class&gt; &lt;init-param&gt; &lt;param-name&gt;javax.ws.rs.Application&lt;/param-name&gt; &lt;param-value&gt;org.powtorki.spring.PowtorkiApplication&lt;/param-value&gt; &lt;/init-param&gt; &lt;load-on-startup&gt;1&lt;/load-on-startup&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;RestPowtorkiServlet&lt;/servlet-name&gt; &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;context-param&gt; &lt;param-name&gt;log4jConfigLocation&lt;/param-name&gt; &lt;param-value&gt;classpath:log4j.properties&lt;/param-value&gt; &lt;/context-param&gt; &lt;listener&gt; &lt;listener-class&gt;org.springframework.web.util.Log4jConfigListener&lt;/listener-class&gt; &lt;/listener&gt; &lt;!-- Apply Spring Security Filter to all REST Requests --&gt; &lt;filter&gt; &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt; &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt; &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt; &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt; &lt;/filter-mapping&gt; </code></pre> <p></p> <p>Also I tried running example app from <code>Jersey</code> repository (<a href="https://github.com/jersey/jersey/tree/2.4.1/examples/helloworld-spring-webapp" rel="nofollow">https://github.com/jersey/jersey/tree/2.4.1/examples/helloworld-spring-webapp</a>) and it seems it is suffering from the same issue.</p> <p>Is it a bug in <code>Spring</code> integration with <code>Jersey</code>? If so is there a way to fix it somehow?</p> <p>EDIT: log4j configuration:</p> <pre><code># Root logger option log4j.rootLogger=DEBUG, stdout log4j.category.org.springframework.data.document.mongodb=DEBUG,stdout log4j.logger.org.springframework.web.context.ContextLoader=DEBUG,stdout # Direct log messages to stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target=System.out log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload