Uploaded image for project: 'Jetspeed 2 (Retired)'
  1. Jetspeed 2 (Retired)
  2. JS2-320

build.properties Variable Interpolation (Commons Configuration) not working in AbstractTestHelper

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0-M4
    • 2.0-M4, 2.0-FINAL
    • Testing
    • None
    • WindowsXP SP2, JDK1.5.0_04_b05, Oracle9i

    Description

      I used to be able to define the (Oracle) test and production db configuration in my build.properties using variable interpolation.

      Something like this:

      my.j2.db.name = orcl
      my.j2.db.url=jdbc:oracle:thin:@localhost:1521:${my.j2.db.name}
      my.j2.db.driver=oracle.jdbc.driver.OracleDriver
      my.j2.testuser = j2t
      my.j2.produser = j2p

      And then use the above property definitions like this:

      org.apache.jetspeed.test.database.url = ${my.j2.db.url}
      org.apache.jetspeed.test.database.driver = ${my.j2.db.driver}
      org.apache.jetspeed.test.database.user = ${my.j2.testuser}
      org.apache.jetspeed.test.database.password =${my.j2.testuser}

      org.apache.jetspeed.production.database.url = ${my.j2.db.url}
      org.apache.jetspeed.production.database.driver = ${my.j2.db.driver}
      org.apache.jetspeed.production.database.user = ${my.j2.produser}
      org.apache.jetspeed.production.database.password =${my.j2.produser}

      This though is no longer working

      In AbstractTestHelper the configurations from my build.properties and the j2 project.properties are loaded using a Commons PropertyConfiguration.
      Although the Commons Configuration says it supports Variable Interpolation, it clearly doesn't work:

      Testcase: testHelper(org.apache.jetspeed.testhelpers.TestDatasourceHelper): Caused an ERROR
      Cannot load JDBC driver class '${my.j2.db.driver}'
      org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class '${my.j2.db.driver}'
      at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:766)
      at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
      at org.apache.jetspeed.testhelpers.TestDatasourceHelper.testHelper(TestDatasourceHelper.java:22)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      Caused by: java.lang.ClassNotFoundException: ${my.j2.db.driver}
      at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:164)
      at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:760)
      ... 16 more

      I tried using Commons Configuration 1.1 (the latest while we currently 1.0) but that didn't help either.
      Of course, I could "solve" this by (temporarily) hardcoding my properties but this clearly isn't what I like...

      Attachments

        Activity

          People

            ate Ate Douma
            ate Ate Douma
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: