title: Unable to get managed connection EJB, Hibernate, JBOSS, Postgres
body: <p>What can be a reason for this error?</p>
  
  <p>My datasource included as module and fells ok if I do not try to look up from there.
  This is my error:</p>
  
  <pre><code>    2016-11-04 15:57:55,389 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (ServerService Thread Pool -- 74) javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:jboss/datasources/PostgresDS
  </code></pre>
  
  <p>This is mu standalone.xml:</p>
  
  <pre><code>                    &lt;datasource jta="true" jndi-name="java:jboss/datasources/PostgresDS" pool-name="PostgresDS" enabled="true" use-java-context="true"&gt;
                  &lt;connection-url&gt;jdbc:postgresql://localhost:5433/cats&lt;/connection-url&gt;
                  &lt;connection-property name="cats"&gt;
                      dictionary
                  &lt;/connection-property&gt;
                  &lt;driver&gt;postgres&lt;/driver&gt;
                  &lt;pool&gt;
                      &lt;min-pool-size&gt;1&lt;/min-pool-size&gt;
                      &lt;max-pool-size&gt;20&lt;/max-pool-size&gt;
                  &lt;/pool&gt;
                  &lt;security&gt;
                      &lt;user-name&gt;postgres&lt;/user-name&gt;
                      &lt;password&gt;mei&lt;/password&gt;
                  &lt;/security&gt;
              &lt;/datasource&gt;
              &lt;drivers&gt;
                  &lt;driver name="postgres" module="org.postgres"&gt;
                      &lt;xa-datasource-class&gt;org.postgresql.xa.PGXADataSource&lt;/xa-datasource-class&gt;
                      &lt;datasource-class&gt;org.postgresql.Driver&lt;/datasource-class&gt;
              &lt;/drivers&gt;
  </code></pre>
  
  <p>This is my persistence.xml:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
      &lt;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"&gt;
  &lt;persistence-unit name="primary"&gt;
      &lt;jta-data-source&gt;java:jboss/datasources/PostgresDS&lt;/jta-data-source&gt;
     &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
      &lt;properties&gt;
          &lt;property name="hibernate.archive.autodetection" value="class" /&gt;
          &lt;property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" /&gt;
          &lt;property name="hibernate.connection.driver_class" value="org.postgresql.Driver" /&gt;
          &lt;property name="hibernate.connection.url" value="jdbc:postgresql://localhost:5433/cats" /&gt;
          &lt;property name="hibernate.connection.username" value="postgres" /&gt;
          &lt;property name="hibernate.connection.password" value="postgres" /&gt;
          &lt;!-- &lt;property name="hibernate.show_sql" value="true"/&gt; --&gt;
          &lt;property name="hibernate.flushMode" value="FLUSH_AUTO" /&gt;
          &lt;property name="hibernate.hbm2ddl.auto" value="update" /&gt;
      &lt;/properties&gt;
  &lt;/persistence-unit&gt;
  </code></pre>
  
  <p></p>
  
  <p>And this is my pom.xml:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;  &lt;!-- standalone="no"?&gt; --&gt;
  </code></pre>
  
  <p>http://maven.apache.org/xsd/maven-4.0.0.xsd">
      4.0.0</p>
  
  <pre><code>&lt;groupId&gt;catshelter&lt;/groupId&gt;
  &lt;artifactId&gt;catshelter-java&lt;/artifactId&gt;
  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;
  
  &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;version.wildfly.maven.plugin&gt;1.0.2.Final&lt;/version.wildfly.maven.plugin&gt;
      &lt;version.jboss.spec.javaee.7.0&gt;1.0.3.Final&lt;/version.jboss.spec.javaee.7.0&gt;
      &lt;version.war.plugin&gt;3.0.0&lt;/version.war.plugin&gt;
      &lt;maven.compiler.target&gt;1.8&lt;/maven.compiler.target&gt;
      &lt;maven.compiler.source&gt;1.8&lt;/maven.compiler.source&gt;
  &lt;/properties&gt;
  
  &lt;dependencyManagement&gt;
      &lt;dependencies&gt;
          &lt;!-- JBoss version
               JavaEE 7
               Any d-s from org.jboss.spec--&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.jboss.spec&lt;/groupId&gt;
              &lt;artifactId&gt;jboss-javaee-7.0&lt;/artifactId&gt;
              &lt;version&gt;${version.jboss.spec.javaee.7.0}&lt;/version&gt;
              &lt;type&gt;pom&lt;/type&gt;
              &lt;scope&gt;import&lt;/scope&gt;
          &lt;/dependency&gt;
  
      &lt;/dependencies&gt;
  &lt;/dependencyManagement&gt;
  
  &lt;dependencies&gt;
      &lt;!-- CDI API  Context and Dependency injection--&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.enterprise&lt;/groupId&gt;
          &lt;artifactId&gt;cdi-api&lt;/artifactId&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Common annotation API (JRS-250)--&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.jboss.spec.javax.annotation&lt;/groupId&gt;
          &lt;artifactId&gt;jboss-annotations-api_1.2_spec&lt;/artifactId&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;!-- JSF API Java Server Faces--&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.jboss.spec.javax.faces&lt;/groupId&gt;
          &lt;artifactId&gt;jboss-jsf-api_2.2_spec&lt;/artifactId&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;!-- JTA - transaction api--&gt;
      &lt;!-- JPA  Java Persistence api--&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate.javax.persistence&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-jpa-2.1-api&lt;/artifactId&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;!--JPA --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.jboss.spec.javax.transaction&lt;/groupId&gt;
          &lt;artifactId&gt;jboss-transaction-api_1.2_spec&lt;/artifactId&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;!--EJB API--&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.jboss.spec.javax.ejb&lt;/groupId&gt;
          &lt;artifactId&gt;jboss-ejb-api_3.2_spec&lt;/artifactId&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
          &lt;version&gt;5.2.0.Final&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
          &lt;version&gt;5.1.0.Final&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.postgresql&lt;/groupId&gt;
          &lt;artifactId&gt;postgresql&lt;/artifactId&gt;
          &lt;version&gt;9.4.1211&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  &lt;build&gt;
      &lt;finalName&gt;${project.artifactId}&lt;/finalName&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
              &lt;version&gt;${version.war.plugin}&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.wildfly.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;wildfly-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;${version.wildfly.maven.plugin}&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;hostname&gt;${wildfly-hostname}&lt;/hostname&gt;
                  &lt;port&gt;9991&lt;/port&gt;
                  &lt;username&gt;${wildfly-username}&lt;/username&gt;
                  &lt;password&gt;${wildfly-password}&lt;/password&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p></p>