I have one spring bean which contains two methods. One method is asynchronous with @Async annotation and second is not. Both methods are accessing SOAP endpoint client, generated with jaxws-maven-plugin. Method not annotated with @Async works fine. But method annotated with @Async sometimes fails with exception "java.lang.ClassNotFoundException: com.sun.xml.ws.spi.ProviderImpl". But this exception is really sporadic, not thrown always. Example of code:
@Service
public class MyService {
@Transactional
public void createTask(URL url) {
new TaskService(url).getTaskServicePort().createTask();
}
@Async
@Transactional
public void getTask(URL url) {
new TaskService(url).getTaskServicePort().getTask();
}
}
Is it problem of asynchronous method call? Why I sometimes get this ClassNotFoundException: com.sun.xml.ws.spi.ProviderImpl ?
I would expect both methods works without throwing exception.
Update: I forgot to mention.
Java version is 17, Spring Boot version 2.7.4