[ 
https://issues.apache.org/jira/browse/CXF-8666?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17709642#comment-17709642
 ] 

knoobie commented on CXF-8666:
------------------------------

[~reta] Thanks for your comment! Sorry, I probably have to add: I'm using CXF 
4.0 / Spring Boot 3 / Spring Framework 6 and the problem persists. Once you add 
a Jakarta based WebServiceContext within a Webservice Bean the application is 
broken. I was torn between opening a new issue or commenting on this one, which 
basically is the same problem related to the linked change in Spring Framework 
6. Now Spring tries to inject WebServiceContext to a bean and is failing (in 
Spring Framework 5 this Interface was ignored thanks to ìgnoreResourceType`).

You should be able to reproduce it, once you add the following as field:
{code:java}
@jakarta.annotation.Resource
jakarta.xml.ws.WebServiceContext context;
{code}
to 
[https://github.com/apache/cxf/blob/main/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/service/HelloPortImpl.java]

and change the Endpoint definition in 
[https://github.com/apache/cxf/blob/main/distribution/src/main/release/samples/jaxws_spring_boot/src/main/java/sample/ws/WebServiceConfig.java]
 from
{code:java}
@Bean
public Endpoint endpoint() {
    EndpointImpl endpoint = new EndpointImpl(bus, new HelloPortImpl() //…
{code}
to
{code:java}
@Bean
public Hello hello() {
    return new HelloPortImpl();
}

@Bean
public Endpoint endpoint(Hello hello) {
    EndpointImpl endpoint = new EndpointImpl(bus, hello //…

{code}
Now the application fails with:
{code:none}
***************************
APPLICATION FAILED TO START
***************************

Description:

A component required a bean of type 'jakarta.xml.ws.WebServiceContext' that 
could not be found.


Action:

Consider defining a bean of type 'jakarta.xml.ws.WebServiceContext' in your 
configuration.

{code}

> Spring6 for JSR 250 annotations isn't disabled for 
> jakarta.xml.ws.WebServiceContext
> -----------------------------------------------------------------------------------
>
>                 Key: CXF-8666
>                 URL: https://issues.apache.org/jira/browse/CXF-8666
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-WS Runtime
>    Affects Versions: 3.5.0, 3.4.5
>            Reporter: Jim Ma
>            Priority: Major
>
> The test is failed after Spring6 upgrade. 
> {code:java}
> [INFO] Running org.apache.cxf.jaxws.spring.SpringBeansTest
> [ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.716 
> s <<< FAILURE! - in org.apache.cxf.jaxws.spring.SpringBeansTest
> [ERROR] org.apache.cxf.jaxws.spring.SpringBeansTest.testCXF3959SpringInject  
> Time elapsed: 0.661 s  <<< ERROR!
> org.springframework.beans.factory.BeanCreationException: Error creating bean 
> with name 'org.apache.cxf.jaxws.EndpointImpl--1761046809': Cannot create 
> inner bean '(inner bean)#338c99c8' of type 
> [org.apache.cxf.jaxws.spring.PostConstructCalledCount] while setting 
> constructor argument; nested exception is 
> org.springframework.beans.factory.BeanCreationException: Error creating bean 
> with name '(inner bean)#338c99c8': Injection of resource dependencies failed; 
> nested exception is 
> org.springframework.beans.factory.NoSuchBeanDefinitionException: No 
> qualifying bean of type 'jakarta.xml.ws.WebServiceContext' available: 
> expected at least 1 bean which qualifies as autowire candidate. Dependency 
> annotations: {@jakarta.annotation.Resource(shareable=true, lookup="", 
> name="", description="", authenticationType=CONTAINER, 
> type=java.lang.Object.class, mappedName="")}
>     at 
> org.apache.cxf.jaxws.spring.SpringBeansTest.testCXF3959SpringInject(SpringBeansTest.java:482)
> Caused by: org.springframework.beans.factory.BeanCreationException: Error 
> creating bean with name '(inner bean)#338c99c8': Injection of resource 
> dependencies failed; nested exception is 
> org.springframework.beans.factory.NoSuchBeanDefinitionException: No 
> qualifying bean of type 'jakarta.xml.ws.WebServiceContext' available: 
> expected at least 1 bean which qualifies as autowire candidate. Dependency 
> annotations: {@jakarta.annotation.Resource(shareable=true, lookup="", 
> name="", description="", authenticationType=CONTAINER, 
> type=java.lang.Object.class, mappedName="")}
>     at 
> org.apache.cxf.jaxws.spring.SpringBeansTest.testCXF3959SpringInject(SpringBeansTest.java:482)
> Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: 
> No qualifying bean of type 'jakarta.xml.ws.WebServiceContext' available: 
> expected at least 1 bean which qualifies as autowire candidate. Dependency 
> annotations: {@jakarta.annotation.Resource(shareable=true, lookup="", 
> name="", description="", authenticationType=CONTAINER, 
> type=java.lang.Object.class, mappedName="")}
>     at 
> org.apache.cxf.jaxws.spring.SpringBeansTest.testCXF3959SpringInject(SpringBeansTest.java:482){code}
>  
> Spring5 has this setting in 
> {code:java}
> org.springframework.context.annotation.CommonAnnotationBeanPostProcessor{code}
> {code:java}
> this.ignoreResourceType("javax.xml.ws.WebServiceContext");{code}
> but this setting for jakarta.xml.ws.WebServiceContext is removed in Spring6, 
> see
> [https://github.com/spring-projects/spring-framework/issues/27422]
>  
> The source code in Spirng5 and Spring6:
> https://github.com/spring-projects/spring-framework/blob/v5.3.16/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java#L207
> https://github.com/spring-projects/spring-framework/blob/v6.0.0-M2/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java#L179



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

Reply via email to