title: ClassCastException in between equal classes Wildfly 10
body: <p>I am Creating a RESTful application and I am having trouble making a conversion for a new connection.
  My application server is Wildfly 10.0.</p>
  
  <p><strong>DataSource and Driver in standalone-full.xml:</strong></p>
  
  <pre><code>&lt;datasource jndi-name="java:jboss/datasources/PostgreDS" pool-name="PostgreDS" enabled="true" use-java-context="true"&gt;
      &lt;connection-url&gt;jdbc:postgresql://192.168.0.112:5432/bdns&lt;/connection-url&gt;
      &lt;driver&gt;postgresql&lt;/driver&gt;
      &lt;transaction-isolation&gt;TRANSACTION_READ_COMMITTED&lt;/transaction-isolation&gt;
      &lt;pool&gt;
          &lt;min-pool-size&gt;10&lt;/min-pool-size&gt;
          &lt;max-pool-size&gt;40&lt;/max-pool-size&gt;
          &lt;prefill&gt;true&lt;/prefill&gt;
      &lt;/pool&gt;
      &lt;security&gt;
          &lt;user-name&gt;sa&lt;/user-name&gt;
          &lt;password&gt;000000&lt;/password&gt;
      &lt;/security&gt;
      &lt;statement&gt;
          &lt;prepared-statement-cache-size&gt;32&lt;/prepared-statement-cache-size&gt;
          &lt;share-prepared-statements&gt;true&lt;/share-prepared-statements&gt;
      &lt;/statement&gt;
  &lt;/datasource&gt;
  &lt;drivers&gt;
      &lt;driver name="postgresql" module="org.postgresql"&gt;
          &lt;xa-datasource-class&gt;org.postgresql.xa.PGXADataSource&lt;/xa-datasource-class&gt;
      &lt;/driver&gt;
  &lt;/drivers&gt;
  </code></pre>
  
  <p><strong>Java code ConnectionMng.java:</strong></p>
  
  <pre><code>package dao;
  
  import java.sql.Connection;
  import java.sql.SQLException;
  
  import javax.naming.InitialContext;
  import javax.naming.NamingException;
  import javax.sql.DataSource;
  
  import org.jboss.jca.adapters.jdbc.jdk7.WrappedConnectionJDK7;
  import org.postgresql.jdbc.PgConnection;
  
  public class ConnectionMng {
      private DataSource ds;
  
      private ConnectionMng() throws NamingException {
          this.ds = (DataSource)new InitialContext().lookup("java:jboss/datasources/PostgreDS");
      }
  
      public PgConnection getPgConnection() throws SQLException {
          WrappedConnectionJDK7 wrappedConn = (WrappedConnectionJDK7)ds.getConnection();
          Connection underlyingConn = wrappedConn.getUnderlyingConnection(); 
          return (PgConnection)underlyingConn;
      }
  }
  </code></pre>
  
  <p><strong>Exception occurred:</strong></p>
  
  <pre><code>ClassCastException: org.jboss.jca.adapters.jdbc.jdk7.WrappedConnectionJDK7 cannot be cast to org.jboss.jca.adapters.jdbc.jdk7.WrappedConnectionJDK7
  </code></pre>
  
  <p><strong>pom.xml:</strong></p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;Core&lt;/groupId&gt;
  &lt;artifactId&gt;Core&lt;/artifactId&gt;
  &lt;version&gt;1.0.0-SNAPSHOT&lt;/version&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;
  &lt;name&gt;Core&lt;/name&gt;
  &lt;description&gt;Core&lt;/description&gt;
  
  &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;javac.target&gt;1.8&lt;/javac.target&gt;
      &lt;postgresql.enforce.jdk.version&gt;[1.7,1.8)&lt;/postgresql.enforce.jdk.version&gt;
  &lt;/properties&gt;
  
  &lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;1.3.3.RELEASE&lt;/version&gt;
  &lt;/parent&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.wildfly&lt;/groupId&gt;
          &lt;artifactId&gt;wildfly-connector&lt;/artifactId&gt;
          &lt;version&gt;10.0.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;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax&lt;/groupId&gt;
          &lt;artifactId&gt;javaee-api&lt;/artifactId&gt;
          &lt;version&gt;7.0&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
          &lt;version&gt;2.5&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;exclusions&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
              &lt;/exclusion&gt;
          &lt;/exclusions&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
          &lt;artifactId&gt;commons-dbcp2&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.codehaus.jackson&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-mapper-asl&lt;/artifactId&gt;
          &lt;version&gt;1.9.13&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
          &lt;artifactId&gt;poi-ooxml&lt;/artifactId&gt;
          &lt;version&gt;3.12&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;commons-fileupload&lt;/groupId&gt;
          &lt;artifactId&gt;commons-fileupload&lt;/artifactId&gt;
          &lt;version&gt;1.3.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.thoughtworks.xstream&lt;/groupId&gt;
          &lt;artifactId&gt;xstream&lt;/artifactId&gt;
          &lt;version&gt;1.4.8&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.github.junrar&lt;/groupId&gt;
          &lt;artifactId&gt;junrar&lt;/artifactId&gt;
          &lt;version&gt;0.7&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.zeroturnaround&lt;/groupId&gt;
          &lt;artifactId&gt;zt-zip&lt;/artifactId&gt;
          &lt;version&gt;1.9&lt;/version&gt;
          &lt;type&gt;jar&lt;/type&gt;
          &lt;exclusions&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
                  &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
              &lt;/exclusion&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;log4j&lt;/groupId&gt;
                  &lt;artifactId&gt;log4j&lt;/artifactId&gt;
              &lt;/exclusion&gt;
          &lt;/exclusions&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  
  &lt;build&gt;
      &lt;sourceDirectory&gt;src&lt;/sourceDirectory&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
                  &lt;source&gt;1.8&lt;/source&gt;
                  &lt;target&gt;1.8&lt;/target&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
                  &lt;warSourceDirectory&gt;WebContent&lt;/warSourceDirectory&gt;
                  &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p></p>