Q:

Postgres and JPA in macOS

I had a windows environment with Postgres 9.6 and Wildfly 14. I have created connections via the wildfly as following:
<datasource jndi-name="java:jboss/datasources/mydb" pool-name="mydb" enabled="true">
    <connection-url>jdbc:postgresql://localhost:5432/mydb</connection-url>
    <driver-class>org.postgresql.Driver</driver-class>
    <datasource-class>org.postgresql.ds.PGSimpleDataSource</datasource-class>
    <driver>postgresql-42.1.1.jar</driver>
    <security>
        <user-name>someusername</user-name>
        <password>somepassword</password>
    </security>
    <validation>
        <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker"/>
        <background-validation>true</background-validation>
        <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter"/>
    </validation>
</datasource>

And then my Persistence.xml as following:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
   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">
        <persistence-unit name="SomePU" transaction-type="JTA">
           <jta-data-source>java:jboss/datasources/mydb</jta-data-source>
        </persistence-unit>
</persistence>

My JPA Entity looks like this:
@Entity @Table(name="usr_apps")
public class SomeApp{...}

My EJB Stateless class:
@PersistenceContext(unitName = "SomePU")
private EntityManager em;

public List getSometing(){
   return em.createQuery("select b from SomeApp b").getResultList(); 
}     

The same configs were working on Linux Ubuntu, Linux RHEL, Mac OSX Lion.
but now that I'm trying to run it on macOS mojave, I'm receiving this error when trying to read data through JPA.
[org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-1) ERROR: relation "usr_apps" does not exist
 Position: 150

I'm pretty sure that table exists. I can see the same query running in any other DBMS. I have dumped the database from the my other environment and restored it on the new one.
PS. I also tried PSQL 10. Same result. No data is being read from the database. I can successfully ping the connection from Wildfly management console.
I also made sure that the table is in public schema.
EDIT:
I realized that even though the connection is set to mydb, but JPA is only sending the query to postgres default database!
EDIT 2
Ok this is getting closer to a bug to me. 
<datasource jndi-name="java:jboss/datasources/mydb" pool-name="mydb">
                <connection-url>jdbc:postgresql://localhost:5432/mydb</connection-url>
                <driver-class>org.postgresql.Driver</driver-class>
                <datasource-class>org.postgresql.ds.PGSimpleDataSource</datasource-class>
                <driver>postgresql-42.2.5.jar</driver>
                <security>
                    <user-name>testuser</user-name>
                    <password>testpassword</password>
                </security>
                <validation>
                    <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker"/>
                    <background-validation>true</background-validation>
                    <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter"/>
                </validation>
            </datasource>

I'm receiving this error:
Caused by: org.postgresql.util.PSQLException: FATAL: database "testuser" does not exist

Why JPA is treating my username as a database name?
PS. WILDFLY 14.0.1.Final

A:

OK!! All I had to do is to remove the datasource class from the connection :
<datasource-class>org.postgresql.ds.PGSimpleDataSource</datasource-class>

Finally got it working
Note that wildfly version 14 and onwards adds this line to the xml file automatically when you create the datasource through admin console.

