openpreserve / scape-fcrepo4-connector

Connector API implementation on top of Fedora 4
Apache License 2.0
0 stars 0 forks source link

An exception when updating metadata #1

Open artourkin opened 10 years ago

artourkin commented 10 years ago

I am using the prepackaged war.

When I try to update metadata with the command (taken from the guide): $ curl -H "Content-Type:text/xml" -X PUT http://localhost:8080/fcrepo/rest/scape/metadata/entity-1/representation-1/file-1/bitstream-1/TECHNICAL -d 'dc:titlefoo/dc:title/dc:dublin-core'

I get the following exception:

javax.jcr.RepositoryException: java.io.FileNotFoundException: http://localhost:8080/rest/scape/file/entity-1/representation-1/file-1 at eu.scape_project.service.ConnectorService.addFiles(ConnectorService.java:650) at eu.scape_project.service.ConnectorService.addRepresentations(ConnectorService.java:780) at eu.scape_project.service.ConnectorService.updateEntity(ConnectorService.java:832) at eu.scape_project.service.ConnectorService.updateEntityMetadata(ConnectorService.java:1090) at eu.scape_project.service.ConnectorService.updateMetadata(ConnectorService.java:892) at eu.scape_project.resource.Metadata.updateMetadata(Metadata.java:90) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60) at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205) at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75) at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302) at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108) at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84) at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1511) at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1442) at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1391) at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1381) at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416) at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538) at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716) at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:534) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1081) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658) at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) Caused by: java.io.FileNotFoundException: http://localhost:8080/rest/scape/file/entity-1/representation-1/file-1 at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1834) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1439) at java.net.URL.openStream(URL.java:1038) at eu.scape_project.service.ConnectorService.addFiles(ConnectorService.java:644)

Running the fcrepo.war as root web-app didn't help. The REST endpoint is not available in this case.

fasseg commented 10 years ago

Hey Artur,

It seems to me that the whole file-1 object is missing. Did you create the file-1 and bitstream-1 object before updating the metadata? Can you try a HTTP GET to: http://localhost:8080/fcrepo/rest/scape/file/entity-1/representation-1/file-1 to check if the file exists?

artourkin commented 10 years ago

I use the entity_minimum.xml from the tests. So there is file-1 and bitstream-1. Also I can retrieve all the elements (entity, representation, file, bitstream, metadata) and run search queries. But I cannot update anything.

fasseg commented 10 years ago

Then I'll have to check and reproduce this. It's gonna take me a bit though since im currently preparing a talk for a Fedora User Group meeting tomorrow. I am not sure that I will find time to commit a fix and create a new WAR file before the weekend, but I'll try my best...

fasseg commented 10 years ago

I can reproduce this issue and am working on a fix

fasseg commented 10 years ago

The cause it seems is a wrong path with a "/fcrepo/" missing in the created file's URI. Will fix the path generation in the service

fasseg commented 10 years ago

The bug was caused by a wrong value in the configuration file scape-connector.xml. A fix was uploaded to master

artourkin commented 10 years ago

Great. Thanks! I close the issue

fasseg commented 10 years ago

@artourkin: Can you please confirm that the following sequence fixes the issue:

  1. Download scape-connector.xml from https://github.com/openplanets/scape-fcrepo4-connector/blob/master/src/main/resources/scape-connector.xml and make sure that the fedoraUrl Property is set to http://localhost:8080/fcrepo/rest (including the "fcrepo"-bit"
  2. Put the xml file in {TOMCAT_HOME}/fcrepo/webapps/WEB-INF/classes
  3. Change {TOMCAT_HOME}/fcrepo/webapps/WEB-INF/web.xml to:
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>WEB-INF/classes/spring/master.xml WEB-INF/classes/scape-connector.xml</param-value>
</context-param>

After that procedure, the update methods should work again.

fasseg commented 10 years ago

I'll keep the issue open until I rolled out a new WAR file..

artourkin commented 10 years ago

I have tried the sequence, but it didnot solve the problem.

First of all, I could not find master.xml in WEB-INF/classes/spring. There are the following files in that folder: screenshot from 2014-09-22 15 09 19

Secondly, there is scape.xml, which looks exactly the same as scape-connector.xml (except old fedoraUrl value), which you propose here as a solution. I changed the fedoraUrl Property to "http://localhost:8080/fcrepo/rest" but then there is an empty response from tomcat for any of my requests.

fasseg commented 10 years ago

I will bundle a new WAR file with the fixed configuration and upload it

fasseg commented 10 years ago

I bundled the Connector/Plan Management and Report API in a new Project at: https://github.com/fasseg/fcrepo4-scape I will verify the API features, and then report on this issue.

fasseg commented 10 years ago

The issue seems to be fixed for me with the new war bundle at: https://drive.google.com/file/d/0B5nd_qlYdcqyaXZZWVViYWlXajg/edit?usp=sharing build from https://github.com/fasseg/fcrepo4-scape

artourkin commented 10 years ago

Hi, I tried your new war package. Now there are even more issues:

  1. I cannot ingest an entity using curl -X POST http://localhost:8080/fcrepo/rest/scape/entity -d @entity-minimal.xml. I get an error report "HTTP Status 415 - Unsupported Media Type". However, asynchronous ingest works well.
  2. Updating medata works only for the first time. If I want to update it once more, i get an exception:

"java.lang.NullPointerException at eu.scape_project.service.ConnectorService.updateFileMetadata(ConnectorService.java:1250) at eu.scape_project.service.ConnectorService.updateMetadata(ConnectorService.java:858) at eu.scape_project.resource.connector.Metadata.updateMetadata(Metadata.java:97) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:151) at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:171) at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:152) at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:104) at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:387) at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:331) at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:103) at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:271) at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) at org.glassfish.jersey.internal.Errors.process(Errors.java:315) at org.glassfish.jersey.internal.Errors.process(Errors.java:297) at org.glassfish.jersey.internal.Errors.process(Errors.java:267) at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:297) at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:254) at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1030) at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:373) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:381) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:344) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:221) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:534) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1081) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658) at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745)"