NCEAS / metacat

Data repository software that helps researchers preserve, share, and discover data
https://knb.ecoinformatics.org/software/metacat
GNU General Public License v2.0
28 stars 13 forks source link

Objects without format id cause the failure of /v2/object #1708

Open taojing2002 opened 1 year ago

taojing2002 commented 1 year ago

After we creating objects without format id (format id is blank), the call to /v2/object fails. The error message in the metacat log is:

metacat 20231001-12:03:12: [ERROR]: class org.dataone.exceptions.MarshallingException: null [edu.ucsb.nceas.metacat.restservice.v2.MNResourceHandler:handle:551]
org.dataone.exceptions.MarshallingException: null
    at org.dataone.service.util.TypeMarshaller.marshalTypeToOutputStream(TypeMarshaller.java:232) ~[d1_common_java-2.3.0.jar:?]
    at org.dataone.service.util.TypeMarshaller.marshalTypeToOutputStream(TypeMarshaller.java:202) ~[d1_common_java-2.3.0.jar:?]
    at edu.ucsb.nceas.metacat.restservice.v2.MNResourceHandler.getObject(MNResourceHandler.java:1509) ~[metacat.jar:?]
    at edu.ucsb.nceas.metacat.restservice.v2.MNResourceHandler.handle(MNResourceHandler.java:294) [metacat.jar:?]
    at edu.ucsb.nceas.metacat.restservice.D1RestServlet.doGet(D1RestServlet.java:86) [metacat.jar:?]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:655) [servlet-api.jar:?]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) [servlet-api.jar:?]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) [catalina.jar:8.5.73]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.73]
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-websocket.jar:8.5.73]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.73]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.73]
    at edu.ucsb.nceas.metacat.restservice.D1URLFilter.doFilter(D1URLFilter.java:54) [metacat.jar:?]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.73]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.73]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:196) [catalina.jar:8.5.73]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) [catalina.jar:8.5.73]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542) [catalina.jar:8.5.73]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) [catalina.jar:8.5.73]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) [catalina.jar:8.5.73]
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:698) [catalina.jar:8.5.73]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) [catalina.jar:8.5.73]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:364) [catalina.jar:8.5.73]
    at org.apache.coyote.ajp.AjpProcessor.service(AjpProcessor.java:526) [tomcat-coyote.jar:8.5.73]
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-coyote.jar:8.5.73]
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:831) [tomcat-coyote.jar:8.5.73]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1673) [tomcat-coyote.jar:8.5.73]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-coyote.jar:8.5.73]
    at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) [tomcat-util.jar:8.5.73]
    at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) [tomcat-util.jar:8.5.73]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.5.73]
    at java.lang.Thread.run(Thread.java:750) [?:1.8.0_351]
Caused by: javax.xml.bind.MarshalException
    at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:311) ~[?:1.8.0_351]
    at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:236) ~[?:1.8.0_351]
    at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:95) ~[?:1.8.0_351]
    at org.dataone.service.util.TypeMarshaller.marshalTypeToOutputStream(TypeMarshaller.java:229) ~[d1_common_java-2.3.0.jar:?]
    ... 31 more
Caused by: com.sun.istack.internal.SAXException2: Object must have some value in its @XmlValue field: org.dataone.service.types.v1.ObjectFormatIdentifier@0
    at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:232) ~[?:1.8.0_351]
    at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:247) ~[?:1.8.0_351]
    at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:355) ~[?:1.8.0_351]
    at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:681) ~[?:1.8.0_351]
    at com.sun.xml.internal.bind.v2.runtime.property.ArrayElementNodeProperty.serializeItem(ArrayElementNodeProperty.java:54) ~[?:1.8.0_351]
    at com.sun.xml.internal.bind.v2.runtime.property.ArrayElementProperty.serializeListBody(ArrayElementProperty.java:157) ~[?:1.8.0_351]
    at com.sun.xml.internal.bind.v2.runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:144) ~[?:1.8.0_351]
    at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:345) ~[?:1.8.0_351]
    at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsSoleContent(XMLSerializer.java:578) ~[?:1.8.0_351]
    at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:326) ~[?:1.8.0_351]
    at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:479) ~[?:1.8.0_351]
    at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:308) ~[?:1.8.0_351]
    at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:236) ~[?:1.8.0_351]
    at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:95) ~[?:1.8.0_351]
    at org.dataone.service.util.TypeMarshaller.marshalTypeToOutputStream(TypeMarshaller.java:229) ~[d1_common_java-2.3.0.jar:?]
    ... 31 more
Caused by: com.sun.xml.internal.bind.api.AccessorException: Object must have some value in its @XmlValue field: org.dataone.service.types.v1.ObjectFormatIdentifier@0
    at com.sun.xml.internal.bind.v2.model.impl.RuntimeClassInfoImpl$TransducerImpl.writeLeafElement(RuntimeClassInfoImpl.java:395) ~[?:1.8.0_351]
    at com.sun.xml.internal.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.writeLeafElement(TransducedAccessor.java:239) ~[?:1.8.0_351]
    at com.sun.xml.internal.bind.v2.runtime.property.SingleElementLeafProperty.serializeBody(SingleElementLeafProperty.java:115) ~[?:1.8.0_351]
    at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:345) ~[?:1.8.0_351]
    at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:681) ~[?:1.8.0_351]
    at com.sun.xml.internal.bind.v2.runtime.property.ArrayElementNodeProperty.serializeItem(ArrayElementNodeProperty.java:54) ~[?:1.8.0_351]
    at com.sun.xml.internal.bind.v2.runtime.property.ArrayElementProperty.serializeListBody(ArrayElementProperty.java:157) ~[?:1.8.0_351]
    at com.sun.xml.internal.bind.v2.runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:144) ~[?:1.8.0_351]
    at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:345) ~[?:1.8.0_351]
    at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsSoleContent(XMLSerializer.java:578) ~[?:1.8.0_351]
    at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:326) ~[?:1.8.0_351]
    at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:479) ~[?:1.8.0_351]
    at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:308) ~[?:1.8.0_351]
    at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:236) ~[?:1.8.0_351]
    at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:95) ~[?:1.8.0_351]
    at org.dataone.service.util.TypeMarshaller.marshalTypeToOutputStream(TypeMarshaller.java:229) ~[d1_common_java-2.3.0.jar:?]
    ... 31 more
metacat 20231001-12:03:13: [ERROR]: D1ResourceHandler: Serializing exception with code 500: null [edu.ucsb.nceas.metacat.restservice.D1ResourceHandler:serializeException:591]
org.dataone.service.exceptions.ServiceFailure: null
    at edu.ucsb.nceas.metacat.restservice.v2.MNResourceHandler.handle(MNResourceHandler.java:558) [metacat.jar:?]
    at edu.ucsb.nceas.metacat.restservice.D1RestServlet.doGet(D1RestServlet.java:86) [metacat.jar:?]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:655) [servlet-api.jar:?]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) [servlet-api.jar:?]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) [catalina.jar:8.5.73]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.73]
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-websocket.jar:8.5.73]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.73]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.73]
    at edu.ucsb.nceas.metacat.restservice.D1URLFilter.doFilter(D1URLFilter.java:54) [metacat.jar:?]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.73]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.73]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:196) [catalina.jar:8.5.73]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) [catalina.jar:8.5.73]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542) [catalina.jar:8.5.73]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) [catalina.jar:8.5.73]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) [catalina.jar:8.5.73]
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:698) [catalina.jar:8.5.73]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) [catalina.jar:8.5.73]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:364) [catalina.jar:8.5.73]
    at org.apache.coyote.ajp.AjpProcessor.service(AjpProcessor.java:526) [tomcat-coyote.jar:8.5.73]
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-coyote.jar:8.5.73]
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:831) [tomcat-coyote.jar:8.5.73]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1673) [tomcat-coyote.jar:8.5.73]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-coyote.jar:8.5.73]
    at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) [tomcat-util.jar:8.5.73]
    at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) [tomcat-util.jar:8.5.73]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.5.73]
    at java.lang.Thread.run(Thread.java:750) [?:1.8.0_351]
taojing2002 commented 1 year ago

in the system meta schema, the format id is required:

<xs:element name="formatId" type="d1:ObjectFormatIdentifier">

And ObjectFormatIdentifier should be a none-empty string:

<xs:simpleType name="ObjectFormatIdentifier">
    <xs:annotation>
      <xs:documentation>A string used to identify an instance of
      :class:`Types.ObjectFormat` and MUST be unique within an instance of
      :class:`Types.ObjectFormatList`. </xs:documentation>
    </xs:annotation>
    <xs:restriction base="d1:NonEmptyString"></xs:restriction>
  </xs:simpleType>

So the create/update method should prevent the objects with blank value in object format identifier in the first place.