[jboss-jira] [JBoss JIRA] (WFLY-10513) Getting JTA Datasource (Wildfly 13)

Scott Marlow (JIRA) issues at jboss.org
Tue Jul 10 12:04:00 EDT 2018


    [ https://issues.jboss.org/browse/WFLY-10513?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13603178#comment-13603178 ] 

Scott Marlow commented on WFLY-10513:
-------------------------------------

[~david.tierens] I'm not sure of why your seeing this problem, sounds like a bug to me.  We also included Hibernate ORM 5.3 in WildFly 13, if you start the app server via "./standalone.sh -Dee8.preview.mode=true" (or "standalone.bat -Dee8.preview.mode=true"), your application should be deployed with the newer ORM version.

Let us know if that helps.  

I do see that the Hibernate ORM project source still includes "javax.persistence.jtaDataSource" ([https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java#L55]). 

> Getting JTA Datasource (Wildfly 13)
> -----------------------------------
>
>                 Key: WFLY-10513
>                 URL: https://issues.jboss.org/browse/WFLY-10513
>             Project: WildFly
>          Issue Type: Bug
>          Components: JPA / Hibernate
>    Affects Versions: 13.0.0.Final
>            Reporter: David Tierens
>            Assignee: Scott Marlow
>            Priority: Minor
>
> In Wildfly 12 it ,was possible to get the DataSource via :
>  
> {code:java}
> @ApplicationScoped
> public class ExamplePersistenceContextConfiguration {
>  
>    @PersistenceContext(unitName = "examplePersistenceUnit")
>    @Produces
>    private EntityManager entityManager;
>  
>    @Produces
>    public DataSource getDataSource() {
>   EntityManagerFactory entityManagerFactory = entityManager.getEntityManagerFactory();
>   Map<String, Object> properties = entityManagerFactory.getProperties();
>    return (DataSource) properties.get("javax.persistence.jtaDataSource");
>   }
>  
>    @Produces
>    public SessionFactory getSessionFactory() {
>   Session session = entityManager.unwrap(Session.class);
>    return session.getSessionFactory();
>   }
> }
> {code}
>  
> Currently it's returning null in Wildfly 13, however :
> {code:java}
>   (DataSource) properties.get("hibernate.connection.datasource");
> {code}
> does work (instead of :
> {code:java}
>  (DataSource) properties.get("javax.persistence.jtaDataSource")
> {code}
>  
> Persistence.XML :
> {code:xml}
> // Some comments here
> public String getFoo()
> {
>     return foo;
> }
> <?xml version="1.0" encoding="UTF-8"?>
> <persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
>    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
>   http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
>    version="2.1">
>    <!-- HBM files in this module will be loaded automatically -->
>    <persistence-unit name="examplePersistenceUnit" transaction-type="JTA">
>    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
>    <jta-data-source>jdbc/ExampleXADataSource</jta-data-source>
>    <properties>
>    <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
>    <property name="hibernate.show_sql" value="true"/>
>    <property name="hibernate.order_inserts" value="true"/>
>    <property name="hibernate.jdbc.wrap_result_sets" value="true"/>
>    <property name="hibernate.integration.envers.enabled" value="false"/>
>    </properties>
>    </persistence-unit>
> </persistence>
> {code}
>  
> Is there any way to get it via the properties.get("javax.persistence.jtaDataSource") and not via Hibernate ?
>  
> Thanks in advance,
> David



--
This message was sent by Atlassian JIRA
(v7.5.0#75005)


More information about the jboss-jira mailing list