Community
Participate
Working Groups
This wiki enhancement request surrounds usage of the javax.persistence.jtaDataSource as an override for application scoped datasources deployed with the EAR. The original wls server bug# 246126 is for WebLogic 10.3 but the behaviour of this persistence unit property should be documented for all application servers. Issue: The jta-data-source is always overriden by the datasource in javax.persistence.jtaDataSource - A documentation wiki is required on usage of this alternate property. Current behavior is that javax.persistence.jtaDataSource and nonJtaDataSource (if present) take precedence over the normal <jta-data-source> element. Example persistence.xml <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> <persistence-unit name="unified" transaction-type="JTA"> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <jta-data-source>localOracle10RemoteDS</jta-data-source> <properties> ---> <property name="javax.persistence.jtaDataSource" value="java:app/jdbc/appDS"/> --------------code references----------------- This one found by Doug and Shaun during debugging of the workaround for bug# 246126 During a CRUD operation against the entityManager. 1) By design in EntityManagerSetupImpl.getDatasourceFromProperties() we only use the datasource from <jta-data-source> if it is non-null in the supplied PersistenceUnitInfoImpl. The global datasource "oracle10RemoteDS" defined in <jta-data-source> is ignored, the application managed datasource localOracle10RemoteDS defined in javax.persistence.jtaDataSource is used intead ignored ---> weblogic.jdbc.common.internal.RmiDataSource@18a24e9 used ---> datasource "java:app/jdbc/localOracle10RemoteDS" (id=11049) protected javax.sql.DataSource getDatasourceFromProperties(Map m, String property, javax.sql.DataSource defaultDataSource){ Object datasource = getConfigPropertyLogDebug(property, m, session); if ( datasource == null ){ return defaultDataSource; } if ( datasource instanceof String){ // Create a dummy DataSource that will throw an exception on access --> return new DataSourceImpl((String)datasource, null, null, null); Daemon Thread [[ACTIVE] ExecuteThread: '14' for queue: 'weblogic.kernel.Default (self-tuning)'] (Suspended) EntityManagerSetupImpl.getDatasourceFromProperties(Map, String, DataSource) line: 1035 EntityManagerSetupImpl.updateLogins(Map) line: 966 EntityManagerSetupImpl.updateServerSession(Map, ClassLoader) line: 1176 EntityManagerSetupImpl.deploy(ClassLoader, Map) line: 237 EntityManagerFactoryImpl.getServerSession() line: 69 EntityManagerFactoryImpl.createEntityManagerImpl(Map, boolean) line: 118 jtaDataSource RmiDataSource (id=10956) appName null classLoader null driverClass "weblogic.jdbc.jta.DataSource" (id=11038) driverInstance DataSource (id=11039) driverProps ConcurrentProperties (id=11040) driverUrl "jdbc:weblogic:jta:oracle10RemoteDS" (id=11041) isLoggingResource false jdbcCtx WLEventContextImpl (id=11042) jndiNames String[1] (id=11043) jtaRegistrationName "oracle10RemoteDS" (id=11044) moduleName null pa null poolName "oracle10RemoteDS" (id=11044) rmiSettings RmiDriverSettings (id=11045) scope "Global" (id=11046) txDataSource true useDriver true verbose false 2) Later on in updateLogins() we create our own wrapper for the ds name and dataSource org.eclipse.persistence.internal.jpa.jdbc.DataSourceImpl@1ca62e2 When we return to the login() call later in deploy() we resolve the datasource and set it on our wrapper - this is the one we use. Daemon Thread [[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'] (Suspended (breakpoint at line 102 in JNDIConnector)) JNDIConnector.connect(Properties) line: 118 JNDIConnector.connect(Properties, Session) line: 94 DatabaseLogin(DatasourceLogin).connectToDatasource(Accessor, Session) line: 164 ServerSession(DatabaseSessionImpl).loginAndDetectDatasource() line: 570 EntityManagerFactoryProvider.login(ServerSession, Map) line: 209 EntityManagerSetupImpl.deploy(ClassLoader, Map) line: 246 EntityManagerFactoryImpl.getServerSession() line: 69 EntityManagerFactoryImpl.createEntityManagerImpl(Map, boolean) line: 118 dataSource RmiDataSource (id=11046) appName null classLoader null driverClass "weblogic.jdbc.jta.DataSource" (id=10944) driverInstance DataSource (id=11047) driverProps ConcurrentProperties (id=11048) driverUrl "jdbc:weblogic:jta:localOracle10RemoteDS" (id=11049) isLoggingResource false jdbcCtx WLEventContextImpl (id=11050) jndiNames String[1] (id=11051) jtaRegistrationName "_appsdir_weblogicEAR88_ear@localOracle10RemoteDS@localOracle10RemoteDS" (id=11052) moduleName null pa null poolName "localOracle10RemoteDS" (id=11053) rmiSettings null scope "Application" (id=11054) txDataSource true useDriver true verbose false 3) We may need to adjust the comments/javadoc for updateLogins() as they contradict each other in their use of the supplied PersistenceUnitInfo. We should state that if "persistenceInfo is available and valid..." and that "properties will overrided settings in persistenceUnitInfo" /** * Override the default login creation method. * If persistenceInfo is available, use the information from it to setup the login * and possibly to set readConnectionPool. */ protected void updateLogins(Map m){ DatasourceLogin login = session.getLogin(); // Note: This call does not checked the stored persistenceUnitInfo or extended properties because // the map passed into this method should represent the full set of properties we expect to process
See the following for a summary of the javax.persistence.jtaDataSource workaround and how to enabled it in an EAR application. http://wiki.eclipse.org/EclipseLink/Examples/JPA/WLS_AppScoped_DataSource
Underlying JNDI validation error on the server is fixed in post load 12 - we need to verify the fix and/or deprecate the workaround
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink