我们的应用程序以前在Tomee 1.5.2中运行,并且运行正常。 它混合了一些遗留的struts代码(以.do结尾的URL引用),一些新的JSF代码和一些jax-rs Restful服务。
我得到的是没有为struts网址找到404。
我更新到Tomee 1.7.2 Plus,因此拥有CXF版本2.6.16 jaxrs库。现在,当我尝试访问struts URL时,CXF代码拦截该URL并且无法将其与任何内容匹配,因此会引发异常。
有没有办法指定CXF拦截的路径? (我们不使用spring,所以所有提到spring的cxf文档都没用)
struts的版本是1.2.9。 web.xml在下面。
这是我的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<filter-mapping>
<filter-name>EncodingRequestFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<session-config>
<session-timeout>60</session-timeout>
</session-config>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>rmt_theme</param-value>
</context-param>
.....
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
... a lot of servlet mappings
<mime-mapping>
...a whole lot of mime mappings deleted here for readability.
...
...
<welcome-file-list>
<welcome-file>index.jsf</welcome-file>
</welcome-file-list>
</web-app>
这是激活了FINE级别的日志。
Sep 09, 2015 2:59:43 PM org.apache.cxf.transport.http.AbstractHTTPDestination invoke
FINE: Create a new message for processing
Sep 09, 2015 2:59:43 PM org.apache.cxf.transport.http.Headers copyFromRequest
FINE: Request Headers: {Accept=[text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8], accept-encoding=[gzip, deflate, sdch], accept-language=[en,es;q=0.8,en-GB;q=0.6,en-US;q=0.4,es-419;q=0.2], cache-control=[no-cache], connection=[keep-alive], Content-Type=[null], cookie=[treeOpenStatex-userStockSites=; JSESSIONID=9303FA8BA796D5C8E224C9AC546675BA; jpreLoader=loaded; primefaces.download=true; oam.Flash.RENDERMAP.TOKEN=-6lb69gdo9], host=[localhost:8080], pragma=[no-cache], referer=[http://localhost:8080/chemalert/], upgrade-insecure-requests=[1], user-agent=[Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36]}
Sep 09, 2015 2:59:43 PM org.apache.cxf.phase.PhaseInterceptorChain add
FINE: Adding interceptor org.apache.cxf.transport.https.CertConstraintsInterceptor@34848be9 to phase pre-stream
Sep 09, 2015 2:59:43 PM org.apache.cxf.phase.PhaseInterceptorChain outputChainToLog
FINE: Chain org.apache.cxf.phase.PhaseInterceptorChain@7351c0b4 was created. Current flow:
receive [PolicyInInterceptor, SaajInFaultInterceptor]
pre-stream [CertConstraintsInterceptor]
unmarshal [JAXRSInInterceptor]
pre-logical [OneWayProcessorInterceptor]
invoke [ServiceInvokerInterceptor]
post-invoke [SaajInInterceptor, OutgoingChainInterceptor]
Sep 09, 2015 2:59:43 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept
FINE: Invoking handleMessage on interceptor org.apache.cxf.ws.policy.PolicyInInterceptor@35ca0cf
Sep 09, 2015 2:59:43 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept
FINE: Invoking handleMessage on interceptor org.apache.openejb.server.cxf.client.SaajInFaultInterceptor@121fe3c8
Sep 09, 2015 2:59:43 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept
FINE: Invoking handleMessage on interceptor org.apache.cxf.transport.https.CertConstraintsInterceptor@34848be9
Sep 09, 2015 2:59:43 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept
FINE: Invoking handleMessage on interceptor org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor@3239ff45
Sep 09, 2015 2:59:43 PM org.apache.cxf.jaxrs.utils.JAXRSUtils selectResourceClass
FINE: Trying to select a resource class, request path : /admin/adminHome.do
Sep 09, 2015 2:59:43 PM org.apache.cxf.jaxrs.utils.JAXRSUtils selectResourceClass
FINE: No resource class match for org.saiku.web.rest.resources.AdminResource, request path : /admin/adminHome.do
Sep 09, 2015 2:59:43 PM org.apache.cxf.jaxrs.utils.JAXRSUtils selectResourceClass
FINE: No resource class match for org.saiku.web.rest.resources.QueryResource, request path : /admin/adminHome.do
Sep 09, 2015 2:59:43 PM org.apache.cxf.jaxrs.utils.JAXRSUtils selectResourceClass
FINE: No resource class match for org.saiku.web.rest.resources.BasicTagRepositoryResource, request path : /admin/adminHome.do
Sep 09, 2015 2:59:43 PM org.apache.cxf.jaxrs.utils.JAXRSUtils selectResourceClass
FINE: No resource class match for org.saiku.web.rest.resources.InfoResource, request path : /admin/adminHome.do
Sep 09, 2015 2:59:43 PM org.apache.cxf.jaxrs.utils.JAXRSUtils selectResourceClass
FINE: No resource class match for org.saiku.web.rest.resources.FilterRepositoryResource, request path : /admin/adminHome.do
Sep 09, 2015 2:59:43 PM org.apache.cxf.jaxrs.utils.JAXRSUtils selectResourceClass
FINE: No resource class match for org.saiku.web.rest.resources.SessionResource, request path : /admin/adminHome.do
Sep 09, 2015 2:59:43 PM org.apache.cxf.jaxrs.utils.JAXRSUtils selectResourceClass
FINE: No resource class match for org.saiku.web.rest.resources.StatisticsResource, request path : /admin/adminHome.do
Sep 09, 2015 2:59:43 PM org.apache.cxf.jaxrs.utils.JAXRSUtils selectResourceClass
FINE: No resource class match for au.com.blah.analytics.web.rest.PredefinedQueryResource, request path : /admin/adminHome.do
Sep 09, 2015 2:59:43 PM org.apache.cxf.jaxrs.utils.JAXRSUtils selectResourceClass
FINE: No resource class match for org.saiku.web.rest.resources.DataSourceResource, request path : /admin/adminHome.do
Sep 09, 2015 2:59:43 PM org.apache.cxf.jaxrs.utils.JAXRSUtils selectResourceClass
FINE: No resource class match for org.saiku.web.rest.resources.ExporterResource, request path : /admin/adminHome.do
Sep 09, 2015 2:59:43 PM org.apache.cxf.jaxrs.utils.JAXRSUtils selectResourceClass
FINE: No resource class match for org.saiku.web.rest.resources.OlapDiscoverResource, request path : /admin/adminHome.do
Sep 09, 2015 2:59:43 PM org.apache.cxf.jaxrs.utils.JAXRSUtils selectResourceClass
FINE: No resource class match for org.saiku.web.rest.resources.BasicRepositoryResource2, request path : /admin/adminHome.do
Sep 09, 2015 2:59:43 PM org.apache.cxf.jaxrs.utils.JAXRSUtils selectResourceClass
FINE: No resource class match for org.saiku.web.rest.resources.Query2Resource, request path : /admin/adminHome.do
Sep 09, 2015 2:59:43 PM org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor processRequest
WARNING: No root resource matching request path /chemalert/admin/adminHome.do has been found, Relative Path: /admin/adminHome.do. Please enable FINE/TRACE log level for more details.
Sep 09, 2015 2:59:43 PM org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
WARNING: javax.ws.rs.WebApplicationException
at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:162)
at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:91)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:240)
at org.apache.openejb.server.cxf.rs.CxfRsHttpListener.doInvoke(CxfRsHttpListener.java:227)
at org.apache.tomee.webservices.CXFJAXRSFilter.doFilter(CXFJAXRSFilter.java:94)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at au.com.blah.web.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:29)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Sep 09, 2015 2:59:43 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept
FINE: Invoking handleMessage on interceptor org.apache.cxf.interceptor.OneWayProcessorInterceptor@5fd546d4
Sep 09, 2015 2:59:43 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept
FINE: Invoking handleMessage on interceptor org.apache.cxf.interceptor.ServiceInvokerInterceptor@74a3639c
Sep 09, 2015 2:59:43 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept
FINE: Invoking handleMessage on interceptor org.apache.openejb.server.cxf.client.SaajInInterceptor@6dbba9fa
Sep 09, 2015 2:59:43 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept
FINE: Invoking handleMessage on interceptor org.apache.cxf.interceptor.OutgoingChainInterceptor@6f91c6a5
Sep 09, 2015 2:59:43 PM org.apache.cxf.interceptor.OutgoingChainInterceptor getChain
FINE: Interceptors contributed by bus: [org.apache.cxf.ws.policy.PolicyOutInterceptor@6cad111a, org.apache.openejb.server.cxf.client.SaajOutInterceptor@9bc91f]
Sep 09, 2015 2:59:43 PM org.apache.cxf.interceptor.OutgoingChainInterceptor getChain
FINE: Interceptors contributed by service: []
Sep 09, 2015 2:59:43 PM org.apache.cxf.interceptor.OutgoingChainInterceptor getChain
FINE: Interceptors contributed by endpoint: [org.apache.cxf.interceptor.MessageSenderInterceptor@73183b04]
Sep 09, 2015 2:59:43 PM org.apache.cxf.interceptor.OutgoingChainInterceptor getChain
FINE: Interceptors contributed by binding: [org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor@343caabe]
Sep 09, 2015 2:59:43 PM org.apache.cxf.phase.PhaseInterceptorChain outputChainToLog
FINE: Chain org.apache.cxf.phase.PhaseInterceptorChain@5173e983 was created. Current flow:
setup [PolicyOutInterceptor, SaajOutInterceptor]
prepare-send [MessageSenderInterceptor]
marshal [JAXRSOutInterceptor]
Sep 09, 2015 2:59:43 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept
FINE: Invoking handleMessage on interceptor org.apache.cxf.ws.policy.PolicyOutInterceptor@6cad111a
Sep 09, 2015 2:59:43 PM org.apache.cxf.ws.policy.PolicyOutInterceptor handle
FINE: No binding operation info.
Sep 09, 2015 2:59:43 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept
FINE: Invoking handleMessage on interceptor org.apache.openejb.server.cxf.client.SaajOutInterceptor@9bc91f
Sep 09, 2015 2:59:43 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept
FINE: Invoking handleMessage on interceptor org.apache.cxf.interceptor.MessageSenderInterceptor@73183b04
Sep 09, 2015 2:59:43 PM org.apache.cxf.phase.PhaseInterceptorChain add
FINE: Adding interceptor org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor@575a516b to phase prepare-send-ending
Sep 09, 2015 2:59:43 PM org.apache.cxf.phase.PhaseInterceptorChain outputChainToLog
FINE: Chain org.apache.cxf.phase.PhaseInterceptorChain@5173e983 was modified. Current flow:
setup [PolicyOutInterceptor, SaajOutInterceptor]
prepare-send [MessageSenderInterceptor]
marshal [JAXRSOutInterceptor]
prepare-send-ending [MessageSenderEndingInterceptor]
Sep 09, 2015 2:59:43 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept
FINE: Invoking handleMessage on interceptor org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor@343caabe
Sep 09, 2015 2:59:43 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept
FINE: Invoking handleMessage on interceptor org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor@575a516b
Sep 09, 2015 2:59:43 PM org.apache.cxf.ws.addressing.ContextUtils retrieveMAPs
FINE: retrieving MAPs from context property javax.xml.ws.addressing.context.inbound
Sep 09, 2015 2:59:43 PM org.apache.cxf.ws.addressing.ContextUtils retrieveMAPs
FINE: WS-Addressing - failed to retrieve Message Addressing Properties from context
答案 0 :(得分:1)
回答我自己的问题。
看起来,tomee 1.5.2和1.7.2之间的CXF之间的区别在于jax-rs部署单元曾经是每个端点,但在更高版本中,部署单元是整个应用程序(请参阅此处了解一点)更多细节https://rmannibucau.wordpress.com/2013/01/09/tomeeopenejb-jaxrs-refactoring/)。
因此,为了解决我的问题,我必须将其余服务映射到某个URL,以避免将整个应用视为休息服务(如果有意义的话)。
为此,我将以下内容添加到web.xml
<servlet>
<servlet-name>javax.ws.rs.core.Application</servlet-name>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>javax.ws.rs.core.Application</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
然后我更改了任何调用休息服务的URL以在开始时包含/ rest /。
(在web.xml中使用条目的替代方法是使用javax.ws.rs.core.Application,如本示例中所示http://tomee.apache.org/examples-trunk/rest-example-with-application/README.html)