Reading-eScience-Centre / edal-java

Environmental Data Abstraction Layer libraries
Other
39 stars 30 forks source link

NullPointerException in CdmDatasetFactory.processVectors #158

Open sharon-tickell opened 1 year ago

sharon-tickell commented 1 year ago

I'm working with the opendap/hyrax_ncwms:1.16.8 docker image, which includes a version of ncwms2 that uses edal-java v1.5.2.

When I request the ncWMS2 capabilities for a dynamic dataset that is an output from our oceanography model, I get a NullPointerException at the call to CdmDatasetFactory.processVectors. The log results look like:

hyrax_ncwms  | uk.ac.rdg.resc.edal.exceptions.EdalException: Problem creating dataset lds/path/to/out_simple.nc at http://localhost:8080/opendap//path/to/out_simple.nc
hyrax_ncwms  |  at uk.ac.rdg.resc.edal.dataset.cdm.CdmDatasetFactory.createDataset(CdmDatasetFactory.java:133)
hyrax_ncwms  |  at uk.ac.rdg.resc.edal.dataset.cdm.CdmDatasetFactory.createDataset(CdmDatasetFactory.java:81)
hyrax_ncwms  |  at uk.ac.rdg.resc.edal.dataset.cdm.CdmDatasetFactory.createDataset(CdmDatasetFactory.java:75)
hyrax_ncwms  |  at uk.ac.rdg.resc.edal.ncwms.NcwmsCatalogue.getDatasetFromId(NcwmsCatalogue.java:222)
hyrax_ncwms  |  at uk.ac.rdg.resc.edal.wms.WmsServlet.getCapabilities(WmsServlet.java:688)
hyrax_ncwms  |  at uk.ac.rdg.resc.edal.wms.WmsServlet.dispatchWmsRequest(WmsServlet.java:370)
hyrax_ncwms  |  at uk.ac.rdg.resc.edal.ncwms.NcwmsServlet.dispatchWmsRequest(NcwmsServlet.java:212)
hyrax_ncwms  |  at uk.ac.rdg.resc.edal.wms.WmsServlet.doGet(WmsServlet.java:303)
hyrax_ncwms  |  at javax.servlet.http.HttpServlet.service(HttpServlet.java:655)
hyrax_ncwms  |  at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
hyrax_ncwms  |  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
hyrax_ncwms  |  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
hyrax_ncwms  |  at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:168)
hyrax_ncwms  |  at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:233)
hyrax_ncwms  |  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
hyrax_ncwms  |  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
hyrax_ncwms  |  at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
hyrax_ncwms  |  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
hyrax_ncwms  |  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
hyrax_ncwms  |  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
hyrax_ncwms  |  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
hyrax_ncwms  |  at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
hyrax_ncwms  |  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
hyrax_ncwms  |  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
hyrax_ncwms  |  at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687)
hyrax_ncwms  |  at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:769)
hyrax_ncwms  |  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
hyrax_ncwms  |  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
hyrax_ncwms  |  at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
hyrax_ncwms  |  at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
hyrax_ncwms  |  at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
hyrax_ncwms  |  at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1789)
hyrax_ncwms  |  at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
hyrax_ncwms  |  at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
hyrax_ncwms  |  at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
hyrax_ncwms  |  at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
hyrax_ncwms  |  at java.base/java.lang.Thread.run(Thread.java:829)
hyrax_ncwms  | Caused by: java.lang.NullPointerException
hyrax_ncwms  |  at uk.ac.rdg.resc.edal.dataset.cdm.CdmDatasetFactory.processVectors(CdmDatasetFactory.java:308)
hyrax_ncwms  |  at uk.ac.rdg.resc.edal.dataset.cdm.CdmDatasetFactory.createDataset(CdmDatasetFactory.java:104)
hyrax_ncwms  |  ... 36 more

Investigations show that the exception is being generated at this line: https://github.com/Reading-eScience-Centre/edal-java/blob/4c9c334867e0c2bc64eaa7c2826c55a0dd0c25ff/cdm/src/main/java/uk/ac/rdg/resc/edal/dataset/cdm/CdmDatasetFactory.java#L308 because vectorInfo is quite properly null for any of the non-vector variables that loop has looked up vectorInfo for.

sharon-tickell commented 1 year ago

Submitted PR https://github.com/Reading-eScience-Centre/edal-java/pull/159 as a proposed fix for this issue