I have just busted by head trying to debug ODK-Aggregate-v2.0.0-Linux-x64.run.zip. My server was running ODK v1.7.0 on Ubuntu Server 18 previously and I used the ODK-Aggregate-v1.7.1-Linux-x64.run.zip for my next hop. Ran the RUN file, generated the WAR and plopped it into my /opt/tomcat/webapps folder and restarted, everything worked beautifully.
Then I repeated the exact same steps to go from v1.7.1 to v2.0.0 and everything broke. I kept getting the redirect to a 404 Not Found when going to https://myodkserver.local:8443/Aggregate.html.
Then I checked the Tomcat log files /opt/tomcat/logs/Catalina.out
WARNING: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dataSource' defined in class path resource [odk-settings.xml]: Could not resolve placeholder 'jdbc.driverClassName' in string value "${jdbc.driverClassName}"; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'jdbc.driverClassName' in string value "${jdbc.driverClassName}"
Feb 28, 2019 1:44:50 PM org.springframework.web.context.ContextLoader initWebApplicationContext
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dataSource' defined in class path resource [odk-settings.xml]: Could not resolve placeholder 'jdbc.driverClassName' in string value "${jdbc.driverClassName}"; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'jdbc.driverClassName' in string value "${jdbc.driverClassName}"
at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:223)
So the I did some troubleshooting and noticed that there were missing lines in the jdbc.properties definition file!!
This is the file from v1.7.0 and v1.7.1 is similar:
jdbc.driverClassName=org.postgresql.Driver <<--- This Line missing in 2.0.0
jdbc.resourceName=jdbc/odk_aggregate <<--- This Line also missing in 2.0.0
jdbc.url=jdbc:postgresql://127.0.0.1/odk_prod?autoDeserialize=true
jdbc.username=odk_user
jdbc.password=meinP@ssw0rt!!!
jdbc.schema=odk_prod_schema
jdbc.help.about=Generated on 2018-11-01T11:58:38-0700 for MeinODK ODK Aggregate v1.7.0
This is the file in v2.0.0 notice the two lines missing above!!!
jdbc.help.about=Generated on 2019-02-28T10:13:12-0800 for MeinODK Aggregate v2.0.0
jdbc.url=jdbc:postgresql://127.0.0.1/odk_prod?autoDeserialize=true
jdbc.username=odk_user
jdbc.password=meinP@ssw0rt!!!
jdbc.schema=odk_prod_schema
The Tomcat was unable to find ${jdbc.driverClassName} and thus unable to query the database and thus unable to start the listener leading to the 404 Not Found because those two lines were missing in jdbc.properties.
To fix it:
-
I first ran the RUN file using all the original settings I entered the first time I ever installed ODK Aggregate to get the WAR File.
-
Extract the WAR into a new folder (I called it mod) using the jar -xvf commando
-
Go into the ./mod/WEB-INF/lib folder
-
Create a mod-settings folder and extracted ODKAggregate-settings.jar into there
-
Modify the jdbc.properties file adding back the two missing lines
jdbc.driverClassName=org.postgresql.Driver
jdbc.resourceName=jdbc/odk_aggregate -
Repackage the modified ODKAggregate-settings.jar file being careful not to include the mod-settings folder into the root of the archive. I did this while in ./mod/WEB-INF/lib/mod-settings by running the command
--> jar -cvf ,,/ODKAggregate-settings-2.jar *
- Go back to ./mod/WEB-INF/lib and delete the broken ODKAggregate-settings.jar file and rename the one we just made
--> rm ODKAggregate-settings.jar
--> mv ODKAggregate-settings-2.jar ODKAggregate-settings.jar
-
Repackage the repaired ODKAggregate.war file by going back to ./mod and running the command
--> jar -cvf ../ODKAggregate.war *
Which will place the newly created war file one directory up, in order not to include the mod directory in the root of the web application. -
Redeploy the ODKAggregate.war into /opt/tomcat/webapps
-
Test and it should be working!
I don't understand how such a bug got into the final build. v1.7.1 was fine. v2.0 beta0 has even a bigger problem in that it calls the database using odk_unit username instead of odk_user, and odk_db instead of odk_prod database i.e. the settings you entered during the RUN / WAR file generation are ignored.