0 Replies Latest reply on Aug 7, 2012 3:02 AM by Roman Goeldi

    How to change the database from h2database to oracle

    Roman Goeldi Newbie

      Hi,

       

      I'm a student and I'm new to Java EE 6 and JBoss AS 7. In my holidays I work for a little company and have some issues with creating a new ear application. Unfortunately they work with another JBoss version in the company, and they aren't much experienced with it, so I have to get on with it for the most part by myself.

       

      Ok, here is what I've got:

      eclipse indigo, jboss tools, jboss as 7.1.0.Final

       

      Here is what I want:

      A Java EE 6 Application with JBoss AS 7 to access a oracle database, but the client side should be rich client (nothing with JSF)

       

      I made my own Project with a new Java EE Project from JBoss Central and now want to change the database from h2database to oracle db

       

      is this actually possible?

       

      Or do I need something entire different?

       

      can I delete the FinalBalanceStructure-web project or do I need that?

       

      I first edited the datasource in myProject-ear/src/main/application/META-INF:

      my datasource:

       

      <?xml version="1.0" encoding="UTF-8"?>
      
      <datasources xmlns="http://www.jboss.org/ironjacamar/schema"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd">
         <datasource jndi-name="java:jboss/datasources/FinalBalanceStructureDS"
            pool-name="FinalBalanceStructure" enabled="true"
            use-java-context="true">
            <connection-url>jdbc:oracle:oci:@myTNSDatabaseName</connection-url>
            <driver>oracle</driver>
            <security>
               <user-name>myUserName</user-name>
               <password>myPassword</password>
            </security>
         </datasource>
      </datasources>
      

       

      then I created a new datasource in the administration window of the server and enabled it, so that the standalone.xml looks like:

       

       

       

      .
      .
      .
      <subsystem xmlns="urn:jboss:domain:datasources:1.0">
                  <datasources>
                          .
                          .
                          .
                      <datasource jta="false" jndi-name="java:jboss/datasources/FinalBalanceStructureDS" pool-name="FinalBalanceStructure" enabled="true" use-ccm="false">
                          <connection-url>jdbc:oracle:oci:@myTNSDatabaseName</connection-url>
                          <driver-class>oracle.jdbc.OracleDriver</driver-class>
                          <driver>ojdbc6.jar</driver>
                          <security>
                              <user-name>myUserName</user-name>
                              <password>myPassword</password>
                          </security>
                          <validation>
                              <validate-on-match>false</validate-on-match>
                              <background-validation>false</background-validation>
                              <background-validation-millis>0</background-validation-millis>
                          </validation>
                          <statement>
                              <prepared-statement-cache-size>0</prepared-statement-cache-size>
                              <share-prepared-statements>false</share-prepared-statements>
                          </statement>
                      </datasource>
                      <xa-datasource...
                          .
                          .
                          .                        
                      </xa-datasource>
                      <drivers>
                          <driver name="oracle" module="com.oracle.db">
                              <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
                          </driver>
                          <driver name="h2" module="com.h2database.h2">
                              <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                          </driver>
                      </drivers>
                  </datasources>
              </subsystem>
      

       

      I also created module.xml and ojdbc6 in JBossHome\modules\com\oracle\db\main

       

       

      <?xml version="1.0" encoding="UTF-8"?>
      
      <module xmlns="urn:jboss:module:1.0" name="com.oracle.db">
          <resources>
              <resource-root path="ojdbc6.jar"/>
          </resources>
          <dependencies>
              <module name="javax.api"/>
              <module name="javax.transaction.api"/>
          </dependencies>
      </module>
      

       

      I also added jboss-client-7.1.0.Final.jar to my ejb projects buildpath libraries

       

      Now I tried to deploy it and get the following error:

      11:59:50,778 INFO  [org.jboss.weld.deployer] (MSC service thread 1-2) JBAS016005: Starting Services for CDI deployment: FinalBalanceStructure-ear.ear

      11:59:50,809 INFO  [org.jboss.weld.Version] (MSC service thread 1-2) WELD-000900 1.1.5 (AS71)

      11:59:50,825 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.deployment.unit."FinalBalanceStructure-ear.ear".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."FinalBalanceStructure-ear.ear".INSTALL: Failed to process phase INSTALL of deployment "FinalBalanceStructure-ear.ear"

          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [rt.jar:1.6.0_33]

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0_33]

          at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_33]

      Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS010464: Exception deploying datasource java:jboss/datasources/FinalBalanceStructureDS

          at org.jboss.as.connector.deployers.processors.DsXmlDeploymentInstallProcessor.deploy(DsXmlDeploymentInstallProcessor.java:125)

          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.0.Final.jar:7.1.0.Final]

          ... 5 more

      Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.naming.context.java.jboss.datasources.FinalBalanceStructureDS is already registered

          at org.jboss.msc.service.ServiceRegistrationImpl.setInstance(ServiceRegistrationImpl.java:154) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

          at org.jboss.msc.service.ServiceControllerImpl.startInstallation(ServiceControllerImpl.java:227) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

          at org.jboss.msc.service.ServiceContainerImpl.install(ServiceContainerImpl.java:560) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

          at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:201) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

          at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2228) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

          at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:201) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

          at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2228) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

          at org.jboss.msc.service.ServiceBuilderImpl.install(ServiceBuilderImpl.java:307) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

          at org.jboss.as.connector.deployers.processors.DsXmlDeploymentInstallProcessor.startDataSource(DsXmlDeploymentInstallProcessor.java:309)

          at org.jboss.as.connector.deployers.processors.DsXmlDeploymentInstallProcessor.deploy(DsXmlDeploymentInstallProcessor.java:123)

          ... 6 more

       

      11:59:51,075 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "FinalBalanceStructure-ear.ear" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"FinalBalanceStructure-ear.ear\".INSTALL" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"FinalBalanceStructure-ear.ear\".INSTALL: Failed to process phase INSTALL of deployment \"FinalBalanceStructure-ear.ear\""},"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.comp.FinalBalanceStructure-ear.\"FinalBalanceStructure-ejb-0.0.1-SNAPSHOT\".MemberRegistration.Validatorjboss.naming.context.java.comp.FinalBalanceStructure-ear.\"FinalBalanceStructure-ejb-0.0.1-SNAPSHOT\".MemberRegistrationMissing[jboss.naming.context.java.comp.FinalBalanceStructure-ear.\"FinalBalanceStructure-ejb-0.0.1-SNAPSHOT\".MemberRegistration.Validatorjboss.naming.context.java.comp.FinalBalanceStructure-ear.\"FinalBalanceStructure-ejb-0.0.1-SNAPSHOT\".MemberRegistration]","jboss.naming.context.java.comp.FinalBalanceStructure-ear.\"FinalBalanceStructure-ejb-0.0.1-SNAPSHOT\".MemberRegistration.ValidatorFactoryjboss.naming.context.java.comp.FinalBalanceStructure-ear.\"FinalBalanceStructure-ejb-0.0.1-SNAPSHOT\".MemberRegistrationMissing[jboss.naming.context.java.comp.FinalBalanceStructure-ear.\"FinalBalanceStructure-ejb-0.0.1-SNAPSHOT\".MemberRegistration.ValidatorFactoryjboss.naming.context.java.comp.FinalBalanceStructure-ear.\"FinalBalanceStructure-ejb-0.0.1-SNAPSHOT\".MemberRegistration]"]}

      Did I miss some configurations?

       

      I tried to get a working ear project since 1 week and im getting really desperate.

       

      Thanks for your help.

      Roman

       

      Seems you can't do that, I created instead a new ear project and the deployment works now.

       

      Message was edited by: Roman Goeldi