我有一个可以在tomcat和jetty服务器中运行的spring Web应用程序,但是当我在jboss服务器(7.1.1版本)中部署它时,出现错误404。
我在web.xml中的配置是
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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_2_5.xsd"
version="2.5" xmlns="http://java.sun.com/xml/ns/javaee">
<display-name>rci_sof</display-name>
<!-- Servlet de démarrage de l'application -->
<servlet>
<servlet-name>AppContextInitializerServlet</servlet-name>
<servlet-class>com.rcibanque.sof.server.servlet.SofContextInitializerServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Services RPC -->
<servlet>
<servlet-name>dataServiceRPC</servlet-name>
<servlet-class>com.rcibanque.sof.server.service.data.SofDataServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dataServiceRPC</servlet-name>
<url-pattern>/rci_sof/dataService.rpc</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>dataServiceRPC</servlet-name>
<url-pattern>/rci_admin/dataService.rpc</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>dataModuleServiceRPC</servlet-name>
<servlet-class>com.rcibanque.sof.server.service.data.SofDataModuleServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dataModuleServiceRPC</servlet-name>
<url-pattern>/rci_sof/dataModuleService.rpc</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>dataModuleServiceRPC</servlet-name>
<url-pattern>/rci_admin/dataModuleService.rpc</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>tariffingServiceRPC</servlet-name>
<servlet-class>com.rcibanque.sof.server.service.tariffing.TariffingServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>tariffingServiceRPC</servlet-name>
<url-pattern>/rci_sof/tariffingService.rpc</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>tariffingServiceRPC</servlet-name>
<url-pattern>/rci_admin/tariffingService.rpc</url-pattern>
</servlet-mapping>
<!-- RPC Chart -->
<servlet>
<servlet-name>chartRPC</servlet-name>
<servlet-class>com.rcibanque.sof.server.chart.ChartGeneratorImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>chartRPC</servlet-name>
<url-pattern>/rci_sof/chart.rpc</url-pattern>
</servlet-mapping>
<!-- RPC Print Report -->
<servlet>
<servlet-name>printReportRPC</servlet-name>
<servlet-class>com.rcibanque.sof.server.print.report.SofPrintReportImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>printReportRPC</servlet-name>
<url-pattern>/rci_sof/printReport.rpc</url-pattern>
</servlet-mapping>
<!-- RPC Mail -->
<servlet>
<servlet-name>messagingServiceRPC</servlet-name>
<servlet-class>com.rcibanque.sof.server.print.messaging.SofMessagingServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>messagingServiceRPC</servlet-name>
<url-pattern>/rci_sof/messagingService.rpc</url-pattern>
</servlet-mapping>
<!-- RPC TOPCAR -->
<servlet>
<servlet-name>topCarServiceRPC</servlet-name>
<servlet-class>com.rcibanque.sof.server.service.topcar.TopCarService</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>topCarServiceRPC</servlet-name>
<url-pattern>/rci_sof/topCarService.rpc</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>topCarServiceRPC</servlet-name>
<url-pattern>/rci_admin/topCarService.rpc</url-pattern>
</servlet-mapping>
<!-- RPC Fiscalité CO2 -->
<servlet>
<servlet-name>fiscaliteCO2</servlet-name>
<servlet-class>com.rcibanque.socle.server.service.data.FiscaliteCO2Service</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>fiscaliteCO2</servlet-name>
<url-pattern>/rci_sof/fiscaliteCO2Service.rpc</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>fiscaliteCO2</servlet-name>
<url-pattern>/rci_admin/fiscaliteCO2Service.rpc</url-pattern>
</servlet-mapping>
<!-- RPC Offre -->
<servlet>
<servlet-name>offreServiceRPC</servlet-name>
<servlet-class>com.rcibanque.sof.server.service.offre.OffreServiceRPCImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>offreServiceRPC</servlet-name>
<url-pattern>/rci_sof/offreService.rpc</url-pattern>
</servlet-mapping>
<!-- Servlets -->
<servlet>
<servlet-name>displayChartServlet</servlet-name>
<servlet-class>org.jfree.chart.servlet.DisplayChart</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>displayChartServlet</servlet-name>
<url-pattern>/rci_sof/displayChart</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>downloadServlet</servlet-name>
<servlet-class>com.rcibanque.socle.server.servlet.DownloadServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>downloadServlet</servlet-name>
<url-pattern>*.pdf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>downloadServlet</servlet-name>
<url-pattern>*.xls</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>downloadServlet</servlet-name>
<url-pattern>*.txt</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>downloadServlet</servlet-name>
<url-pattern>*.csv</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>topcarDownloadServlet</servlet-name>
<servlet-class>com.rcibanque.socle.server.servlet.TopcarDownloadServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>topcarDownloadServlet</servlet-name>
<url-pattern>/rci_sof/download</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>uploadServlet</servlet-name>
<servlet-class>com.rcibanque.socle.server.servlet.UploadServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>uploadServlet</servlet-name>
<url-pattern>/rci_sof/upload</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>uploadServlet</servlet-name>
<url-pattern>/rci_admin/upload</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>uploadTopcarServlet</servlet-name>
<servlet-class>com.rcibanque.socle.server.servlet.UploadTopcarServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>uploadTopcarServlet</servlet-name>
<url-pattern>/rci_sof/uploadTopcar</url-pattern>
</servlet-mapping>
<!-- Filtre de gestion des caches -->
<filter>
<filter-name>gwtCacheControlFilter</filter-name>
<filter-class>com.rcibanque.socle.server.filter.GWTCacheControlFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>gwtCacheControlFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>Index.html</welcome-file>
</welcome-file-list>
<!-- Timeout QC32499 session connexion timeout <session-config> <session-timeout>300</session-timeout>
</session-config> -->
</web-app>
,我们使用AbstractAnnotationConfigDispatcherServletInitializer通过Java配置来配置Spring
public class SoftWebInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
return new Class[] { SoftWebConfig.class };
}
@Override
protected Class<?>[] getServletConfigClasses() {
return null;
}
@Override
protected String[] getServletMappings() {
return new String[] { "/*", "/ws/*" };
}
}
我的SoftWebConfig是
@Configuration
@Import(SoftDBConfig.class)
@EnableScheduling
@EnableWebMvc
@EnableHypermediaSupport(type = { HypermediaType.HAL })
@ComponentScan(basePackages = { "com.rcibanque.socle.server.*", "com.rcibanque.sof.server.*",
"com.rcibanque.socle.server.ws.*" })
public class SoftWebConfig implements SchedulingConfigurer {
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
taskRegistrar.setScheduler(taskExecutor());
}
@Bean(name = "TOPCAR-EXECUTOR", destroyMethod = "shutdown")
public Executor taskExecutor() {
return Executors.newScheduledThreadPool(1);
}
}
此应用程序可以在TOMCAT和JETTY服务器上完美运行,但是当我将其部署在Jboss Server中并通过http://localhost:8080/rci_sof/index.html进入该应用程序时,出现404错误,并且在server.log中我找到了该日志:
11:30:07,927信息 [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (MSC服务线程1-8)映射 “ {[/ inffr / mat / {codeModele} / {codeVersion}],方法= [GET],消耗= [text / plain || application / ],produces = [application / hal + json]}“公开 org.springframework.http.ResponseEntity> com.rcibanque.socle.server.ws.inffr.WsVehiculeInffr.findByCodesMat(java.lang.String,java.lang.String,boolean,boolean) 11:30:07,933信息 [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (MSC服务线程1-8)映射 “ {[/ inffr / mat / {codeModele}],方法= [GET],消耗= [文本/纯文字|| application / ],产生= [application / hal + json]}“公开 org.springframework.http.ResponseEntity> com.rcibanque.socle.server.ws.inffr.WsVehiculeInffr.findByCodesMat(java.lang.String,boolean) 11:30:07,939信息 [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (MSC服务线程1-8)映射 “ {[/ inffr / renault / {codeModeleRenault} / {libelleVersionRenault}],方法= [GET],耗材= [text / plain || application / ],produces = [application / hal + json]}“公开 org.springframework.http.ResponseEntity> com.rcibanque.socle.server.ws.inffr.WsVehiculeInffr.findByCodesRenault(java.lang.String,java.lang.String,boolean,boolean) 11:30:07,945信息 [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (MSC服务线程1-8)映射 “ {[/ inffr / renault / {codeModeleRenault}],方法= [GET],消耗= [文本/纯文本 || application / ],产生= [application / hal + json]}“公开 org.springframework.http.ResponseEntity> com.rcibanque.socle.server.ws.inffr.WsVehiculeInffr.findByCodesRenault(java.lang.String,boolean) 11:30:07,952信息 [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (MSC服务线程1-8)映射 “ {[/ historiquedlo / {siren} / {codeProduit} / {debut}],方法= [GET],消耗= [text / plain || application / ],produces = [application / hal + json]}“公开 org.springframework.http.ResponseEntity> com.rcibanque.socle.server.ws.dlo.WsHistoriqueDlo.findHistoriqueDlo(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String) 11:30:07,958信息 [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (MSC服务线程1-8)映射 “ {[/ historiquedlo / {siren} / {debut}],方法= [GET],消耗= [文本/纯文本 || application / ],产生= [application / hal + json]}“公开 org.springframework.http.ResponseEntity> com.rcibanque.socle.server.ws.dlo.WsHistoriqueDlo.findHistoriqueDlo(java.lang.String,java.lang.String,java.lang.String,java.lang.String) 11:30:08,198信息 [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter] (MSC服务线程1-8)寻找@ControllerAdvice:根目录 WebApplicationContext:启动日期[2018年8月16日星期四11:30:04 CEST]; 上下文层次结构的根11:30:08,248 INFO [org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver] (MSC服务线程1-8)在中检测到@ExceptionHandler方法 wsExceptionHandlerAdvice 11:30:08,327信息 [org.springframework.web.context.ContextLoader](MSC服务线程 1-8)根WebApplicationContext:初始化在3565毫秒内完成 11:30:08,334信息 [org.apache.catalina.core.ContainerBase。[jboss.web]。[默认主机]。[/ rci-sof-web-16.6.01-SNAPSHOT]] (MSC服务线程1-8)初始化Spring FrameworkServlet 'dispatcher'11:30:08,337信息 [org.springframework.web.servlet.DispatcherServlet](MSC服务 线程1-8)FrameworkServlet'dispatcher':初始化已开始 11:30:08,340信息 [org.springframework.web.context.support.AnnotationConfigWebApplicationContext] (MSC服务线程1-8)为刷新WebApplicationContext 命名空间“ dispatcher-servlet”:启动日期[CEST Aug 16 11:30:08 CEST 2018];父级:Root WebApplicationContext 11:30:08,345信息 [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor] (MSC服务线程1-8)JSR-330'javax.inject.Inject'注释 找到并支持自动装配11:30:08,361 INFO [org.springframework.web.servlet.DispatcherServlet](MSC服务 线程1-8)FrameworkServlet'dispatcher':初始化完成 23 ms 11:30:08,364 INFO [stdout](MSC服务线程1-8)为空
11:30:08,365信息 [com.rcibanque.socle.server.servlet.AbstractContextInitializerServlet] (MSC服务线程1-8)部分所有权: null \ rci_sof.properties 11:30:08,382 INFO [org.jboss.web](MSC 服务线程1-8)JBAS018210:注册Web上下文: /rci-sof-web-16.6.01-SNAPSHOT 11:30:08,388 INFO [org.jboss.as](MSC 服务线程1-2)JBAS015951:管理控制台正在监听 http://127.0.0.1:9990 11:30:08,390 INFO [org.jboss.as](MSC服务 线程1-2)JBAS015874:JBoss AS 7.1.1.Final“ Brontes”开始于 66742ms-341个服务中的263个开始(76个服务为被动或 按需)11:30:08,569信息[org.jboss.as.server] (DeploymentScanner-threads-2)JBAS018559:已部署 “ rci-sof-web-16.6.01-SNAPSHOT.war”
11:48:15,691警告[org.springframework.web.servlet.PageNotFound] (http--127.0.0.1-8080-2)找不到具有URI的HTTP请求的映射 [/rci-sof-web-16.6.01-SNAPSHOT/rci_sof/Index.html]在 名称为'dispatcher'的DispatcherServlet 11:48:20,311 WARN [org.springframework.web.servlet.PageNotFound] (http--127.0.0.1-8080-2)找不到具有URI的HTTP请求的映射 [/rci-sof-web-16.6.01-SNAPSHOT/Index.html]在DispatcherServlet中, 名称“ dispatcher” 11:48:25,258警告 [org.springframework.web.servlet.PageNotFound] (http--127.0.0.1-8080-2)找不到具有URI的HTTP请求的映射 [/rci-sof-web-16.6.01-SNAPSHOT/rci_sof/Index.html]在 名称为'dispatcher'的DispatcherServlet 11:48:42,939 WARN [org.springframework.web.servlet.PageNotFound] (http--127.0.0.1-8080-2)找不到具有URI的HTTP请求的映射 [/rci-sof/Index.html]在DispatcherServlet中, 名称为“调度员”
谢谢您的帮助。
答案 0 :(得分:0)
我通过用“ /”替换“ / *”解决了这个问题,现在它可以在Jboss,Jetty和Tomcat中使用。