Hello,
I would like to prepare a CMS docker image(container) connecting to Oracle 12c database. I am quite new to docker realm and also bloomreach. I read following pages and gave it a try but I have not yet made any progress:
It seems for H2, MySQL and PostgreSQL everything is so easy and prepared and would be done through the Mavenâs Profile but for Oracle Database more effort need to be made.
Generally, is there any other document/instruction which explain this procedure with more details because several questions have been raised for me:
- What do I have to do to modify database type from default H2 to Oracle 12c? where should I put my configured repository.xml?
- Where should I place database driver(ojdbc8)? I mean it should be done by changing the docker file or I should place it in $TOMCAT_HOME/lib after creation of docker image?
Thank you in advance,
Amirhossein Farmad
Which version of brXM are you using?
hippo CMS 13.3.0
I followed this instruction to create the project.
Now, I would like to change the database to Oracle and then create a docker image.
Great, then you can take advantage of the ootb docker support. Oracle db setup does not come with it, but it is supported. You just have to do some work.
- First of all, check out [1]. There, you can see that you need 1)repository.xml for oracle 2) context.xml for oracle. This page will have those.
- Take a look at the existing postgresql setup for example in the project. You have a repository-postgresql.xml there for instance. You should add your repository-oracle.xml next to that one for example. Check in detail the repositoy-postgresql.xml: youâll see that there are variables in there which are surrounded by two â@â characters (example: â@cluster.node.id@â ). Do the same for your repository-oracle.xml
- Take a look at the existing context-postgresql.xml for the same kind of variables (two â@â signs). Do the same for your own context-oracle.xml
- go to src/main/docker/scripts and take a look at the postgres folder. There you can find a script that substitutes the â@â variables with environment variables. Also copy this behavior for your oracle db.
- In your dockerfile pass the correct repo config file reference with an environment variable:
REPO_CONFIG = âfile://${CATALINA_HOME}/conf/repository-oracle.xmlâ
This should be it, hopefully I didnât miss anything. Good luck!
[1] https://documentation.bloomreach.com/library/deployment/configuring/configuring-hippo-for-oracle-database.html
1 Like
Thanks bcanvural, I followed your instruction.
- conf\repository-oracle.xml was created and the variables were set.
- conf\context-oracle.xml was created and the variables were set.
- src\main\docker\scripts\oracle\setup-db.sh was created and the variables were set.
- src\main\docker\scripts\oracle\setup-db.sh was modified.
- Then following commands was executed:
mvn clean install
mvn -P docker.build
mvn -P docker.run
and I came across this error during the run:
java.sql.SQLException: Cannot load JDBC driver class âoracle.jdbc.OracleDriverâ
Caused by: java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
- It seems ojdbc8 was not placed at its rigth place âgam-cms\target\docker\com.gam\gamcms\0.1.0-SNAPSHOT\build\maven\db-drivers\oracle\ojdbc8â so as to finally copy to âtomcat\libsâ. Therefore I made these changes to force the maven profile to make a âoracleâ directory at â\build\maven\db-driversâ such as postgres and mysql and then put the ojdbc8 there.
- I declared a new profile:
<profile>
<id>oracle</id>
</profile>
<profile>
<id>docker.oracle</id>
<properties>
<docker.db.host>xxx</docker.db.host>
<docker.db.port>xxx</docker.db.port>
<docker.db.schema>xxx</docker.db.schema>
<docker.db.username>xxx</docker.db.username>
<docker.db.password>xxx</docker.db.password>
<docker.db.bind.1>${project.basedir}/target/oracle-data:/var/lib/oracle/data</docker.db.bind.1>
<docker.db.bind.2>${project.basedir}/db-bootstrap:/docker-entrypoint-initdb.d</docker.db.bind.2>
<docker.brxm.envRun.ORACLE_DB_HOST>${docker.container.db.net.gamcms-network.ip}</docker.brxm.envRun.ORACLE_DB_HOST>
</properties>
<dependencies>
<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>12.2.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
- I added a new dependencySet at â\gam-cms\src\main\docker\assembly\docker-db-libs.xmlâ:
<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<outputDirectory>db-drivers/oracle</outputDirectory>
<scope>provided</scope>
<includes>
<include>com.oracle.jdbc:ojdbc8</include>
</includes>
</dependencySet>
- I added following changes at â\gam-cms\src\main\docker\assembly\conf-component-docker.xmlâ:
<file>
<source>conf/context-oracle.xml</source>
<outputDirectory>conf</outputDirectory>
<filtered>false</filtered>
</file>
<file>
<source>conf/repository-oracle.xml</source>
<outputDirectory>conf</outputDirectory>
<filtered>false</filtered>
</file>
- Following commands was executed:
mvn clean install
mvn -P docker.build
mvn -P docker.run,oracle
and again I came across the same error during the run because the âgam-cms\target\docker\com.gam\gamcms\0.1.0-SNAPSHOT\build\maven\db-drivers\oracle\ojdbc8â has not yet created. I think this warning can be a clue to understand why it doesnât create this directory like Postgresql and MySQL. Do you have any idea what I have to do:
[INFO] Reading assembly descriptor: \gam-cms\src\main\docker\assembly\distribution-docker.xml
[WARNING] The following patterns were never triggered in this artifact inclusion filter:
o âcom.oracle.jdbc:ojdbc8â
HI again,
Check the hippo-cms7-release-13.x.y.pom. in there, in the dependency management section there are connector jars listed. Did you add the oracle db jar just like those in your project?
If it works for postgres but not your case essentially I would look into the parent poms of the project and see how dependencies are setup for mysql and postgres.
1 Like