I'm trying to access classes from a .jar file within my Spring Boot application. Here's how I've declared the bean initialization in RtgsTestConfiguration:
@EnableConfigurationProperties
public class RtgsTestConfiguration {
private static final Logger logger = LoggerFactory.getLogger(RtgsTestConfiguration.class);
@Bean
@Scope("cucumber-glue")
XmlToDocumentConverter xmlToDocumentConverter() {
return new XmlToDocumentConverter();
}
}
In my step definition file (CommonSteps), I've declared dependencies including XmlToDocumentConverter:
public class CommonSteps extends BaseSteps {
public CommonSteps(final RtgsConfigurationProperties configurationProperties,
final RtgsConfigurationService<Context> contextService,
final ContextWorld contextWorld,
final AuthenticationWorld authenticationWorld,
final RtgsConfigurationService<Jwt> jwtService,
final XmlToDocumentConverter xmlToDocumentConverter)
{
super(configurationProperties, contextWorld, xmlToDocumentConverter);
this.contextService = contextService;
this.authenticationWorld = authenticationWorld;
this.jwtService = jwtService;
}
@And("I validate the response, ensuring all essential fields are correctly populated.")
public void iValidateTheResponseEnsuringAllEssentialFieldsAreCorrectlyPopulated() { xmlToDocumentConverter.convertXmlToDocumentPacs004(ResponseValidation.responseFileName);
}
}
I'm encountering an issue with bean creation in my Spring Boot application. I have a XmlToDocumentConverter bean defined in my RtgsTestConfiguration class, and it's failing to instantiate with the following
error:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xmlToDocumentConverter' defined in com.santander.api.framework.rtgs.configuration.RtgsTestConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.isbanuk.iso20022.common.utils.converter.XmlToDocumentConverter]: Factory method 'xmlToDocumentConverter' threw exception; nested exception is java.lang.NoClassDefFoundError: jakarta/xml/bind/JAXBException
It seems to be related to a java.lang.NoClassDefFoundError for jakarta.xml.bind.JAXBException. I've already included the necessary dependencies in my pom.xml file, but the issue persists.
I have added these dependencies
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>3.0.0</version>
</dependency>
I am using Java 17 in my system.