Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QGISserver cannot find shp; tries to open absolute instead of relative path #33200

Closed
rduivenvoorde opened this issue Dec 3, 2019 · 2 comments · Fixed by #33925
Closed

QGISserver cannot find shp; tries to open absolute instead of relative path #33200

rduivenvoorde opened this issue Dec 3, 2019 · 2 comments · Fixed by #33925
Assignees
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Server Related to QGIS server

Comments

@rduivenvoorde
Copy link
Contributor

When I create a simple qgis project to be served by QGIS-Server/wfs3 I get a message:

<ServerException>Layer(s) not valid</ServerException>

It seems as QGISServer is seeing the relative path to my shp file as an absolute path.
IN the qgs file from the qgz I see a relative path ( attached: zippedprojectfile.zip )

I've seen this first on a Windows (OSGeo4W server instal), but I can reproduce it on a Debian based install.
As this is about WFS3, it works only in 3.10 or master

<datasource>./pc6/pc6.shp</datasource>
But in the apache log it seems QGISServer is looking at an absolute path:

../src/core/providers/ogr/qgsogrprovider.cpp:475 : (QgsOgrProvider) [1ms] Data source uri is [/pc6/pc6.shp]
../src/core/providers/ogr/qgsogrprovider.cpp:273 : (AnalyzeURI) [0ms] Data source uri is [/pc6/pc6.shp]
../src/core/providers/ogr/qgsogrprovider.cpp:4401 : (open) [0ms] mFilePath: /pc6/pc6.shp

To reproduce:

  • put the pc6.* files from this zip in a directory pc6 somewhere pc6.zip
  • create a QGIS project from (only this pc6.shp) and save it NEXT to the pc6 dir
    (you can check datasource in the project file)
  • also make sure you tick the box that you want to server the pc6 file as a wfs3 layer (in project properties)
  • now copy the project.qgz file AND the data pc6/pc6.* into your /usr/lib/cgi-bin dir (next to your mapserv)
  • configure qgis mapserver (I do it in Apache) pointing to the projectfile by using:
    FcgidInitialEnv QGIS_PROJECT_FILE "pc6project.qgz"

Now go to your mapserver:
http://localhost/cgi-bin/qgis_mapserv.fcgi/wfs3

And you will see the error

Full apache log:

../src/core/qgsmessagelog.cpp:29 : (logMessage) [1ms] 2019-12-03T09:58:25 [1] Adding service WMTS 1.0.0
../src/core/qgsmessagelog.cpp:29 : (logMessage) [0ms] 2019-12-03T09:58:25 Server[0] Server initialized
../src/core/qgsmessagelog.cpp:29 : (logMessage) [0ms] 2019-12-03T09:58:25 ../src/server/qgsserverplugins.cpp[0] load library /home/richard/bin/qgis/master/debug/lib/qgispython (3.11.0)
../src/core/qgsmessagelog.cpp:29 : (logMessage) [3ms] 2019-12-03T09:58:25 ../src/server/qgsserverplugins.cpp[0] Python support library loaded successfully.
../src/server/qgsserverplugins.cpp:74 : (initPlugins) [0ms] Python support library's instance() symbol resolved.
../src/core/qgsmessagelog.cpp:29 : (logMessage) [29ms] 2019-12-03T09:58:25 Python error[1] The extra plugin path '/opt/qgis-server/plugins' does not exist!
../src/server/qgsserverplugins.cpp:80 : (initPlugins) [798ms] Python support ENABLED :-)
../src/core/qgsmessagelog.cpp:29 : (logMessage) [3ms] 2019-12-03T09:58:26 Server[0] No server python plugins are available
fcgi query string:  ""
../src/server/qgsserver.cpp:144 : (configPath) [0ms] QGIS_PROJECT_FILE:pc6project.qgz
../src/server/qgsserver.cpp:144 : (configPath) [0ms] QGIS_PROJECT_FILE:pc6project.qgz
../src/core/qgsproject.cpp:1192 : (readProjectFile) [7ms] Opened document /tmp/QGIS3-XtRAWk/pc6project.qgs
../src/core/qgsproject.cpp:1225 : (readProjectFile) [2ms] 45 properties read
../src/core/qgsproject.cpp:882 : (_getTitle) [0ms] unable to find title element
../src/core/qgscoordinatereferencesystem.cpp:593 : (loadFromDatabase) [0ms] load CRS from /home/richard/bin/qgis/master/debug/share/qgis/resources/srs.db where lower(auth_name||':'||auth_id) is epsg:28992
../src/core/qgsvectorlayer.cpp:1460 : (readXml) [28ms] Datasource in QgsVectorLayer::readXml: /pc6/pc6.shp
../src/core/providers/ogr/qgsogrprovider.cpp:475 : (QgsOgrProvider) [1ms] Data source uri is [/pc6/pc6.shp]
../src/core/providers/ogr/qgsogrprovider.cpp:273 : (AnalyzeURI) [0ms] Data source uri is [/pc6/pc6.shp]
../src/core/providers/ogr/qgsogrprovider.cpp:4401 : (open) [0ms] mFilePath: /pc6/pc6.shp
../src/core/providers/ogr/qgsogrprovider.cpp:4402 : (open) [0ms] mLayerIndex: 0
../src/core/providers/ogr/qgsogrprovider.cpp:4403 : (open) [0ms] mLayerName:·
../src/core/providers/ogr/qgsogrprovider.cpp:4404 : (open) [0ms] mSubsetString:·
../src/core/providers/ogr/qgsogrprovider.cpp:4457 : (open) [6ms] OGR failed to opened in update mode, trying in read-only mode
../src/core/qgsmessagelog.cpp:29 : (logMessage) [1ms] 2019-12-03T09:58:26 OGR[1] Cannot open /pc6/pc6.shp.()
../src/core/providers/ogr/qgsogrconnpool.cpp:39 : (QgsOgrConnPool) [0ms] Entering.
../src/core/providers/ogr/qgsogrconnpool.cpp:39 : (QgsOgrConnPool) [0ms] Leaving.
../src/core/qgsvectorlayer.cpp:1689 : (setDataProvider) [0ms] Instantiated the data provider plugin
../src/core/qgsvectorlayer.cpp:1694 : (setDataProvider) [0ms] Invalid provider plugin /pc6/pc6.shp
../src/core/qgsvectorlayer.cpp:1495 : (readXml) [1ms] Could not set data provider for layer /pc6/pc6.shp
../src/core/qgsvectorlayer.cpp:2096 : (readSymbology) [1ms] contextproject:layers:pc6_fcafc551_9302_452d_acf0_84cb41b2cda9:fieldaliases source ID
../src/core/qgsvectorlayer.cpp:2102 : (readSymbology) [0ms] field ID origalias  trans·
../src/core/qgsvectorlayer.cpp:2096 : (readSymbology) [0ms] contextproject:layers:pc6_fcafc551_9302_452d_acf0_84cb41b2cda9:fieldaliases source POSTCODE
../src/core/qgsvectorlayer.cpp:2102 : (readSymbology) [0ms] field POSTCODE origalias  trans·
../src/core/qgsvectorlayer.cpp:2096 : (readSymbology) [0ms] contextproject:layers:pc6_fcafc551_9302_452d_acf0_84cb41b2cda9:fieldaliases source MULTIPARTS
../src/core/qgsvectorlayer.cpp:2102 : (readSymbology) [0ms] field MULTIPARTS origalias  trans·
../src/core/qgsvectorlayer.cpp:2096 : (readSymbology) [0ms] contextproject:layers:pc6_fcafc551_9302_452d_acf0_84cb41b2cda9:fieldaliases source ADRESLOCAT
../src/core/qgsvectorlayer.cpp:2102 : (readSymbology) [0ms] field ADRESLOCAT origalias  trans·
../src/core/qgsproject.cpp:1061 : (addLayer) [3ms] Unable to load vector layer
../src/core/qgsproject.cpp:1389 : (readProjectFile) [0ms] Unable to get map layers from project file.
../src/core/qgsproject.cpp:1393 : (readProjectFile) [0ms] there are 1 broken layers
../src/core/qgsmessagelog.cpp:29 : (logMessage) [3ms] 2019-12-03T09:58:26 Server[2] Layer(s) pc6_fcafc551_9302_452d_acf0_84cb41b2cda9 not valid
../src/core/qgsmessagelog.cpp:29 : (logMessage) [5ms] 2019-12-03T09:58:26 Server[0] <ServerException>Layer(s) not valid</ServerException>

@rduivenvoorde rduivenvoorde added Bug Either a bug report, or a bug fix. Let's hope for the latter! Server Related to QGIS server labels Dec 3, 2019
@rduivenvoorde
Copy link
Contributor Author

rduivenvoorde commented Dec 3, 2019

Ah found a clue myself....

IF instead of
FcgidInitialEnv QGIS_PROJECT_FILE "pc6project.qgz"
I use
FcgidInitialEnv QGIS_PROJECT_FILE "/usr/lib/cgi-bin/pc6project.qgz"
THEN the data is found...
(and off course I can also tick the checkbox 'use absolute paths' in the project file)

@elpaso is the cgi maybe not aware of it's place on the file system, if it is set relative (to the cgi)? So it cannot know that it should look for the data in /usr/lib/cgi-bin (or whatever folder you have the fcgi).

If that is the case then I think it should just not be possible to use a relative path for the QGIS_PROJECT_FILE anyway. Now it finds the project file, but cannot find the data
Else; maybe there is some logic missing?

@elpaso elpaso self-assigned this Jan 20, 2020
@elpaso
Copy link
Contributor

elpaso commented Jan 20, 2020

@rduivenvoorde you mention WFS3, but does it work with plain WMS/WFS? In other words is this specific to WFS3?

Regarding your question about cgi self-awareness, I think that it does not matter: the (relative) paths are all calculated relatively to the project path.

elpaso added a commit to elpaso/QGIS that referenced this issue Jan 20, 2020
Fixes qgis#33200 when (server) project was loaded from
the FCGI current directory with a relative path
or not path at all: the pathresolver assumed the
project file path was absolute, which wasn't the
case in this issue.

By forcing the project path to absolute, the
problem goes away.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Server Related to QGIS server
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants