我有一个与Spring Boot 1.5.16和JBoss 6.4 EAP相关的非常令人担忧的问题。
简介 该应用程序被归档为War,并与另一个Spring Application和一个Angular一起包含在EAR中。
问题 就我在本地测试部署而言,没有任何问题出现。尽管War是在本地环境中正确加载到Jboss中的,但在远程测试服务器中,运行会在此特定阶段运行的Spring Boot Application期间挂起。
10:04:53,056 WARN [org.jboss.as.ee] (MSC service thread 1-2) JBAS011006: Not installing optional component org.springframework.http.server.ServletServerHttpAsyncRequestControl due to an exception (enable DEBUG log level to see the cause)
10:04:53,056 WARN [org.jboss.as.ee] (MSC service thread 1-2) JBAS011006: Not installing optional component org.springframework.web.context.request.async.StandardServletAsyncWebRequest due to an exception (enable DEBUG log level to see the cause)
10:04:53,058 WARN [org.jboss.as.ee] (MSC service thread 1-4) JBAS011006: Not installing optional component org.springframework.http.server.ServletServerHttpAsyncRequestControl due to an exception (enable DEBUG log level to see the cause)
10:04:53,059 WARN [org.jboss.as.ee] (MSC service thread 1-4) JBAS011006: Not installing optional component org.springframework.web.context.request.async.StandardServletAsyncWebRequest due to an exception (enable DEBUG log level to see the cause)
10:04:53,155 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-2) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
10:04:53,157 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-2) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.fabric.jdbc.FabricMySQLDriver (version 5.1)
10:04:53,247 INFO [org.jboss.web] (ServerService Thread Pool -- 65) JBAS018210: Register web context: /ng-app
10:04:53,252 INFO [org.jboss.web] (ServerService Thread Pool -- 52) JBAS018210: Register web context: /spring-boot-app
10:04:53,252 INFO [org.jboss.web] (ServerService Thread Pool -- 51) JBAS018210: Register web context: /spring-app
10:04:53,294 INFO [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/spring-app]] (ServerService Thread Pool -- 51) No Spring WebApplicationInitializer types detected on classpath
10:04:53,306 INFO [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/spring-boot-app]] (ServerService Thread Pool -- 52) 2 Spring WebApplicationInitializers detected on classpath
10:04:53,522 INFO [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/spring-app]] (ServerService Thread Pool -- 51) Initializing Spring root WebApplicationContext
10:04:53,525 INFO [stdout] (ServerService Thread Pool -- 51) INFO org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
尽管该应用程序已正确加载并运行(整个应用程序都可以运行),但是如果重新启动该应用程序,则Spring Boot Application无法成功关闭其会话。结果是在新的加载阶段,JVM将占用的资源增加了一倍,依此类推。
我做什么 我基本上专注于此消息:
2 Spring WebApplicationInitializers detected on classpath
这可能是与多上下文初始化有关的问题吗?我为您提供了相关的课程,希望对您有所帮助。
ServletInitializer .class
@SpringBootApplication(exclude = {EmbeddedServletContainerAutoConfiguration.class})
public class ServletInitializer {
public static void main(String[] args) {
SpringApplication application = new SpringApplication(ApplicationConfig.class);
new SpringApplicationBuilder(application).web(false).run(args); }
}
ApplicationConfig .class
@Configuration
@EnableJpaAuditing
@Order
public class ApplicationConfig extends SpringBootServletInitializer {
// @PostConstruct
// void init() {
// TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
// }
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
application.web(false);
return application.sources(ServletInitializer.class);
}
@Bean
public DispatcherServlet dispatcherServlet() {
return new DispatcherServlet();
}
@Bean
public ServletRegistrationBean dispatcherServletRegistration() {
ServletRegistrationBean registration = new ServletRegistrationBean(
dispatcherServlet(), "/*");
registration
.setName(DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME);
registration.setLoadOnStartup(1);
return registration;
}
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
System.setProperty(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME, "test");
super.onStartup(servletContext);
}
}
一些详细信息 我有一个JNDI数据库连接,至少在本地环境中可以正常工作。 我没有web.xml。 这是 jboss-deployment-structure .xml
中的springboot应用子部署<sub-deployment name="CRVbusinessService.war">
<dependencies>
<module name="javax.xml.rpc.api"/>
<module name="javax.wsdl4j.api"/>
</dependencies>
<exclusions>
<module name="org.apache.xalan"/>
<module name="org.apache.commons.logging"/>
<module name="org.apache.log4j"/>
<module name="org.jboss.logging"/>
<module name="org.jboss.logging.jul-to-slf4j-stub"/>
<module name="org.jboss.logmanager"/>
<module name="org.jboss.logmanager.log4j"/>
<module name="org.slf4j"/>
<module name="org.slf4j.impl"/>
</exclusions>
</sub-deployment>
<sub-deployment name="restService.war">
<local-last value="true" />
<dependencies>
<module name="deployment.jpa2.1"/>
</dependencies>
<exclusions>
<module name="org.jboss.logging"/>
<module name="org.apache.commons.logging"/>
<module name="org.jboss.logmanager"/>
<module name="org.slf4j"/>
<module name="org.apache.log4j"/>
<module name="javax.persistence.api" />
<module name="org.hibernate" />
<module name="javax.validation.api"/>
<module name="javaee.api" />
</exclusions>
</sub-deployment>
<module name="deployment.jpa2.1" >
<module-alias name="jpa2.1"/>
<resources>
<resource-root path="hibernate-jpa-2.1-api-1.0.0.Final.jar" />
</resources>
</module>
在此先感谢您的帮助。