1 Reply Latest reply on Mar 2, 2017 2:09 PM by abi abi

    Migration from Glassfish : JDBC Driver

    abi abi Newbie

      I try to migrate from glassfish and have an issue. I uploaded pgjdbc-ng driver (with admin console - deployment) and created pool. Pool works and I have no issue with it. However, my application needs to receiver async notification from database.

      Here is the code that worked with Glassfish:

       

      @PostConstruct
      private void init() {

         try {

        javax.naming.InitialContext ctx = new InitialContext();
         dataSource = (DataSource) ctx.lookup("java:jboss/datasources/PGSQLDS");
         listener = dataSource.getConnection();

         Statement statement = listener.createStatement();
         statement.execute(String.format("LISTEN %s", CHANNEL));
         statement.close();

         listener.unwrap(PGConnection.class).addNotificationListener(notificationListener);
         logger.info("Listener installed");
         } catch (NamingException|SQLException e) {

         logger.warn(e.getMessage(), e);
         }

      }

       

      The idea was to unwrap implementation class from proxy and use it directly. However, looks like I don't have access to PGConnection class.

       

      Caused by: java.lang.ClassNotFoundException: com.impossibl.postgres.api.jdbc.PGNotificationListener from [Module "deployment.smartsockets.war:main" from Service Module Loader]

          at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)

       

      How can I use driver specific classes ?

        • 1. Re: Migration from Glassfish : JDBC Driver
          abi abi Newbie

          Solved with

          <?xml version="1.0" encoding="UTF-8"?>
          <jboss-deployment-structure>
            <deployment>
            <dependencies>
            <module name="com.impossibl.postgres"/>
            </dependencies>
            </deployment>
          </jboss-deployment-structure>

           

          If it does matter, I added module with

          module add --name=com.impossibl.postgres --resources=/tmp/pgjdbc-ng-0.6-complete.jar --dependencies=javax.xml.bind.api,javax.api,javax.transaction.api,

          /subsystem=datasources/jdbc-driver=pgjdbc-ng:add(driver-name="pgjdbc-ng",driver-module-name="com.impossibl.postgres",driver-class-name=com.impossibl.postgres.jdbc.PGDriver