2 Replies Latest reply on Feb 20, 2013 8:08 PM by Steven Boscarine

    How do you install an Oracle Datasource in AS7.x/EAP6.0.1 domain mode using CLI?

    Steven Boscarine Apprentice

      Hello All,

      I ask both for myself and hoping this will be helpful to other users.  I have a CLI script for EAP 6.0.1 that works great for standalone mode and am having challenges getting it working in domain mode.

       

      Standalone Script:

      #Register driver as JBoss module (update path to ojdbc6.jar)module add --name=com.oracle.jdbc --resources=ojdbc6.jar --dependencies=javax.api,javax.transaction.api
        
      #Register module as driver
      /subsystem=datasources/jdbc-driver=oracle:add(driver-module-name=com.oracle.jdbc,driver-name=oracle,driver-xa-datasource-class-name=oracle.jdbc.xa.client.OracleXADataSource)
        
      #Create our main DataSource
      /subsystem=datasources/data-source=myds:add( \
          jndi-name=java:/myds, \
          #CHANGE ME!
          connection-url=jdbc:oracle:thin:@localhost:1521:XE,\
          #CHANGE ME! 
          user-name=ChangeMePlease, \
          #CHANGE ME!
          password=ChangeMePlease, \
          use-java-context=false, \
          check-valid-connection-sql="select 1 from dual", \
          min-pool-size=2,\
          max-pool-size=50,\
          driver-name=oracle,\
          flush-strategy=FailingConnectionOnly)
        
      #Enable
      /subsystem=datasources/data-source=myds:enable
      #reload server to apply changes
      /:reload 
      
      

       

      I am starting a default domain:

       

      Here's how far I could get:

      I think I was successful in installing the driver as a global module:

      #Start CLI on server without connecting
      
      [user@vm003 ~]$ jboss-cli.sh
      You are disconnected at the moment. Type 'connect' to connect to the server or '
      [disconnected /] module add --name=com.oracle.jdbc --resources=ojdbc6.jar --dependencies=javax.api,javax.transaction.api
      
      
      #Now verify
      
      [user@vm003 ~]$ ls $JBOSS_HOME/modules/com/oracle/jdbc/main/
      module.xml  ojdbc6.jar
      

       

      I am stuck on the next command, where I am trying to register my module as a driver. 

       

      #Confirm that we have a server named "server-one" on "master"
      [domain@192.168.1.142:9999 /] /host=master/server=server-one/subsystem=datasources:installed-drivers-list
      {
          "outcome" => "success",
          "result" => [{
              "driver-name" => "h2",
              "deployment-name" => undefined,
              "driver-module-name" => "com.h2database.h2",
              "module-slot" => "main",
              "driver-datasource-class-name" => "",
              "driver-xa-datasource-class-name" => "org.h2.jdbcx.JdbcDataSource",
              "driver-class-name" => "org.h2.Driver",
              "driver-major-version" => 1,
              "driver-minor-version" => 3,
              "jdbc-compliant" => true
          }]
      }
      
      #Now try to run our command to register a datasource against server-one on master
      [domain@192.168.1.142:9999 /] /host=master/server=server-one/subsystem=datasources/jdbc-driver=oracle:add(driver-module-name=com.oracle.jdbc,driver-name=oracle,driver-xa-datasource-class-name=oracle.jdbc.xa.client.OracleXADataSource)
      Failed to get the list of the operation properties: "JBAS014753: There is no operation add registered at address [
          ("subsystem" => "datasources"),
          ("jdbc-driver" => "oracle")
      ]"
      

       

      How do you register a driver in domain mode?

      Is there a way to make this commad global across all servers?

        • 1. Re: How do you install an Oracle Datasource in AS7.x/EAP6.0.1 domain mode using CLI?
          Steven Boscarine Apprentice

          If it helps, we figured out you can run the commands at the profile level.  For example:

           

          /profile=default/subsystem=datasources/jdbc-driver=oracle:add(driver-module-name=com.oracle.jdbc,driver-name=oracle,driver-xa-datasource-class-name=oracle.jdbc.xa.client.OracleXADataSource)
          

          However, we cannot figure out how to assign the profile-level datasource to the invidividual servers (server-one, server-two, etc).  Anyone know how to do so?

          • 2. Re: How do you install an Oracle Datasource in AS7.x/EAP6.0.1 domain mode using CLI?
            Steven Boscarine Apprentice

            I figured out one way. 

            1. Assign values from standalone script to a profile
            2. ensure server is in the group

             

            Here's my script:

            Change your profile and host name if different

            #Run this while disconnected and logged into the remote server.
            #Register driver as JBoss module (update path to ojdbc6.jar)
            module add --name=com.oracle.jdbc --resources=ojdbc6.jar --dependencies=javax.api,javax.transaction.api
            
            #Now connect
            connect   
            
            #Install Oracle Driver in default profile
            #Register module as driver
            /profile=default/subsystem=datasources/jdbc-driver=oracle:add(driver-module-name=com.oracle.jdbc,driver-name=oracle,driver-xa-datasource-class-name=oracle.jdbc.xa.client.OracleXADataSource)
            
            #Create our main DataSource
            /profile=default/subsystem=datasources/data-source=myds:add( \
                jndi-name=java:/myds, \
                #CHANGE ME!
                connection-url=jdbc:oracle:thin:@localhost:1521:XE,\
                #CHANGE ME! 
                user-name=ChangeMePlease, \
                #CHANGE ME!
                password=ChangeMePlease, \
                use-java-context=false, \
                check-valid-connection-sql="select 1 from dual", \
                min-pool-size=2,\
                max-pool-size=50,\
                driver-name=oracle,\
                flush-strategy=FailingConnectionOnly)
            
            #Enable
            /profile=default/subsystem=datasources/data-source=myds:enable
            
            #reload server to apply changes
            /host=master:reload
            

             

            To add main-server-group to the default profile, I ran:

            /server-group=main-server-group:write-attribute(name=profile,value=default)