It's easy to access an external database from within Confluence...
You specify something like this in <install-dir>/conf/server.xml:
<Resource name="jdbc/myDataSource" auth="Container" type="javax.sql.DataSource" username="myusername" password="mypassword" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/mydatabase?useUnicode=true&amp;characterEncoding=utf8" maxActive="15" maxIdle="7" defaultTransactionIsolation="READ_COMMITTED" validationQuery="Select 1" />
But during development, how do you get this resource to persist after issuing the atlas-run command?
Any edits to target/container/tomcat6x/cargo-confluence-home/conf/server.xml are overwritten on atlas-run
I'm thinking along the lines of a specially created tomcat zip file (including an updated server.xml file) similar to how the cargo-maven2-plugin works:
<plugins> <plugin> <groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven2-plugin</artifactId> <configuration> <container> <containerId>tomcat5x</containerId> <zipUrlInstaller> <url>http://www.apache.org/dist/jakarta/tomcat-5/v5.0.30/bin/jakarta-tomcat-5.0.30.zip</url> <downloadDir>${project.build.directory}/downloads</downloadDir> <extractDir>${project.build.directory}/extracts</extractDir> </zipUrlInstaller> </container> </configuration> </plugin> </plugins>
All suggestions are welcome. Extra points for working code :)
Community moderators have prevented the ability to post new answers.
Another way of tackling this is to create your own tomcat zip as described by @Radu here in step 18:
https://answers.atlassian.com/questions/11337/using-mysql-instead-of-hsql-db-with-atlassian-pdk?page=1#12035
Quoted and adapted below:
create apache-tomcat-6.0.20.zip with edited server.xml file. And then using "maven install" update your maven repository to use this file instead of standard tomcat zip that you downloaded from atlassian maven repository.
atlas-mvn install:install-file -DgroupId=org.apache.tomcat -DartifactId=apache-tomcat -Dversion=6.0.20 -Dfile=apache-tomcat-6.0.20.zip -Dpackaging=zip -DgeneratePom=false
Why wouldn't you set up a db config in confluence-home and use atlas-create-home-zip (https://developer.atlassian.com/display/DOCS/atlas-create-home-zip)? I haven't actually tried this, but it seems like it would work as follows.
# atlas-run
# edit the db settings in plugin confluence-home
# ctrl-c
# atlas-create-home-zip and associated settings
# atlas-run
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just tried it and it seems like you need a pre-existing Confluence DB to get it to work. I get an error in the log.
Table 'apreference.bandana' doesn't exist
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David,
I have the same problem where the changes in cargo-jira-home>conf>server.xml are not persisted. I tried your solution but didn't have any luck.
I installed the SDK and ended up with the following structure:
target>container>tomcat6x>apache-tomcat-6.0.20>conf
target>container>tomcat6x>cargo-jira-home>conf
<Context path="/jira" docBase="/Path/amps-standalone/target/jira/jira.war" debug="2"> <Resource name="UserTransaction" auth="Container" type="javax.transaction.UserTransaction" factory="org.objectweb.jotm.UserTransactionFactory" jotm.timeout="60"/> <Resource name='jdbc/StagingDB' auth='Container' type='javax.sql.DataSource' username='x' password='x' driverClassName='oracle.jdbc.OracleDriver' url='jdbc:oracle:thin:@x:9999:x' connectionProperties="SetBigStringTryClob=true" /> </Context>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm usually solving this via an ant-maven-plugin. Of course, feel free to adapt it, add conditions, etc
That being said, I'm leaving the code to speak for itself :) - it is an excerpt from some project of mine.
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>prepare-directories</id>
<phase>initialize</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
............................
<echo message="MYBATIS.GEN: [2.2] Patching generator file ..." />
<!-- load in var additional-xml the dynamically generated fragment -->
<loadfile property="additional-xml"
srcfile="${project.build.directory}/generated-sources/mybator.fragment" />
<!-- This looks for AUTOGENTABLES string (including comments tags) and replaces it with what was generated -->
<replace file="${project.build.directory}/generated-sources/ibatis-generator-config.xml"
token="<!--AUTOGENTABLES-->"
value="${additional-xml}"/>
</tasks>
</configuration>
</execution>
..........................
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
And for reference, a technique that I use when you do not have, as shown above, a token to rely on.
If you need to add some config between:
===
<Context>
<!-- ..... here, I mean -->
</Context>
===
you just have to define you fragment like this:
===
<Resource ..../></Context>
===
Then:
use the token as : token="</Context>"
The result will be:
===
<Context>
<!-- ..... here, I mean -->
<Resource ..../>
</Context>
===
HTH
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm fighting with the same issue as David.
Radu, your solution seems to work somewhat for me, but it gets executed at the wrong point in time during the atlas-debug or atlas-run execution.
The changes are made in the server.xml file, but around the moment the log outputs:
"[INFO] [talledLocalContainer] Tomcat 6.x starting...", the server.xml is overwritten with a fresh copy.
I realize I expose my broad-sweeping ignorance of all things maven here... but how can I schedule an antrun plugin to execute once the tomcat files have been written, but before tomcat is started up?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
1) First, I have to admit that my builds are usually customized (i.e. I do not use atlas-....). It's just maven.
2) Next: find your executing goals like this:
atlas-mvn help:describe -Dcmd=(command_from_atlas_run_or_whatever)
(Atl scrips, AFAIK, are using some atl plugins to do the dispatching to bamboo, jira, etc)
You will see the actual execution. Choose a phase and a goal carefully and do your stuff
HTH
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just to confirm, this is for use with external datasources, not switching Confluence from the embedded DB :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.