- - PR -
XMLデータベースeXistでサーブレット使用について
1
投稿者 | 投稿内容 |
---|---|
|
投稿日時: 2006-01-12 15:38
eXistを利用してサーブレットからxmlドキュメントの格納したいのですができません。
eXist内のドキュメントをInputStreamでキャッチしてREST-Style APIを利用して格納しています。 import java.io.*; import java.net.*; import org.xmldb.api.*; import org.xmldb.api.base.*; import org.xmldb.api.modules.*; import org.exist.http.RESTServer; import org.exist.xmldb.*; import org.exist.xmlrpc.*; import javax.servlet.*; import javax.servlet.http.*; public class TestStoreDb extends HttpServlet { public void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ String docName = "TestAsahi"; try { URL geturl = new URL("http://admin:@localhost:8080/eXist/servlet/db/asahi1221.xml"); InputStream in = geturl.openStream(); URL url = new URL("http://admin:@localhost:8080/eXist/servlet/db/data2/Asahi/"+ docName); HttpURLConnection connect =(HttpURLConnection)url.openConnection(); connect.setRequestMethod("PUT"); connect.setDoOutput(true); connect.setRequestProperty("ContentType", "text/xml"); OutputStream os = connect.getOutputStream(); byte[] buf =new byte[1024]; int c; while((c = in.read(buf)) > -1){ os.write(buf, 0, c);} connect.connect(); } catch (Exception e) { e.printStackTrace(); } } } eXistの紹介しているページも少なくて、困っています。 サーブレットからの格納方法を教えていただきたいのです。 よろしくお願いします。 |
|
投稿日時: 2006-01-12 16:37
2.3. PUT Requests
http://exist.sourceforge.net/devguide.html#N102CB の 例との比較では con.putheader('Content-Length', `clen`) とかに相当するものもいるのでは |
|
投稿日時: 2006-01-12 17:02
>2.3. PUT Requests
>http://exist.sourceforge.net/devguide.html#N102CB >の 例との比較では >con.putheader('Content-Length', `clen`) >とかに相当するものもいるのでは 2.3. PUT Requests http://exist.sourceforge.net/devguide.html#N102CB で紹介しているサンプルはpythonで書かれたもので、私はjavaで書いているので異なります。 私が書いたjavaプログラムはアプリケーションなら動きました。 それをサーブレットに書き直してみると、動きませんでした。 eXistのlogを見てみるとエラーが出ていたのですが、解決方法がわからないのです。 ERROR (2006-01-12) 13:45.18:687 [sitemap.transformer.xinclude] (/eXist/index.xml) http-8080-Processor25/XIncludeTransformer.XIncludePipe: Error processing an xInclude, will try to use fallback. java.net.ConnectException: Connection timed out: connect at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection$6.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) at org.apache.excalibur.source.impl.URLSource.getInputStream(URLSource.java:252) at org.apache.cocoon.components.source.SourceUtil.toSAX(SourceUtil.java:156) at org.apache.cocoon.components.source.SourceUtil.toSAX(SourceUtil.java:96) at org.apache.cocoon.transformation.XIncludeTransformer$XIncludePipe.processXIncludeElement(XIncludeTransformer.java:393) at org.apache.cocoon.transformation.XIncludeTransformer$XIncludePipe.startElement(XIncludeTransformer.java:182) at org.apache.cocoon.xml.AbstractXMLPipe.startElement(AbstractXMLPipe.java:95) at org.apache.cocoon.components.sax.XMLTeePipe.startElement(XMLTeePipe.java:83) at org.apache.cocoon.components.sax.XMLByteStreamInterpreter.parse(XMLByteStreamInterpreter.java:97) at org.apache.cocoon.components.sax.XMLByteStreamInterpreter.deserialize(XMLByteStreamInterpreter.java:73) at org.apache.cocoon.components.pipeline.impl.AbstractCachingProcessingPipeline.processXMLPipeline(AbstractCachingProcessingPipeline.java:257) at org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.process(AbstractProcessingPipeline.java:490) at org.apache.cocoon.components.treeprocessor.sitemap.SerializeNode.invoke(SerializeNode.java:120) at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:49) at org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:130) at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:72) at org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:126) at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:72) at org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:101) at org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:336) at org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:277) at org.apache.cocoon.Cocoon.process(Cocoon.java:639) at org.apache.cocoon.servlet.CocoonServlet.service(CocoonServlet.java:1098) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Unknown Source) Caused by: java.net.ConnectException: Connection timed out: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(Unknown Source) at java.net.PlainSocketImpl.connectToAddress(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at sun.net.NetworkClient.doConnect(Unknown Source) at sun.net.www.http.HttpClient.openServer(Unknown Source) at sun.net.www.http.HttpClient.openServer(Unknown Source) at sun.net.www.http.HttpClient.<init>(Unknown Source) at sun.net.www.http.HttpClient.New(Unknown Source) at sun.net.www.http.HttpClient.New(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(Unknown Source) at java.net.HttpURLConnection.getHeaderFieldDate(Unknown Source) at java.net.URLConnection.getLastModified(Unknown Source) at org.apache.excalibur.source.impl.URLSource.getInfos(URLSource.java:160) at org.apache.excalibur.source.impl.AbstractSource.checkInfos(AbstractSource.java:58) at org.apache.excalibur.source.impl.URLSource.getInputStream(URLSource.java:195) ... 36 more |
1