1

I have a basic Spring 4 MVC project setup. After starting the server the site is accessible and works until I change something in code and later it doesn't respond to any kind of requests(GET/POST) from the browser when I click links in my site to navigate. When I click login I get the following in my console,

DEBUG DispatcherServlet:861 - DispatcherServlet with name 'dispatcherServlet' processing GET request for [/springapp/login]
[artifact:mvn] 2016-01-12 14:06:25 DEBUG RequestMappingHandlerMapping:318 - Looking up handler method for path /login

The URL for login in my app is http://localhost:8080/springapp/login.

The same "Looking up handler method for path /something" message is shown for any subsequent requests but there is no response from the localhost server. I waited for 15 minutes but no response whatsoever. I use embedded jetty as my server in eclipse. I disabled the firewall and uninstalled the antivirus but that doesn't help.

web.xml

<servlet>
<servlet-name>densoServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/config/springContext.xml</param-value>
  </init-param>
</servlet>

<servlet-mapping>
   <servlet-name>densoServlet</servlet-name>
   <url-pattern>/</url-pattern>
</servlet-mapping>

springContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans profile="dev" xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:context="http://www.springframework.org/schema/context"
  xmlns:mvc="http://www.springframework.org/schema/mvc"
  xmlns:tx="http://www.springframework.org/schema/tx"
  xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">

    <mvc:annotation-driven />

    <context:component-scan base-package="com.springapp">
        <context:include-filter type="regex" expression="(service|controller|dao)\..*"/>
    </context:component-scan>

    <context:property-placeholder location="classpath*:*.properties"/>

    <tx:annotation-driven transaction-manager="transactionManager" />

    <mvc:resources mapping="css/**" location="/WEB-INF/css/" />
    <mvc:resources mapping="js/**" location="/WEB-INF/js/" />

    <bean id="templateResolver" class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
        <property name="prefix" value="/WEB-INF/templates/" />
        <property name="suffix" value=".html" />
        <property name="templateMode" value="HTML5" />
        <property name="cacheable" value="false" />
    </bean>

    <bean id="templateEngine" class="org.thymeleaf.spring4.SpringTemplateEngine">
        <property name="templateResolver" ref="templateResolver" />
        <property name="additionalDialects">
           <set>
              <bean class="org.thymeleaf.extras.springsecurity4.dialect.SpringSecurityDialect"/>
           </set>
    </property>
    </bean>

    <bean class="org.thymeleaf.spring4.view.ThymeleafViewResolver">
        <property name="templateEngine" ref="templateEngine" />
        <property name="characterEncoding" value="UTF-8"/>
        <property name="order" value="1" />
    </bean>

    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
        <property name="prefix" value="/WEB-INF/templates/"/>
        <property name="suffix" value=".jsp"/>
        <property name="viewNames" value="*jsp" />
        <property name="order" value="2"/>
    </bean>

    <bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
        <property name="defaultLocale" value="en"/>
    </bean>

    <mvc:interceptors>
        <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
            <property name="paramName" value="lang"/>
        </bean>
    </mvc:interceptors>

    <bean name="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> 
        <property name="basename" value="classpath:i18n/messages" />
        <property name="useCodeAsDefaultMessage" value="true" />
        <property name="defaultEncoding" value="UTF-8"/>
    </bean>

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
      <property name="driverClassName" value="${db.driverClassName}" />
      <property name="url" value="${db.url}" />
      <property name="username" value="${db.username}" />
      <property name="password" value="${db.password}" />
    </bean>

    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" />
    </bean>

    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
      <property name="dataSource" ref="dataSource" />
      <property name="typeAliasesPackage" value="com.springapp.model"/>
      <property name="mapperLocations" value="classpath*:com/springapp/mappers/*.xml" />
    </bean>

    <bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
      <constructor-arg index="0" ref="sqlSessionFactory" />
    </bean>

    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
      <property name="basePackage" value="com.springapp.mappers" />
    </bean>

</beans>

My embedded maven-jetty configuration,

pom.xml

<plugin>
  <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>${jetty.version}</version>
    <configuration>
        <systemProperties>
            <systemProperty>
                <name>spring.profiles.active</name>
                <value>dev</value>
            </systemProperty>
        </systemProperties>
        <stopKey>siteStop</stopKey>
        <stopPort>9191</stopPort>
        <httpConnector>
          <host>0.0.0.0</host>
          <port>8080</port>
        </httpConnector>
    </configuration>
</plugin>

I have to restart the server every time to test my code which is time-consuming. What could be blocking the response from the server?

EDIT: The server stops responding only when I make changes in the code. After stopping the server it throws the thread couldn't be stopped,

[artifact:mvn] DEBUG DisposableBeanAdapter:327 - Invoking destroy method 'close' on bean with name 'sqlSession'
[artifact:mvn] WARN  DisposableBeanAdapter:361 - Invocation of destroy method 'close' failed on bean with name 'sqlSession'
[artifact:mvn] java.lang.UnsupportedOperationException: Manual close is not allowed over a Spring managed SqlSession
[artifact:mvn]  at org.mybatis.spring.SqlSessionTemplate.close(SqlSessionTemplate.java:333)
[artifact:mvn]  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[artifact:mvn]  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[artifact:mvn]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[artifact:mvn]  at java.lang.reflect.Method.invoke(Method.java:606)
[artifact:mvn]  at org.springframework.beans.factory.support.DisposableBeanAdapter.invokeCustomDestroyMethod(DisposableBeanAdapter.java:354)
[artifact:mvn]  at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:277)
[artifact:mvn]  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578)
[artifact:mvn]  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554)
[artifact:mvn]  at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:972)
[artifact:mvn]  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523)
[artifact:mvn]  at org.springframework.beans.factory.support.AbstractBeanFactory.destroySingletons(AbstractBeanFactory.java)
[artifact:mvn]  at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:979)
[artifact:mvn]  at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1006)
[artifact:mvn]  at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:982)
[artifact:mvn]  at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:934)
[artifact:mvn]  at org.springframework.web.servlet.FrameworkServlet.destroy(FrameworkServlet.java:829)
[artifact:mvn]  at org.eclipse.jetty.servlet.ServletHolder.destroyInstance(ServletHolder.java:449)
[artifact:mvn]  at org.eclipse.jetty.servlet.ServletHolder.doStop(ServletHolder.java:421)
[artifact:mvn]  at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
[artifact:mvn]  at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:143)
[artifact:mvn]  at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:162)
[artifact:mvn]  at org.eclipse.jetty.server.handler.AbstractHandler.doStop(AbstractHandler.java:73)
[artifact:mvn]  at org.eclipse.jetty.servlet.ServletHandler.doStop(ServletHandler.java:230)
[artifact:mvn]  at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
[artifact:mvn]  at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:143)
[artifact:mvn]  at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:162)
[artifact:mvn]  at org.eclipse.jetty.server.handler.AbstractHandler.doStop(AbstractHandler.java:73)
[artifact:mvn]  at org.eclipse.jetty.security.SecurityHandler.doStop(SecurityHandler.java:411)
[artifact:mvn]  at org.eclipse.jetty.security.ConstraintSecurityHandler.doStop(ConstraintSecurityHandler.java:457)
[artifact:mvn]  at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
[artifact:mvn]  at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:143)
[artifact:mvn]  at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:162)
[artifact:mvn]  at org.eclipse.jetty.server.handler.AbstractHandler.doStop(AbstractHandler.java:73)
[artifact:mvn]  at org.eclipse.jetty.server.session.SessionHandler.doStop(SessionHandler.java:127)
[artifact:mvn]  at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
[artifact:mvn]  at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:143)
[artifact:mvn]  at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:162)
[artifact:mvn]  at org.eclipse.jetty.server.handler.AbstractHandler.doStop(AbstractHandler.java:73)
[artifact:mvn]  at org.eclipse.jetty.server.handler.ContextHandler.doStop(ContextHandler.java:834)
[artifact:mvn]  at org.eclipse.jetty.servlet.ServletContextHandler.doStop(ServletContextHandler.java:258)
[artifact:mvn]  at org.eclipse.jetty.webapp.WebAppContext.doStop(WebAppContext.java:523)
[artifact:mvn]  at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStop(JettyWebAppContext.java:388)
[artifact:mvn]  at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
[artifact:mvn]  at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:143)
[artifact:mvn]  at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:162)
[artifact:mvn]  at org.eclipse.jetty.server.handler.AbstractHandler.doStop(AbstractHandler.java:73)
[artifact:mvn]  at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
[artifact:mvn]  at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:143)
[artifact:mvn]  at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:162)
[artifact:mvn]  at org.eclipse.jetty.server.handler.AbstractHandler.doStop(AbstractHandler.java:73)
[artifact:mvn]  at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
[artifact:mvn]  at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:143)
[artifact:mvn]  at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:162)
[artifact:mvn]  at org.eclipse.jetty.server.handler.AbstractHandler.doStop(AbstractHandler.java:73)
[artifact:mvn]  at org.eclipse.jetty.server.Server.doStop(Server.java:468)
[artifact:mvn]  at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
[artifact:mvn]  at org.eclipse.jetty.server.ShutdownMonitor$ShutdownMonitorRunnable.stopLifeCycles(ShutdownMonitor.java:273)
[artifact:mvn]  at org.eclipse.jetty.server.ShutdownMonitor$ShutdownMonitorRunnable.run(ShutdownMonitor.java:172)
[artifact:mvn]  at java.lang.Thread.run(Thread.java:745)
[artifact:mvn] [INFO] Jetty server exiting.
[artifact:mvn] [INFO] ------------------------------------------------------------------------
[artifact:mvn] [INFO] BUILD SUCCESS
[artifact:mvn] [INFO] ------------------------------------------------------------------------
[artifact:mvn] [INFO] Total time: 1:15:15.551s
[artifact:mvn] 2016-01-12 16:13:03.560:WARN:oejut.QueuedThreadPool:ShutdownMonitor: qtp340358109{STOPPING,8<=19<=200,i=0,q=2} Couldn't stop Thread[qtp340358109-58,5,main]
[artifact:mvn] 2016-01-12 16:13:03.560:WARN:oejut.QueuedThreadPool:ShutdownMonitor: qtp340358109{STOPPING,8<=19<=200,i=0,q=2} Couldn't stop Thread[qtp340358109-80,5,main]
[artifact:mvn] [INFO] Final Memory: 33M/342M
[artifact:mvn] [INFO] ------------------------------------------------------------------------
BUILD SUCCESSFUL
Total time: 75 minutes 20 seconds

Update:

I tested the same workspace in other systems it works fine there. So the code isn't the problem here. Its not the eclipse either since I used the STS and didn't get any response. I took a Thread dump on eclipse pid using the JDK's jVisualVM and following is the thread dump trace, http://pastebin.com/9HQFSebM

Lucky
  • 16,787
  • 19
  • 117
  • 151
  • Did you try to check if the requests reach the server? meaning does the lookup find the correct controllers? Maybe some hidden from the logs OOM error? – Nadir Jan 12 '16 at 09:31
  • Yes, I don't have a problem with that. It all works fine after starting the server. – Lucky Jan 12 '16 at 09:38
  • start jconsole and monitor your server health. – Amit Parashar Jan 12 '16 at 09:43
  • when you mean code changes , you mean while the server is running ? have you set up the embedded jetty to hot-deploy the new class files? look here http://stackoverflow.com/questions/2369851/hot-deploy-in-embedded-jetty – AntJavaDev Jan 12 '16 at 11:26
  • @AntJavaDev Yes, the server is started with embedded jetty and I meant the code changes after starting the jetty server and I have JRebel listening for code changes inside the `target\classes` directory. Code changes are not my problem. But the server response is blocked somehow which is what I'm not able to track of. – Lucky Jan 12 '16 at 11:39
  • is there any starved thread pool or connection pool?? is there a cap on how you open connections ? because i dont see a managed datasource – AntJavaDev Jan 12 '16 at 12:09
  • JRebel does much more than reload simple code changes - it also reloads the changes in the frameworks. Assuming you're already using up-to-date version of JRebel, contact support@zeroturnaround.com, some integration might be misbehaving. – Henri Viik Jan 13 '16 at 10:31
  • @AntJavaDev I've added an update to the question. You can see the thread dump of eclipse process. I don't see any blocking threads. Also the same workspace works fine in other systems. Based on this [bug 439123](https://bugs.eclipse.org/bugs/show_bug.cgi?id=439123) even tried switching workspace but with no help. – Lucky Jan 13 '16 at 13:44
  • ok based on @Henri Viik answer , what type of code change you perform ? are you changing the application Context ? or a simple change in a method – AntJavaDev Jan 13 '16 at 13:51
  • @AntJavaDev Its simple modification of anything in `.java` files(Controllers, Service and Dao methods basically). – Lucky Jan 13 '16 at 13:53
  • To debug, you can try adding JVM argument `-Drebel.load_embedded_plugins=false`. This disables all JRebel plugins - if problem disappears after this, definitely contact the JRebel support. – Henri Viik Jan 14 '16 at 10:45

1 Answers1

0

After a very long time I found out what the issue was. Contacting Jrebel support team as they suggested, I was using an old version(JRebel Legacy Agent 6.2.1 (201506091436)) of jrebel.

Upgrading to the latest version(JRebel Legacy Agent 6.2.3) solved my issue. Seems like there was some bug fixes with the newer version that I was not updated with.

Lucky
  • 16,787
  • 19
  • 117
  • 151