Uploaded image for project: 'Thorntail'
  1. Thorntail
  2. THORN-1784

JPA ignores given JNDI name for datasource in project-defaults.yml and persistence.xml

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 2017.12.1
    • Fix Version/s: 2018.1.0
    • Component/s: core
    • Labels:
      None
    • Story Points:
      5
    • Steps to Reproduce:
      Hide

      Create a swarm project with a datasource in project-defaults.yml and persistence.xml with a jndi name that does not match the pattern: java:jboss/datasources/$sourceName

      Attempt to run and a crash will result.

      Show
      Create a swarm project with a datasource in project-defaults.yml and persistence.xml with a jndi name that does not match the pattern: java:jboss/datasources/$sourceName Attempt to run and a crash will result.

      Description

      I have been using 2017.6.0 because of datasource trouble, but needed to upgrade to 2017.12.1 for JavaEE 8 for new project.

      This issue is connected to, but distinct from: https://issues.jboss.org/browse/SWARM-1486

      I'm using swarm for testing with Arquillian. It's a lot nicer (to me) than requiring an application server and messing with paths when I can just use Swarm for tests since I will be using Wildfly in prod anyway.

      project-defaults.yml looks like this:

      swarm:
        datasources:
          data-sources:
            app:
              jndi-name: java:/app
              driver-name: myh2
              connection-url: jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
              user-name: sa
              password: sa
          jdbc-drivers:
            myh2:
              driver-class-name: org.h2.Driver
              xa-datasource-name: org.h2.jdbcx.JdbcDataSource
              driver-module-name: com.h2database.h2
      

      persistence.xml looks like:

      <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">
      	
      	<persistence-unit name="app">
      		<jta-data-source>java:/app</jta-data-source>
      		<properties>
      			<property name="hibernate.hbm2ddl.auto" value="update" />
      			<property name="hibernate.hbm2ddl.import_files_sql_extractor" value="org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor" />
      		</properties>
      	</persistence-unit>
      </persistence>
      

      I attempt to run with mvn test and the result is a crash that indicates that it expects to find the datasource at java:jboss/datasources/app instead of the defined java:/app. If I modify the definition in project-defaults.yml and persistence.xml to use java:jboss/datasources/app, it works without any problem

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                kg6zvp Sam McCollum
                Reporter:
                kg6zvp Sam McCollum
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: