我有一个基本的Spring 4 MVC项目设置。启动服务器之后,该站点可以访问并运行,直到我在代码中更改某些内容,之后当我单击我站点中的链接进行导航时,它不响应来自浏览器的任何类型的请求(GET / POST)。当我点击登录时,我在控制台中获得以下内容,
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
我的应用中登录的网址是http://localhost:8080/springapp/login
。
对于任何后续请求,都会显示相同的“查找路径/something
”消息的处理程序方法,但是localhost服务器没有响应。我等了15分钟,但没有任何回应。我在eclipse中使用嵌入式jetty作为我的服务器。我禁用了防火墙并卸载了防病毒软件,但这没有帮助。
的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>
我的嵌入式maven-jetty配置,
的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>
我每次都要重新启动服务器以测试我的代码,这非常耗时。什么可以阻止来自服务器的响应?
编辑:仅当我在代码中进行更改时,服务器才会停止响应。停止服务器后,它抛出线程无法停止,
[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
更新
我测试了其他系统中的相同工作区,它在那里工作得很好。所以代码不是问题所在。它不是日食,因为我使用STS并没有得到任何回应。我使用JDK的jVisualVM在eclipse pid上进行了一个Thread转储,以下是线程转储跟踪,http://pastebin.com/9HQFSebM
答案 0 :(得分:0)
很长一段时间后,我发现了问题所在。正如他们所建议的那样联系Jrebel支持团队,我使用的是jrebel的旧版本(JRebel Legacy Agent 6.2.1 (201506091436)
)。
升级到最新版本(JRebel Legacy Agent 6.2.3
)解决了我的问题。似乎有一些错误修复了我没有更新的新版本。