Error 500 while parsing the XML of the project?
anthony-o opened this issue · 4 comments
I've created a qgis-server with the following docker command docker run -it --name qgis_server -v ${HOME}:/home/${USER} -v /tmp/.X11-unix:/tmp/.X11-unix -v /dev/shm:/dev/shm -e DISPLAY=unix$DISPLAY -e QGIS_PROJECT_FILE='' -e QGIS_LOG_FILE='/tmp/qgis.log' -e QGIS_SERVER_LOG_FILE='/tmp/qgis_server.log' -e QGIS_SERVER_LOG_LEVEL=0 -e QGIS_DEBUG=0 -p 8080:80 kartoza/qgis-server
Then I connect to the container (docker exec -it qgis_server bash
) and install the programs I will need to install qgis-atlasprint
: apt-get install vim unzip wget -y >/dev/null
.
Now I install qgis-atlasprint
following the documentation: wget "https://github.com/3liz/qgis-atlasprint/archive/master.zip" && unzip master.zip && mv qgis-atlasprint-master atlastprint && rm master.zip && service apache2 reload
.
Now I try to generate a PDF accessing to the following URL: http://localhost:8080/?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetPrintAtlas&TEMPLATE=Atlas&MAP=/dev/shm/myproject/myproject.qgs&FORMAT=pdf&DPI=300&EXP_FILTER=93
And the result page is a 500 Internal Server Error
and here is the log I can see in /tmp/qgis_server.log
:
[176][15:41:30] ******************** New request ***************
[176][15:41:30] REMOTE_ADDR: 172.17.0.1
[176][15:41:30] HTTP_USER_AGENT: Mozilla/5.0 (X11; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0
[176][15:41:30] inserting pair SERVICE // WMS into the parameter map
[176][15:41:30] inserting pair VERSION // 1.3.0 into the parameter map
[176][15:41:30] inserting pair REQUEST // GetPrintAtlas into the parameter map
[176][15:41:30] inserting pair TEMPLATE // Atlas into the parameter map
[176][15:41:30] inserting pair MAP // /dev/shm/myproject/myproject.qgs into the parameter map
[176][15:41:30] inserting pair FORMAT // pdf into the parameter map
[176][15:41:30] inserting pair DPI // 300 into the parameter map
[176][15:41:30] inserting pair EXP_FILTER // 93 into the parameter map
[176][15:41:30] formatString is: pdf
[176][15:41:30] DPI:300
[176][15:41:30] EXP_FILTER:93
[176][15:41:30] FORMAT:pdf
[176][15:41:30] MAP:/dev/shm/myproject/myproject.qgs
[176][15:41:30] REQUEST:GetPrintAtlas
[176][15:41:30] SERVICE:WMS
[176][15:41:30] TEMPLATE:Atlas
[176][15:41:30] VERSION:1.3.0
[176][15:41:30] Open the project file '/dev/shm/myproject/myproject.qgs'.
[176][15:41:30]
========================================================================
= WARNING: This project file was saved by a different version of QGIS. =
========================================================================
[176][15:41:30] QGIS server version 2.18.20, project version 2.18.19
[176][15:41:30] QgsMSLayerCache initialized
[176][15:41:30] Checking byte array is ok to set...
[176][15:41:30] Byte array looks good, setting response...
[176][15:41:30] warning:/usr/lib/python2.7/xml/etree/ElementTree.py:1638: DeprecationWarning: This method of XMLParser is deprecated. Define doctype() method on the TreeBuilder target.
DeprecationWarning,
traceback: File "/opt/qgis-server/plugins/atlastprint/filters/atlasprintFilter.py", line 142, in responseComplete
feature_filter=self.feature_filter
File "/opt/qgis-server/plugins/atlastprint/filters/atlasprintFilter.py", line 198, in print_atlas
tree = ET.parse(f)
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1182, in parse
tree.parse(source, parser)
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 656, in parse
parser.feed(data)
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1651, in feed
self._parser.Parse(data, 0)
File "/build/python2.7-dPs3Rr/python2.7-2.7.12/Modules/pyexpat.c", line 839, in DefaultHandlerExpand
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1622, in _default
self._XMLParser__doctype(name, pubid, system[1:-1])
Actually it doesn't seem to be a parse problem as I tried to avoid warnings following this commit on another project and now I don't have the warning anymore, don't have any more logs but still have the error 500.
with open(project_path, 'r') as f:
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
tree = ET.parse(f)
for elem in tree.findall('.//Composer[@title="%s"]' % composer_name):
Do you know where I could find some more complete logs to track down this problem?
Do you still have this issue?
Do you migrate to QGIS 3.4?
Do you still have this issue?
Do you migrate to QGIS 3.4?
I finally used QGIS running in a bash script rather than qgis-server: https://gis.stackexchange.com/a/289645/73088 & https://gis.stackexchange.com/a/289122/73088 (so perhaps this issue is still happening).
You error is about Composer
which has been removed in QGIS 3.0. It is now Layout
so it's a new XML structure. The code has changed also in this area of the code. Let's close this issue, feel free to reopen a ticket if you have another error.