tsgrp / OpenAnnotate

TSG's Browser-based Annotation Tool
8 stars 4 forks source link

Error Loading/Saving Annotations on .png images using DCTM #805

Closed DuncanKummer closed 4 years ago

DuncanKummer commented 4 years ago

Open an image (.png) in AEV, immediately met with an "Error Loading Annotations Dialog"

image accompanied by this in tomcat:

2020-10-01 11:32:27,631 http-nio-8080-exec-9    ERROR   RESTService     Error occured parsing XFDF documents for annotations.
com.tsgrp.opencontent.core.exception.OCRuntimeException: Error occured parsing XFDF documents for annotations.
        at com.tsgrp.opencontent.universal.annotation.AbstractXFDFAnnotationImpl.getAnnotations(AbstractXFDFAnnotationImpl.java:914) ~[oc-hpiDemoDctm.3.universal-3.4.0.jar:3.4.0]
        at sun.reflect.GeneratedMethodAccessor169.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_261]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_261]
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) ~[spring-aop-5.1.1.RELEASE.jar:5.1.1.RELEASE]
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:206) ~[spring-aop-5.1.1.RELEASE.jar:5.1.1.RELEASE]
        at com.sun.proxy.$Proxy97.getAnnotations(Unknown Source) ~[?:?]
        at com.tsgrp.opencontent.universal.annotation.RESTAnnotation.getAnnotations(RESTAnnotation.java:182) ~[oc-hpiDemoDctm.3.universal-3.4.0.jar:3.4.0]
        at sun.reflect.GeneratedMethodAccessor168.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_261]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_261]
        at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:207) ~[spring-web-5.1.1.RELEASE.jar:5.1.1.RELEASE]
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) ~[spring-web-5.1.1.RELEASE.jar:5.1.1.RELEASE]
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102) ~[spring-webmvc-5.1.1.RELEASE.jar:5.1.1.RELEASE]
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.1.1.RELEASE.jar:5.1.1.RELEASE]
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:800) ~[spring-webmvc-5.1.1.RELEASE.jar:5.1.1.RELEASE]
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.1.1.RELEASE.jar:5.1.1.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038) [spring-webmvc-5.1.1.RELEASE.jar:5.1.1.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942) [spring-webmvc-5.1.1.RELEASE.jar:5.1.1.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:998) [spring-webmvc-5.1.1.RELEASE.jar:5.1.1.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:890) [spring-webmvc-5.1.1.RELEASE.jar:5.1.1.RELEASE]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:634) [servlet-api.jar:?]
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:875) [spring-webmvc-5.1.1.RELEASE.jar:5.1.1.RELEASE]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) [servlet-api.jar:?]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) [catalina.jar:8.5.45]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.45]
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-websocket.jar:8.5.45]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.45]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.45]
        at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:109) [catalina.jar:8.5.45]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.45]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.45]
        at com.tsgrp.opencontent.rest.filter.OCTimingFilter.doFilterInternal(OCTimingFilter.java:83) [oc-hpiDemoDctm.1.core-3.4.0.jar:3.4.0]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.1.1.RELEASE.jar:5.1.1.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.45]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.45]
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) [catalina.jar:8.5.45]
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [catalina.jar:8.5.45]
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:528) [catalina.jar:8.5.45]
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) [catalina.jar:8.5.45]
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) [catalina.jar:8.5.45]
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678) [catalina.jar:8.5.45]
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [catalina.jar:8.5.45]
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) [catalina.jar:8.5.45]
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798) [tomcat-coyote.jar:8.5.45]
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-coyote.jar:8.5.45]
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:810) [tomcat-coyote.jar:8.5.45]
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498) [tomcat-coyote.jar:8.5.45]
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-coyote.jar:8.5.45]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_261]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_261]
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.5.45]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_261]
Caused by: com.tsgrp.opencontent.core.exception.OCRuntimeException: Error occured parsing embedded annotations.
        at com.tsgrp.opencontent.universal.annotation.AbstractXFDFAnnotationImpl.getEmbeddedAnnotations(AbstractXFDFAnnotationImpl.java:1045) ~[oc-hpiDemoDctm.3.universal-3.4.0.jar:3.4.0]
        at com.tsgrp.opencontent.universal.annotation.AbstractXFDFAnnotationImpl.getAnnotations(AbstractXFDFAnnotationImpl.java:902) ~[oc-hpiDemoDctm.3.universal-3.4.0.jar:3.4.0]
        ... 52 more
Caused by: java.lang.NullPointerException
        at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:2314) ~[commons-io-2.6.jar:2.6]
        at org.apache.commons.io.IOUtils.copy(IOUtils.java:2270) ~[commons-io-2.6.jar:2.6]
        at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:2291) ~[commons-io-2.6.jar:2.6]
        at org.apache.commons.io.IOUtils.copy(IOUtils.java:2246) ~[commons-io-2.6.jar:2.6]
        at org.apache.commons.io.IOUtils.toByteArray(IOUtils.java:765) ~[commons-io-2.6.jar:2.6]
        at com.tsgrp.opencontent.core.cache.EhCacheImpl.getContentFromRepo(EhCacheImpl.java:102) ~[oc-hpiDemoDctm.1.core-3.4.0.jar:3.4.0]
        at com.tsgrp.opencontent.core.cache.EhCacheImpl.getContent(EhCacheImpl.java:76) ~[oc-hpiDemoDctm.1.core-3.4.0.jar:3.4.0]
        at sun.reflect.GeneratedMethodAccessor226.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_261]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_261]
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) ~[spring-aop-5.1.1.RELEASE.jar:5.1.1.RELEASE]
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) ~[spring-aop-5.1.1.RELEASE.jar:5.1.1.RELEASE]
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.1.1.RELEASE.jar:5.1.1.RELEASE]
        at org.springframework.cache.interceptor.CacheInterceptor.lambda$invoke$0(CacheInterceptor.java:53) ~[spring-context-5.1.1.RELEASE.jar:5.1.1.RELEASE]
        at org.springframework.cache.interceptor.CacheAspectSupport.invokeOperation(CacheAspectSupport.java:365) ~[spring-context-5.1.1.RELEASE.jar:5.1.1.RELEASE]
        at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:420) ~[spring-context-5.1.1.RELEASE.jar:5.1.1.RELEASE]
        at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:345) ~[spring-context-5.1.1.RELEASE.jar:5.1.1.RELEASE]
        at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:61) ~[spring-context-5.1.1.RELEASE.jar:5.1.1.RELEASE]
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.1.RELEASE.jar:5.1.1.RELEASE]
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.1.1.RELEASE.jar:5.1.1.RELEASE]
        at com.sun.proxy.$Proxy84.getContent(Unknown Source) ~[?:?]
        at com.tsgrp.opencontent.universal.annotation.AbstractXFDFAnnotationImpl.getEmbeddedAnnotations(AbstractXFDFAnnotationImpl.java:1001) ~[oc-hpiDemoDctm.3.universal-3.4.0.jar:3.4.0]
        at com.tsgrp.opencontent.universal.annotation.AbstractXFDFAnnotationImpl.getAnnotations(AbstractXFDFAnnotationImpl.java:902) ~[oc-hpiDemoDctm.3.universal-3.4.0.jar:3.4.0]
        ... 52 more

AEV won't save any new annotations you add either:

ImageAnnotationFail

DuncanKummer commented 4 years ago

Commit #: 7055 CRs: jlittle, dvora

Description: Images were failing to load due to an erroneous call to getEmbeddedAnnotations. PDFs support embedded annotations due to their design, unlike non-PDF filetypes like PNGs or JPGs. The code wasn't correctly detecting if the current document was a PDF or not, and was calling getEmbeddedAnnotations every time. Fixed this by refactoring a conditional for functionality and readability!