Page 1 of 1

Environments - setup - jetty-env?

Posted: Wed Mar 12, 2014 12:17 am
by Skychan
So, I'm trying to figure out switching between environments
http://docs.broadleafcommerce.org/core/current/appendix/runtime-environment-configuration
(staging-shared.properties vs development-shared.properties)

What I don't understand is how this can support different DB environments since there is only one jetty-env.xml per site per environment.

So if I want to start switching from HSQL to MySQL, I have to swap between different jetty-env.xml files to switch between the two DB environments?

Re: Environments - setup - jetty-env?

Posted: Sun Mar 23, 2014 7:20 pm
by phillipuniverse
Those runtime properties are not designed for properties at the container level, those are really just defined for the application level. Container-specific properties (like the JNDI database) would yes, be set at a unique jetty-env.xml file.

If you're not really using a standalone container when you deploy to other environments (e.g. if you're using a PaaS like Heroku) then you could move the JNDI datasource defined in the servlet container (Jetty) to just use a Spring datasource like this:

Code: Select all

<bean id="webDS" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
   <property name="driverClassName" value="${database.driver}" />
   <property name="url" value="${database.url}" />
   <property name="username" value="${database.username}" />
   <property name="password" value="${database.password}" />
</bean>


You would replace the bean entries that you find in applicationContext-datasource.xml with those. Then you could define 'database.driver', 'database.username' etc in your different environment properties files and it would work as you expected. This of course would require you to commit database usernames and passwords into your application to use them like that.

Re: Environments - setup - jetty-env?

Posted: Thu Mar 27, 2014 10:04 am
by Skychan
Thank you. I think I'll just switch between jetty-env.xml files if I need to. Hopefully I can switch over to MySQL permanently w/o issue