Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » XA data source connection in EclipseLink in SpringBoot application.(XA data source connection in EclipseLink in SpringBoot application)
XA data source connection in EclipseLink in SpringBoot application. [message #1854213] Mon, 08 August 2022 05:10 Go to next message
Atul Dhiman is currently offline Atul DhimanFriend
Messages: 2
Registered: August 2022
Junior Member
Hi, I am trying to get XA data source connection in EclipseLink in SpringBoot application.

1. Do EclipseLink provides XA Data source connection by out of box?
2. Or do we need to override get connection method? If so, do you have any references for the same?
Re: XA data source connection in EclipseLink in SpringBoot application. [message #1854235 is a reply to message #1854213] Mon, 08 August 2022 17:20 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 54
Registered: December 2021
Member
Generally, EclipseLink uses connections from spring configuration, and hooks into JTA. What exactly are you looking for or how have you configured things so that you would want EclipseLink to provide XA connections?
Re: XA data source connection in EclipseLink in SpringBoot application. [message #1854282 is a reply to message #1854235] Wed, 10 August 2022 10:48 Go to previous message
Atul Dhiman is currently offline Atul DhimanFriend
Messages: 2
Registered: August 2022
Junior Member
I am looking for eclipseLink to provide XAConnection. XAdataSource supports getXAConnection() but spring supports only getConnection(). So, I am looking how we can override getConnection() method so that I return XAConnection object from this overridden method. As a part of this I created a entityManagerFactory and trying to create entityManager, but it fails with following error.

Internal Exception: java.sql.SQLException: The method is disabled
Error Code: 58

Here is how I am creating EntityManagerFactory

@Bean(name = "entityManagerFactory")
public EntityManagerFactory createEntityManagerFactory() throws SQLException, ClassNotFoundException {
System.out.println("Creating EclipseLink entity manager.");
AbstractJpaVendorAdapter vendorAdapter = new EclipseLinkJpaVendorAdapter();
vendorAdapter.setGenerateDdl(false);
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();

final Map<String, Object> propertyMap = new HashMap<>();
propertyMap.put(PersistenceUnitProperties.WEAVING, "static");
propertyMap.put(PersistenceUnitProperties.TRANSACTION_TYPE, "RESOURCE_LOCAL");
Class cls = Class.forName("oracle.trm.jta.jpa.eclipseLink.EclipseLinkXADataSourceConnectionProvider");
propertyMap.put(CLASSLOADER, cls.getClassLoader());
factory.setJpaPropertyMap(propertyMap);

factory.setPackagesToScan(new String[] { "com.oracle.mtm.sample.entity" });

factory.setPersistenceProviderClass(PersistenceProvider.class);
factory.setPersistenceUnitName("mydeptxads");

factory.setJpaVendorAdapter(vendorAdapter);
factory.setPackagesToScan("org.apache.logging.log4j.catalog");
factory.setDataSource(getDataSource());
factory.afterPropertiesSet();

EntityManagerFactory emf = (EntityManagerFactory) factory.getObject();
System.out.println("entityManagerFactory = " + emf);
TrmConfig.initEntityManagerFactory(emf); //
EntityManager em = emf.createEntityManager(propertyMap);
return emf;

}
Previous Topic:Cascade Issue
Next Topic:Toplink 10 to Eclipselink migration
Goto Forum:
  


Current Time: Thu Apr 25 22:02:00 GMT 2024

Powered by FUDForum. Page generated in 0.04026 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top