[ 
https://issues.apache.org/jira/browse/TOMEE-4332?focusedWorklogId=920613&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-920613
 ]

ASF GitHub Bot logged work on TOMEE-4332:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 23/May/24 09:57
            Start Date: 23/May/24 09:57
    Worklog Time Spent: 10m 
      Work Description: jgallimore commented on PR #1130:
URL: https://github.com/apache/tomee/pull/1130#issuecomment-2126704507

   Closing and replacing with #1165




Issue Time Tracking
-------------------

    Worklog Id:     (was: 920613)
    Time Spent: 1.5h  (was: 1h 20m)

> Using JAX-RS endpoints with a Spring Application fails
> ------------------------------------------------------
>
>                 Key: TOMEE-4332
>                 URL: https://issues.apache.org/jira/browse/TOMEE-4332
>             Project: TomEE
>          Issue Type: Bug
>    Affects Versions: 9.1.3
>            Reporter: Jonathan Gallimore
>            Assignee: Jonathan Gallimore
>            Priority: Major
>             Fix For: 10.0.0-M2, 9.1.4
>
>         Attachments: demo.tar.gz
>
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> Consider a Spring application that uses Spring Web MVC, and also makes use of 
> JAX-RS endpoints using CXF in TomEE (reproducer attached).
> In TomEE 9.1.3, invoking the JAX-RS endpoint will fail with the following 
> exception:
>  
> java.lang.NoClassDefFoundError: 
> org/springframework/web/filter/ServerHttpObservationFilter
>     at 
> org.apache.cxf.jaxrs.springmvc.SpringWebUtils.setHttpRequestURI(SpringWebUtils.java:51)
>  ~[cxf-rt-frontend-jaxrs-4.0.4.jar:4.0.4]
>     at 
> org.apache.cxf.jaxrs.utils.HttpUtils.setHttpRequestURI(HttpUtils.java:380) 
> ~[cxf-rt-frontend-jaxrs-4.0.4.jar:4.0.4]
>     at 
> org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.setExchangeProperties(JAXRSInInterceptor.java:246)
>  ~[cxf-rt-frontend-jaxrs-4.0.4.jar:4.0.4]
>     at 
> org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:183)
>  ~[cxf-rt-frontend-jaxrs-4.0.4.jar:4.0.4]
>     at 
> org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:78)
>  ~[cxf-rt-frontend-jaxrs-4.0.4.jar:4.0.4]
>     at 
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
>  ~[cxf-core-4.0.4.jar:4.0.4]
>     at 
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
>  ~[cxf-core-4.0.4.jar:4.0.4]
>     at 
> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:265)
>  ~[cxf-rt-transports-http-4.0.4.jar:4.0.4]
>     at 
> org.apache.openejb.server.cxf.rs.CxfRsHttpListener.doInvoke(CxfRsHttpListener.java:266)
>  ~[openejb-cxf-rs-9.1.3.jar:9.1.3]
>     at 
> org.apache.tomee.webservices.CXFJAXRSFilter.doFilter(CXFJAXRSFilter.java:99) 
> ~[tomee-jaxrs-9.1.3.jar:9.1.3]
>     at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
>  ~[catalina.jar:10.0.27]
>     at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
>  ~[catalina.jar:10.0.27]
>     at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) 
> ~[tomcat-websocket.jar:10.0.27]
>     at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
>  ~[catalina.jar:10.0.27]
>     at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
>  ~[catalina.jar:10.0.27]
>     at org.apache.openejb.server.httpd.EEFilter.doFilter(EEFilter.java:67) 
> ~[openejb-http-9.1.3.jar:9.1.3]
>     at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
>  ~[catalina.jar:10.0.27]
>     at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
>  ~[catalina.jar:10.0.27]
>     at 
> org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
>  ~[spring-web-6.0.19.jar:6.0.19]
>     at 
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
>  ~[spring-web-6.0.19.jar:6.0.19]
>     at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
>  ~[catalina.jar:10.0.27]
>     at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
>  ~[catalina.jar:10.0.27]
>     at 
> org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
>  ~[spring-web-6.0.19.jar:6.0.19]
>     at 
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
>  ~[spring-web-6.0.19.jar:6.0.19]
>     at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
>  ~[catalina.jar:10.0.27]
>     at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
>  ~[catalina.jar:10.0.27]
>     at 
> org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:124)
>  ~[spring-boot-3.1.11.jar:3.1.11]
>     at 
> org.springframework.boot.web.servlet.support.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:99)
>  ~[spring-boot-3.1.11.jar:3.1.11]
>     at 
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
>  ~[spring-web-6.0.19.jar:6.0.19]
>     at 
> org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:117)
>  ~[spring-boot-3.1.11.jar:3.1.11]
>     at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
>  ~[catalina.jar:10.0.27]
>     at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
>  ~[catalina.jar:10.0.27]
>     at 
> org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
>  ~[spring-web-6.0.19.jar:6.0.19]
>     at 
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
>  ~[spring-web-6.0.19.jar:6.0.19]
>     at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
>  ~[catalina.jar:10.0.27]
>     at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
>  ~[catalina.jar:10.0.27]
>     at 
> io.smallrye.metrics.jaxrs.JaxRsMetricsServletFilter.doFilter(JaxRsMetricsServletFilter.java:53)
>  ~[smallrye-metrics-4.0.0.jar:na]
>     at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
>  ~[catalina.jar:10.0.27]
>     at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
>  ~[catalina.jar:10.0.27]
>     at 
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
>  ~[catalina.jar:10.0.27]
>     at 
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
>  ~[catalina.jar:10.0.27]
>     at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:45) 
> ~[tomee-catalina-9.1.3.jar:9.1.3]
>     at 
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
>  ~[catalina.jar:10.0.27]
>     at 
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:119) 
> ~[catalina.jar:10.0.27]
>     at 
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) 
> ~[catalina.jar:10.0.27]
>     at 
> org.apache.tomee.catalina.OpenEJBSecurityListener$RequestCapturer.invoke(OpenEJBSecurityListener.java:97)
>  ~[tomee-catalina-9.1.3.jar:9.1.3]
>     at 
> org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
>  ~[catalina.jar:10.0.27]
>     at 
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
>  ~[catalina.jar:10.0.27]
>     at 
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:356) 
> ~[catalina.jar:10.0.27]
>     at 
> org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399) 
> ~[tomcat-coyote.jar:10.0.27]
>     at 
> org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
>  ~[tomcat-coyote.jar:10.0.27]
>     at 
> org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:870)
>  ~[tomcat-coyote.jar:10.0.27]
>     at 
> org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1762)
>  ~[tomcat-coyote.jar:10.0.27]
>     at 
> org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
>  ~[tomcat-coyote.jar:10.0.27]
>     at 
> org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
>  ~[tomcat-util.jar:10.0.27]
>     at 
> org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
>  ~[tomcat-util.jar:10.0.27]
>     at 
> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
>  ~[tomcat-util.jar:10.0.27]
>     at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]
> Caused by: java.lang.ClassNotFoundException: 
> org.springframework.web.filter.ServerHttpObservationFilter
>     at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445) 
> ~[na:na]
>     at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:592) 
> ~[na:na]
>     at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525) 
> ~[na:na]
>     ... 58 common frames omitted
>  
> This is caused by a change in CXF - 
> https://issues.apache.org/jira/browse/CXF-8963, and the specific commit: 
> [https://github.com/apache/cxf/pull/1671/commits/6b9d2bc476f8f64af4f30aea078d3ea7570a419a].
>  
> In essence, CXF is looking for 
> org.springframework.web.filter.ServerHttpObservationFilter in the 
> ThreadContextClassLoader (i.e. the application class loader), but actually 
> invoking the Spring code using the ClassLoader than loaded 
> org.apache.cxf.jaxrs.springmvc.SpringWebUtils (which would be the parent 
> classloader of the application - i.e. the one that just includes everything 
> in the TomEE lib directory).
>  
> I have a patch to mitigate this in TomEE, but I'll additionally flag this up 
> with CXF as well, in case it is possible to provide a fix there.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to