我正试图让声纳在OpenShift上工作。当我尝试在sonar.properties文件中使用环境变量时,它们不会被声纳解析。
结果如下所示:
2013.06.18 17:22:19 INFO o.s.c.p.Database Create JDBC datasource for jdbc:mysql://${env:OPENSHIFT_MYSQL_IP}:${env:OPENSHIFT_MYSQL_PORT}/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
2013.06.18 17:22:20 ERROR o.s.c.p.Database Can not connect to database. Please check connectivity and settings (see the properties prefixed by 'sonar.jdbc.').
org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Cannot load connection class because of underlying exception: 'java.lang.NumberFormatException: For input string: "OPENSHIFT_MYSQL_IP}:${env:OPENSHIFT_MYSQL_PORT}"'.)
at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549) ~[commons-dbcp-1.3.jar:1.3]
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388) ~[commons-dbcp-1.3.jar:1.3]
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044) ~[commons-dbcp-1.3.jar:1.3]
at org.sonar.core.persistence.DefaultDatabase.checkConnection(DefaultDatabase.java:140) [sonar-core-3.5.1.jar:na]
at org.sonar.core.persistence.DefaultDatabase.start(DefaultDatabase.java:69) [sonar-core-3.5.1.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_19]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_19]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_19]
at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_19]
我试图了解声纳中的变量分辨率是如何工作的,这样我就可以开始弄清楚OpenShift有什么问题了。
答案 0 :(得分:0)
我能够使用git://github.com/wenhao/openshift-sonar.git进行Sonar运行,稍作修改:
修改了ROOT / WEB-INF / classes / sonar-war.properties:
#SONAR_HOME = $ {ENV:OPENSHIFT_REPO_DIR} /webapps/sonar-3.3.1 SONAR_HOME =的/ var / lib中/ openshift / 51c0c3c1e0b8cd74800000dc / APP-根/回购/ web应用/声纳-3.3.1
git add。
我不太清楚为什么ROOT / WEB-INF / classes / sonar-war.properties不解析env变量,但是sonar-3.3.1 / conf / sonar.properties解决它们很好:
sonar.jdbc.username: ${env:OPENSHIFT_MYSQL_DB_USERNAME}
sonar.jdbc.password: ${env:OPENSHIFT_MYSQL_DB_PASSWORD}