Database configuration in context.xml or server.xml

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Database configuration in context.xml or server.xml

James Newcombe
This is more of a curiosity than a problem.

I have a server in our corporate network that runs RHELv6, with Tomcat 7.0.33 hosting Orbeon PE 4.8. We use SQL Server 2008 R2, with Microsoft's JDBC 4.1 libraries to connect Tomcat/Orbeon to SQL Server. To make it easier to manage, and in line with Apache's guidelines, I tried to define the JDBC connection using the 'local' context.xml in ../webapps/orbeon/META-INF, but never managed to get it to work. Erik Bruchez helped me before Christmas to get it working, and the workaround was to define it in the base Tomcat server.xml instead.

On a VM on my own laptop, I keep a separate instance of Orbeon 4.8.1 running on Tomcat 7.0.55 on OpenSUSE 13.2, so that I can try out changes to properties files, etc, and other global platform changes that would make life hard for the other developers if I played with our corporate dev platform. With that I have MariaDB 10.1 as the database.

I was able to get MariaDB to play nicely with Orbeon by configuring it as a mysql data source in the local context.xml when I had a single datasource. I now have a solution that uses 6 separate databases, and the only way I could get that to work was by defining all of the data sources in server.xml. As soon as I had more than one datasource, all datasources defined in orbeon's context.xml went unrecognised.

So I guess my questions are:

1. Am I just trying to do a dumb thing, because one database should be enough for anyone ?
2l. If the answer to (1.) is yes, how have others separated form definition/data from the master data that drives things like lookups on the form (which I would like to be able to alter at will without risking compromising the stored form data)
3. If multiple data sources should work, why can't I have multiple data sources defined in context.xml to make the configuration more portable ?
4. Is the problem with the distinction between server.xml and context xml a tomcat thing, or an orbeon thing ? I understand, I think, how the two configuration files are meant to work in combination for web applications, but in practice either I'm wrong (entirely likely), or Orbeon isn't handling context.xml properly.

Reply | Threaded
Open this post in threaded view
|

Re: Database configuration in context.xml or server.xml

Aaron Spike
I've got multiple databases configured from context.xml (which I believe is a tomcat thing or perhaps a servlet thing).
Can you share a redacted copy of your context.xml with multiple databases?

Aaron Spike

This electronic communication, including any attached documents, may contain confidential and/or legally privileged information that is intended only for use by the recipient(s) named above. If you have received this communication in error, please notify the sender immediately and delete the communication and any attachments. Views expressed by the author do not necessarily represent those of Martin Luther College.

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: Database configuration in context.xml or server.xml

James Newcombe
Sure.

<Resource
    name="jdbc/alphaco"
    auth="Container"
    type="javax.sql.DataSource"
    initialSize="3"
    maxActive="10"
    maxIdle="20"
    maxWait="30000"
    driverClassName="com.mysql.jdbc.Driver"
    poolPreparedStatements="true"
    validationQuery="select 1 from dual"
    testOnBorrow="true"
    username="alphaco"
    password="alphaco"
    url="jdbc:mysql://localhost:3306/alphaco?useUnicode=true&amp;characterEncoding=UTF8"/>
<Resource
    name="jdbc/betaco"
    auth="Container"
    type="javax.sql.DataSource"
    initialSize="3"
    maxActive="10"
    maxIdle="20"
    maxWait="30000"
    driverClassName="com.mysql.jdbc.Driver"
    poolPreparedStatements="true"
    validationQuery="select 1 from dual"
    testOnBorrow="true"
    username="betaco"
    password="betaco"
    url="jdbc:mysql://localhost:3306/betaco?useUnicode=true&amp;characterEncoding=UTF8"/>
<Resource
    name="jdbc/deltaco"
    auth="Container"
    type="javax.sql.DataSource"
    initialSize="3"
    maxActive="10"
    maxIdle="20"
    maxWait="30000"
    driverClassName="com.mysql.jdbc.Driver"
    poolPreparedStatements="true"
    validationQuery="select 1 from dual"
    testOnBorrow="true"
    username="deltaco"
    password="deltaco"
    url="jdbc:mysql://localhost:3306/deltaco?useUnicode=true&amp;characterEncoding=UTF8"/>
<Resource
    name="jdbc/deltacoforms"
    auth="Container"
    type="javax.sql.DataSource"
    initialSize="3"
    maxActive="10"
    maxIdle="20"
    maxWait="30000"
    driverClassName="com.mysql.jdbc.Driver"
    poolPreparedStatements="true"
    validationQuery="select 1 from dual"
    testOnBorrow="true"
    username="deltacoforms"
    password="deltacoforms"
    url="jdbc:mysql://localhost:3306/deltacoforms?useUnicode=true&amp;characterEncoding=UTF8"/>


alphaco, betaco, deltaco are the form data/definition databases, deltacoforms is a separate form master data db for holding the data to drive dropdowns. With this configuration in ../webapps/orbeon/META-INF/context.xml, Orbeon server refused to start. No meaningful error messages were issued, other than I once got a "[jdbc] is not defined in this context". That and Google led me to a solution that suggested putting the configuration in server.xml rather than context.xml, but I found just as many suggestions for resolving exactly the opposite problem (server.xml failing, putting the configuration in context.xml instead was the advice) with no guidance on whether or not they worked.
Reply | Threaded
Open this post in threaded view
|

Re: Database configuration in context.xml or server.xml

Aaron Spike
In reply to this post by James Newcombe
Well, that looks exactly like what I am doing. The only difference is that the root element of my context.xml is <Context/> but I'm guess you omitted that as obvious.

This electronic communication, including any attached documents, may contain confidential and/or legally privileged information that is intended only for use by the recipient(s) named above. If you have received this communication in error, please notify the sender immediately and delete the communication and any attachments. Views expressed by the author do not necessarily represent those of Martin Luther College.

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: Database configuration in context.xml or server.xml

Alessandro  Vernet
Administrator
In reply to this post by James Newcombe
Hi James,

Very succinctly, regarding your 1st point, you should be able to use multiple data sources. In fact, locally, for testing, I have one datasource defined for every type of database we support.

And regarding your 4th point, like Aaron, I am pretty sure this is a Tomcat thing, and I am not sure why things would be working for you with multiple datasources if they are defined in the server.xml but not in the context.xml. But let us know if you're stuck on this.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Database configuration in context.xml or server.xml

James Newcombe
Finally found the problem, I believe, but it turns out that putting the database information in server.xml works better for our ops people.

The problem was simpler and more pernicious than expected; when the Context.xml file was created, it was created and later edited by someone logged in as root. Tomcat couldn't read it, so it simply ignored it.
Reply | Threaded
Open this post in threaded view
|

Re: Database configuration in context.xml or server.xml

Alessandro  Vernet
Administrator
Hi James,

Interesting, I certainly wouldn't have thought of that. I'm glad you found the source of the problem, and thanks for sharing.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet