geoenvo / oskari-server-extension-dps

From https://github.com/oskariorg/sample-server-extension/tree/1.2.1
Other
0 stars 1 forks source link

404 error when accessing Oskari after using the oskari-map.war build output #1

Closed senoadiw closed 4 years ago

senoadiw commented 4 years ago

The build from the wb-idp branch was successful however after rebooting the server accessing the Oskari site at http://192.168.1.200:8080/ gives a 404 error. Accessing http://192.168.1.200:8080/downloads/ works.

sudo su
cd /opt/oskari/oskari-server
git clone -b wb-idp https://github.com/geoenvo/oskari-server-extension-dps.git
cd oskari-server-extension-dps
# fix Unknown host repo.boundlessgeo.com: Name or service not known
nano pom.xml
    # add to end of <repositories> block
    <repository>
        <id>osgeo</id>
        <name>OSGeo Release Repository</name>
        <url>https://repo.osgeo.org/repository/release/</url>
        <snapshots><enabled>false</enabled></snapshots>
        <releases><enabled>true</enabled></releases>
    </repository>
mvn clean install >> oskari_server_extension_dps_build.log
ls -lah webapp-map/target
    total 95M
    drwxr-xr-x 7 root root 4.0K Jun 24 11:44 .
    drwxr-xr-x 4 root root 4.0K Jun 24 11:43 ..
    drwxr-xr-x 3 root root 4.0K Jun 24 11:43 classes
    drwxr-xr-x 3 root root 4.0K Jun 24 11:43 generated-sources
    drwxr-xr-x 2 root root 4.0K Jun 24 11:44 maven-archiver
    drwxr-xr-x 3 root root 4.0K Jun 24 11:43 maven-status
    drwxr-xr-x 4 root root 4.0K Jun 24 11:44 oskari-map
    -rw-r--r-- 1 root root  95M Jun 24 11:44 oskari-map.war
# backup original oskari-map.war
mv /opt/oskari/oskari-server/webapps/oskari-map.war /opt/oskari/oskari-server/webapps/oskari-map.war.orig
# replace with new oskari-map.war build
cp webapp-map/target/oskari-map.war /opt/oskari/oskari-server/webapps/
ls -lah /opt/oskari/oskari-server/webapps/
# need to rebuild oskari db from scratch due to new migrations! Create new oskari db for city
    # backup existing oskari database
    cd ~/backups
    pg_dump --host 127.0.0.1 --port 5432 --username "postgres" --format custom --blobs --verbose --file "yyyymmdd_oskaridb.backup" "oskaridb"
    sudo -u postgres psql -c "CREATE DATABASE oskaridpsdb WITH OWNER oskari;"
    sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE oskaridpsdb TO oskari;"
    sudo -u postgres psql -d oskaridpsdb -c "CREATE EXTENSION postgis; CREATE EXTENSION postgis_topology;"
    sudo -u postgres psql -d oskaridpsdb -c "ALTER VIEW geometry_columns OWNER TO oskari; ALTER TABLE spatial_ref_sys OWNER TO oskari;"
    sudo -u postgres psql -d oskaridpsdb -c "GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO oskari;"
cd /opt/oskari/oskari-server/resources
# backup working config
cp oskari-ext.properties oskari-ext.properties.bak
# add additional settings
nano oskari-ext.properties
    #db.additional.modules=myplaces, userlayer, example
    db.additional.modules=myplaces, userlayer, wbidp

    #db.url=jdbc:postgresql://localhost:5432/oskaridb
    db.url=jdbc:postgresql://localhost:5432/oskaridpsdb

    # add to bottom
    ##################################
    # CKAN-Oskari integration setup
    ##################################
    oskari.scheduler.job.SynchronizeUserDataJob.cronLine=0 * * * * ?
    oskari.scheduler.job.SynchronizeLayerDataJob.cronLine=0 * * * * ?
    ckan.integration.db.url=jdbc:postgresql://localhost:5432/ckan_default
    ckan.integration.db.username=ckan_default
    ckan.integration.db.password=ckandefaultdbpassword

    ##################################
    # Download bundle
    ##################################
    oskari.wfs.download.folder.name=/opt/oskari/oskari-server/webapps/downloads
    oskari.wfs.download.normal.way.downloads=rectangle
    oskari.wfs.download.smtp.host=localhost
    oskari.wfs.download.smtp.port=25
    oskari.wfs.download.email.from=myemail@email.com
    oskari.wfs.download.email.subject=Latauspalvelu | Nedladdningstjänst | Download service
    oskari.wfs.download.email.header=

    oskari.wfs.download.email.message=Tilaamasi aineistot ovat ladattavissa osoitteessa:\nMaterialet som du beställt kan laddas ned på ad$
    oskari.wfs.download.email.footer={LINEBREAK}Lataus-osoite on voimassa 10 päivää{LINEBREAK}Nedladdningsadressen gäller i 10 dagar.{LIN$

    oskari.wfs.download.email.message.datadescription={LINEBREAK}{LINEBREAK}Älä vastaa tähän viestiin.{LINEBREAK}Svara inte på detta medd$
    oskari.wfs.download.email.datadescription_link=
    #oskari.wfs.download.link.url.prefix=https://localhost:8080/downloads/
    oskari.wfs.download.link.url.prefix=http://192.168.1.200:8080/downloads/
    oskari.wfs.service.url=http://geo.stat.fi/geoserver/wfs
    oskari.wfs.error.message=Service down, try again later
    oskari.wfs.download.error.report.support.email=myemail@email.com
    oskari.wfs.download.error.report.subject=Error while downloading data!
mkdir /opt/oskari/oskari-server/webapps/downloads
reboot

Screenshots

error 404

oskari downloads

Logs

Build log oskari_server_extension_dps_build.log

Jetty log on first run of flyway migrations 2020_06_24.jetty.log

Note from Jetty log: 2020-06-24 11:59:03,914 WARN flyway.oskari.V1_39_1__migrate_publish_template_ol3 - Publish template couldn't be loaded with id 2 - If you are populating an empty DB this is fine. If you are migrating an old database you have misconfigured template property ( view.template.publish ) in oskari-ext.properties!

Oskari settings file oskari-ext.properties.log

senoadiw commented 4 years ago

I tried initializing a new Oskari database with the original oskari-map.war build => open http://192.168.1.200:8080 => works, the world map loads!

Replace the oskari-map.war with the custom build on the same database above and restart Oskari server => open http://192.168.1.200:8080 => Error 503 Service Unavailable

Here is the Jetty server log: 2020_06_30.jetty.log

Note: the error below on line 467, it looks like a value is required for the bundle_id column

2020-06-30 16:06:00,575 ERROR fi.nls.oskari.servlet.WebappHelper - DB migration for module wbidp failed! org.flywaydb.core.api.FlywayException@6d7ad0f5[ detailMessage=Migration failed ! cause=org.postgresql.util.PSQLException: ERROR: null value in column "bundle_id" violates not-null constraint Detail: Failing row contains (3, null, 25, null, null, null, download-basket). stackTrace={} suppressedExceptions=[] ]

senoadiw commented 4 years ago

Here is the pg_dump file of the Oskari database above: oskaridbtest.zip

restoring from postgresql backup, drop connections to db first

sudo systemctl restart postgresql cd ~/backups sudo -u postgres psql -c "DROP DATABASE IF EXISTS oskaridbtest;" sudo -u postgres psql -c "CREATE DATABASE oskaridbtest WITH OWNER oskari;" sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE oskaridbtest TO oskari;" sudo -u postgres psql -d oskaridbtest -c "CREATE EXTENSION postgis; CREATE EXTENSION postgis_topology;" sudo -u postgres psql -d oskaridbtest -c "ALTER VIEW geometry_columns OWNER TO oskari; ALTER TABLE spatial_ref_sys OWNER TO oskari;" sudo -u postgres psql -d oskaridbtest -c "GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO oskari;"

restore oskaridbtest database from backup file

pg_restore --host localhost --port 5432 --username "postgres" --dbname "oskaridbtest" --password --schema-only --verbose oskaridbtest.backup pg_restore --host localhost --port 5432 --username "postgres" --dbname "oskaridbtest" --password --data-only --disable-triggers --verbose oskaridbtest.backup

mr-lev1 commented 4 years ago

Ah, I think I got it now. The download-basket bundle is probably missing from from the portti_bundle table. This causes an error while the Flyway tries to add that bundle to views with _../oskari-server-extension-dps/blob/wb-idp/server-extension/src/main/java/flyway/wbidp/V1_0_0__add_downloadbasket.java and does not get an ID for it (since it's missing from the bundle table).

You should be able to fix this easily by adding download-basket bundle manually to the db by running this query in your Oskari db: INSERT INTO "public"."portti_bundle"("name", "config", "state", "startup") VALUES ('download-basket', '{}', '{}', NULL);

And after that just fire up the wbidp-Oskari! Let me know if this helps. I'll try to figure out why this happens.

senoadiw commented 4 years ago

Yes, now Oskari loads the world map properly after inserting the download-basket record manually to the db.