Maven Tomcat在netbeans中两次部署同一应用程序
我正在使用并且似乎在应用程序中部署了两次,一次是web应用程序的两次启动 我试过Tomcat 6和7,结果都一样 我有一个springmvc、Hibernate和Thymeleaf应用程序。 META-INF下的Context.xml包含以下内容:Maven Tomcat在netbeans中两次部署同一应用程序,maven,tomcat,netbeans,Maven,Tomcat,Netbeans,我正在使用并且似乎在应用程序中部署了两次,一次是web应用程序的两次启动 我试过Tomcat 6和7,结果都一样 我有一个springmvc、Hibernate和Thymeleaf应用程序。 META-INF下的Context.xml包含以下内容: 这是日志 **第一次部署开始** [信息]07:13:09上下文加载器-根WebApplicationContext:初始化已开始 [信息]07:13:09 XmlWebApplicationContext-刷新根WebApplicationCo
这是日志
**第一次部署开始**
[信息]07:13:09上下文加载器-根WebApplicationContext:初始化已开始
[信息]07:13:09 XmlWebApplicationContext-刷新根WebApplicationContext:启动日期[美国东部时间2013年5月23日星期四07:13:09];上下文层次结构的根
2013-05-23 07:13:10 JRebel:在“/Users/pack/NetBeansProjects/mysite/site/src/main/webapp/WEB-INF/applicationContext-data.xml”中监视Springbean定义。
[信息]07:13:10 XmlBeanDefinitionReader-从ServletContext资源[/WEB-INF/applicationContext data.XML]加载XMLBean定义
[信息]07:13:10 ClassPathScanningCandidateComponentProvider-JSR-330“javax.inject.Named”找到并支持用于组件扫描的注释
***(tomcat初始化hibernate和其他spring bean)***
...
2013年5月23日上午7:13:17 org.apache.catalina.startup.catalina start
信息:服务器启动时间为15552毫秒
***雄猫开始***
***Tomcat试图关闭上下文***
[信息]07:13:18 XmlWebApplicationContext-关闭命名空间“spring mvc servlet”的WebApplicationContext:启动日期[美国东部时间2013年5月23日星期四07:13:15];父:根WebApplicationContext
[信息]07:13:18 DefaultListableBeanFactory-销毁org.springframework.beans.factory.support中的单例。DefaultListableBeanFactory@5bbe2de2:定义bean[blHeadProcessor,blHeadProcessorExtensionManager,navigationProcessor,BLPaginationPageLinkProcessor,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.annotationk、 context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,blRegisterCustomerValidator,blCategoryController,com.package.ui.thymeleaf.CategoryHandlerMapping#0,templateResolver,templateEngine,org.thymeleaf.spring3.view.ThymeleafViewResolver#0,org.springframework.context.annotaconfig.ConfigurationClassPostProcessor.importAwareProcessor];父级:org.springframework.beans.factory.support。DefaultListableBeanFactory@521e7f21
[信息]07:13:18 XmlWebApplicationContext-关闭根WebApplicationContext:启动日期[美国东部时间2013年5月23日星期四07:13:09];上下文层次结构的根
[信息]07:13:18 DefaultListableBeanFactory-销毁org.springframework.beans.factory.support中的单例。DefaultListableBeanFactory@521e7f21:定义bean[org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.transaction.0,org.springframework.transaction.config.internalTransactionAdvisor,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.InternalAutowiredNotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.context.support.PropertySourcesPlaceholderConfigurer#0、blCategoryDao、blCustomerDao、blIdGenerationDao、nlpDao、jpaTemplate、webDS、entityManagerFactory、transactionManager、org.springframework.security.filterChains、org.springframework.security.filterChainProxy、org.springframework.security.web.DefaultSecurityFilterChain#0、org.springframework.security.web.DefaultSecurityFilterChainhain#1,org.springframework.security.web.DefaultSecurityFilterChain#2,org.springframework.security.web.DefaultSecurityFilterChain#3,org.springframework.security.web.DefaultSecurityFilterChain#4,org.springframework.security.web.DefaultSecurityFilterChain#5,org.springframework.security.web.PortMapperImpl#0,org.springframework.security.web.PortResolverImpl#0,org.springframework.security.authentication.ProviderManager#0,org.springframework.security.web.context.HttpSessionSecurityContextRepository#0,org.springframework.security.web.savedrequest.HttpSessionRequestCache#0,org.springframework.security.web.access.channel.ChannelDecisionManagerImpl#0,org.springframework.security.access.vote.AffirmatismiveBased#0,org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0,org.springframework.security.web.access.DefaultWebInvocationPrivilegeEvaluator#0,org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0,org.springframework.security.userDetailsServiceFactory,org.springframework.security.web.DefaultSecurityFilterChain#6,org.springframework.security.authentication.DaoAuthenticationProvider#0,org.springframework.security.authenticationManager,BlerDetailsService,blCatalogService,blCustomerService、entityService、fbPageService、blIdGenerationService、blLoginService、nlpService、priceIncreaseValidator、SearchFaceService、blEntityConfiguration、blPasswordEncoder、solrIndexService、solrEmbedded、textEncryptor、org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor];工厂层次结构的根
[信息]07:13:18 LocalContainerEntityManagerFactoryBean-正在关闭持久化单元“blPU”的JPA EntityManagerFactory
[信息]07:13:18 SessionFactoryImpl-结束
2013年5月23日上午7:13:18 org.apache.catalina.loader.WebappClassLoader ClearReference
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="false">
public void contextDestroyed(ServletContextEvent sce) {
...
String delme = sce.getServletContext().getInitParameter("eraseOnExit");
if (delme != null && delme.length() > 0) {
File del = new File(delme);
if (del.exists()) {
System.out.println("Deleting file " + delme);
del.delete();
}
}
<context-param>
<description>Workaround for Tomcat starting webapp twice</description>
<param-name>eraseOnExit</param-name>
<param-value>/Users/xxx/apache-tomcat-7.0.42/conf/Catalina/localhost/myappname.xml</param-value>
</context-param>
/**
* tomcat workaround bug, in development mode, if tomcat is stopped and application is not un-deployed,
* the old application will start up again on startup, and then the new code will be deployed, leading
* to a the app starting two times and introducing subtle bugs, when this app is stopped and in dev mode
* remove the deployment descriptor from catalina base
*/
private static void preventTomcatNetbeansRedeployBug(final ServletContextEvent sce) {
final String contextPath = sce.getServletContext().getContextPath();
final String catalinaBase = System.getProperty("catalina.base");
if (StringUtil.checkValidity(contextPath, catalinaBase)
&& FrameworkContext.getInstance().isDevEnvironment()) {
final File catalinaBaseContext = new File(catalinaBase, "conf/Catalina/localhost");
if (catalinaBaseContext.exists() && catalinaBaseContext.canRead()) {
final File[] contexts = catalinaBaseContext.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.equals(contextPath.substring(1) + ".xml");
}
});
if (contexts != null && contexts.length > 0) {
LOG.info("Deleting core context[" + contexts[0].getAbsolutePath() + "] since we are in dev");
contexts[0].delete();
}
}
}
}