Skip to main content



      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 01:10 Go to next message
Eclipse UserFriend
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 13:20 Go to previous messageGo to next message
Eclipse UserFriend
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 06:48 Go to previous message
Eclipse UserFriend
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: Sun Jul 13 14:57:23 EDT 2025

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

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

Back to the top