Announcement Announcement Module
Collapse
No announcement yet.
DATABASE_URL environment variable erroneously used instead of database.properties Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • DATABASE_URL environment variable erroneously used instead of database.properties

    Folks,

    I am facing a strange issue with Roo's database configuration. As part of Heroku deployment I had to create this environment variable:
    Code:
    DATABASE_URL = postgres://postgres:password@localhost:5432/testdb
    Now every Roo project I create somehow detects that variable and uses it instead of the config provided in database.properties.

    applicationContext.xml:
    Code:
    ...
    <bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="dataSource">
        <property name="driverClassName" value="${database.driverClassName}"/>
        <property name="url" value="${database.url}"/>
        <property name="username" value="${database.username}"/>
        <property name="password" value="${database.password}"/>
            ...
    </bean>
    ...
    database.properties:
    Code:
    database.driverClassName=org.apache.derby.jdbc.EmbeddedDriver
    database.url=jdbc\:derby\:test;create\=true
    database.username=
    database.password=
    Error message when running 'mvn clean jetty:run'
    Code:
    2012-10-12 11:42:19,235 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaExport - schema export unsuccessful org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'org.apache.derby.jdbc.EmbeddedDriver' for connect URL 'postgres://postgres:password@localhost:5432/testdb'
    I can't find any references to 'DATABASE_URL' anywhere in the project, not sure how/why it detects that environment variable chooses to use it over what is configured in database.properties. Any ideas?
    Last edited by sbelyankin; Oct 12th, 2012, 02:40 PM.

  • #2
    Found the problem:

    Code:
    <context:property-placeholder location="classpath*:META-INF/spring/*.properties" system-properties-mode="NEVER" />
    In Spring 3.1, this attribute value is defaulted to ENVIRONMENT, it ends up picking up "DATABASE_URL" and converting it to "database.url". The workaround is to add 'system-properties-mode="NEVER"'.

    Comment

    Working...
    X