Select to view content in your preferred language

ExportToJPEG crash with error on ArcGIS Server python

2067
17
10-30-2024 06:18 AM
mgeom
by
Emerging Contributor
Hello,
I'm trying to export a JPEG with a geoprocessing task running on an Arcgis server.
The ExportToJPEG line of code crashes with an error with ArcGIS Server python, but works fine with local ArcGIS Pro python.
I can't figure out what's wrong.
Here is the error:

Job Messages:

esriJobMessageTypeInformative: Submitted.
esriJobMessageTypeInformative: Executing...
esriJobMessageTypeError: Failed.
esriJobMessageTypeInformative: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: com.esri.arcgis.discovery.admin.rediscovery.util.ArcGISServiceException: Impossible de traiter la requête.

Here's a simple code test I did, it crashes at the last line:

 

import arcpy
aprx = arcpy.mp.ArcGISProject(r"D:\path\myAPRX.aprx")
layout = aprx.listLayouts('layout_name')[0]
mf = layout.listElements('MAPFRAME_ELEMENT', '*')[0]
extent = arcpy.Extent(446998.96875,  214866.71875, 446579.875, 215163.046875)
mf.camera.setExtent(extent)
mf.exportToPDF('path\out.jpg')

 

 

0 Kudos
17 Replies
CodyPatterson
MVP Regular Contributor

Hey @mgeom 

I'm wondering if you're using exportToPDF when you mean to use exportToJPEG:

 

import arcpy
aprx = arcpy.mp.ArcGISProject(r"D:\path\myAPRX.aprx")
layout = aprx.listLayouts('layout_name')[0]
mf = layout.listElements('MAPFRAME_ELEMENT', '*')[0]
extent = arcpy.Extent(446998.96875,  214866.71875, 446579.875, 215163.046875)
mf.camera.setExtent(extent)
mf.exportToJPEG('path\out.jpg')

 

Edit: Here is a link of someone else doing similar: https://community.esri.com/t5/arcgis-pro-questions/python-script-to-export-layout-to-jpg/td-p/111450...

Cody

0 Kudos
mgeom
by
Emerging Contributor

Hello,
Thank you for your quick feedback.

I made a small error in the code. But yes, I would like to export a jpg with ExportToJPEG

0 Kudos
MatthewDriscoll
MVP Alum

I would triple check all your paths.  I ran this on both 2.x and 3.x and it ran with no issue.  The only difference is I did it inside pro and used CURRENT for my path.

0 Kudos
mgeom
by
Emerging Contributor

Hello,
Thank you for your quick feedback.

I made a small error in the code. But yes, I would like to export a jpg with ExportToJPEG

0 Kudos
mgeom
by
Emerging Contributor

Any help please ?

It always chrashes at this level with error :  

java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: com.esri.arcgis.discovery.admin.rediscovery.util.ArcGISServiceException: Unable to process request.

mf.exportToJPEG('path\out.jpg')

 

Thanks

0 Kudos
CodyPatterson
MVP Regular Contributor

Hey @mgeom 

Sorry for the late response, could you try something like this:

mf.exportToJPEG('path\\out.jpg')

Where the \ is escaped?

Cody

0 Kudos
mgeom
by
Emerging Contributor

Hello @CodyPatterson 

Thank you for your answer

But it still doesn't work

I don't understand the origin of the error

0 Kudos
CodyPatterson
MVP Regular Contributor

Hey @mgeom 

Hmm that is quite strange, the error that mentions java is typically related to a java function failure which could be caused by really anything it doesn't like. Since the error is extremely non-descriptive, it is nearly impossible to tell what could be causing it.

A final thing I would try, is set your ArcGIS Server logging to info, and attempt to run the script again, when it errors out in this manner, attempt to observe the ArcGIS Server logs to see if there is anything of description there. If so, please attach a screenshot as I believe that a function on there may be failing.

Past this, I would recommend reaching out to ESRI support, as a larger problem may be present.

Cody

0 Kudos
mgeom
by
Emerging Contributor

I set the log level to 'info' as you indicate, but it doesn't give me much infos in the logs, just  very vague information

I will create a ticket at esri as you say

Thank you very much for your help

0 Kudos