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

java.lang.NoClassDefFoundError: org/geotools/api/geometry/Position #3155

Open
billyz313 opened this issue Jan 9, 2024 · 8 comments
Open

Comments

@billyz313
Copy link

billyz313 commented Jan 9, 2024

Context

  • geoserver-2.21.2-printing-plugin:
  • Java version: openjdk version "11.0.20.1" 2023-08-24
  • OS: lunux

Describe the bug
I am trying to create a pdf and it returns the error:

Error: 500 - Error while generating PDF:
java.lang.NoClassDefFoundError: org/geotools/api/geometry/Position
	at org.mapfish.print.config.layout.MapBlock.createTransformer(MapBlock.java:173)
	at org.mapfish.print.config.layout.MapBlock.render(MapBlock.java:64)
	at org.mapfish.print.config.layout.Page.render(Page.java:79)
	at org.mapfish.print.config.layout.Layout.render(Layout.java:64)
	at org.mapfish.print.output.AbstractOutputFormat.doPrint(AbstractOutputFormat.java:31)
	at org.mapfish.print.output.PdfOutputFactory.print(PdfOutputFactory.java:58)
	at org.mapfish.print.MapPrinter.print(MapPrinter.java:177)
	at org.mapfish.print.servlet.MapPrinterServlet.doCreatePDFFile(MapPrinterServlet.java:386)
	at org.mapfish.print.servlet.MapPrinterServlet.createAndGetPDF(MapPrinterServlet.java:168)
	at org.mapfish.print.servlet.MapPrinterServlet.doGet(MapPrinterServlet.java:99)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:670)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:779)
	at org.springframework.web.servlet.mvc.ServletWrappingController.handleRequestInternal(ServletWrappingController.java:166)
	at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:177)
	at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:52)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1043)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:670)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:779)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)

How to reproduce

here is the code i am using to call the generation of the pdf:


import requests
import json


print_url = "https://esa-rdst-data.servirglobal.net/geoserver/pdf/print.pdf"

template_name = "A4 portrait"

layer_name = "NDVI:modis.dekadal.20000311.tif"

print_spec = {
        "dpi":"300",
        "units":"degrees",
        "srs":"EPSG:4326",
        "pages": [{"mapTitle": "BillyZ's Map", "center":[3875254.1134954,3680894.557955],"scale":25000.0,"rotation":0}],
        "layout": template_name,
        "outputFormat": "pdf",
        "attributes": {
            "map": {
                "center": {"x": 0, "y": 0},
                "scale": 50000,
                "layers": [{"base": True, "name": layer_name}]
            }
        }
    
}

print_spec_json = json.dumps(print_spec)

full_url = f"{print_url}?spec={print_spec_json}"

response = requests.get(full_url)

if response.status_code == 200:
    with open("output.pdf", "wb") as pdf_file:
        pdf_file.write(response.content)
    print("PDF generated successfully.")
else:
    print(f"Error: {response.status_code} - {response.text}")
  

Expected results

Just a pdf containing the layer I requested.

@sbrunner
Copy link
Member

Looks to be an integration issue, you should open an issue on geoserver-printing-plugin...

@billyz313
Copy link
Author

@sbrunner Where would I do that? The only documentation i find sends me here.

@pmauduit
Copy link
Contributor

the geoserver printing plugin seems to use mapfishprint v2.3.0, which uses geotools 30.0:
https://github.com/mapfish/mapfish-print-v2/blob/release/2.3.0/pom.xml#L43

the geotools version being used in geoserver 2.24.1 is the v30.1:
https://github.com/geoserver/geoserver/blob/2.24.1/src/pom.xml#L92

I guess it could deserve an issue on geoserver's JIRA:
https://osgeo-org.atlassian.net/projects/GEOS/summary

@billyz313
Copy link
Author

@pmauduit I actually had a typo in the original post, i am using
geoserver 2.21.2 and the geoserver-2.21.2-printing-plugin. I am not sure which version of mapfish geoserver-2.21.2-printing-plugin is using to confirm if the geotools match, but i'm guessing they don't. Do you know a way to confirm?

@pmauduit
Copy link
Contributor

Do you know a way to confirm?

What I did to write my previous comment was to download the official GS release you mentioned, check in the WAR file for gt-* files under WEB-INF/lib, doing the same for the print plugin.

For 2.21.2, we can find a print-lib-2.1.5.jar in the plugin zip file ; from the mfprint sources it sounds that it relies on a pretty old version of GT (8.6):
https://github.com/mapfish/mapfish-print/blob/release/2.1.5/build.gradle#L49-L50

And the geoserver 2.21.2 comes with geotools 27.2:
https://github.com/geoserver/geoserver/blob/2.21.2/src/pom.xml#L92

I'd assume that both GT versions are too far from each other to be compatible.

@billyz313
Copy link
Author

@pmauduit thank you, it seems like they mismatched the plugin version with the geoserver version somehow. This is not what i was hoping for... I downloaded older versions of the plugin and they all are using print-lib-2.1.5 so i guess my only option is to upgrade geoserver to 2.24.0 and the 2.24.0 print plugin that I confirmed uses print-lib 2.3.0. Do you see any less invasive option?

@pmauduit
Copy link
Contributor

I downloaded older versions of the plugin

I'd have checked newer versions of the print plugin, instead of older ones, there are more chances to find an updated version of the print which would match the GT version being used in GS. but the risk is to use a version of the plugin which would be incompatible with your geoserver.

@billyz313
Copy link
Author

billyz313 commented Jan 10, 2024

@pmauduit I upgraded the plugin to geoserver-2.24.0-printing-plugin which uses print-lib-2.3.0 and I'm still getting the same exact error. I wasn't expecting it to necessarily work because it could be incompatible with geoserver, but I did figure it would not give me the same error. Any thoughts? I think my next step is to move forward on an upgrade of geoserver.

Also, I created an issue on the geoserver issues hopefully they can give guidance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants