- PR -

XindiceのXUpdateがうまくできない

1
投稿者投稿内容
Tam
会議室デビュー日: 2002/11/27
投稿数: 4
投稿日時: 2004-01-20 17:18
XindiceでのXupdateがうまくいきません。

この掲示板で以前、議論されていた
http://www.atmarkit.co.jp/bbs/phpBB/viewtopic.php?topic=5174&forum=9&13
を参考にして、XUpdateのプログラムを作成したのですが、うまく動きません。

おくちんさんの2003/8/29の投稿を参考にさせていただいて1)〜3)までは行いました。

作成したプログラムを実行すると、
以下のようなエラーコードが出ます。

org.apache.xindice.client.corba.db.APIException: IDL:org/apache/xindice/client/c
orba/db/APIException:1.0
at org.apache.xindice.client.corba.db.APIExceptionHelper.read(APIExcepti
onHelper.java:112)
at org.apache.xindice.client.corba.db._CollectionStub.queryCollection(_C
ollectionStub.java:833)
at org.apache.xindice.client.xmldb.services.XUpdateQueryServiceImpl.upda
teResult(XUpdateQueryServiceImpl.java:165)
at org.apache.xindice.client.xmldb.services.XUpdateQueryServiceImpl.upda
te(XUpdateQueryServiceImpl.java:185)
at xupdate.main(xupdate.java:39)

XML:DB Exception occured 1

(読みにくくてすいません。)

プログラムは、
import java.io.*;
import java.lang.*;

import org.xmldb.api.base.*;
import org.xmldb.api.modules.*;
import org.xmldb.api.*;
import org.w3c.dom.*;
import org.apache.xerces.parsers.DOMParser;
import org.apache.xindice.client.xmldb.services.*;

public class xupdate{

public static void main(String[] args)throws org.xmldb.api.base.XMLDBException {

org.xmldb.api.base.Collection col = null;

try{

// Database実装クラスの登録
String driver= "org.apache.xindice.client.xmldb.DatabaseImpl";
Class c = Class.forName(driver);
Database database = (Database)c.newInstance();
DatabaseManager.registerDatabase(database);

// コレクションの取得
col = DatabaseManager.getCollection("xmldb:xindice:///db/testcol");

//ここからXUpdate

XUpdateQueryService service = (XUpdateQueryService)col.getService("XUpdateQueryService","1.0");

org.apache.xindice.client.xmldb.services.XUpdateQueryServiceImpl serviceImpl = (org.apache.xindice.client.xmldb.services.XUpdateQueryServiceImpl)service;

     String xupdate = "<xupdate:modificationsversion=\"1.0\""
 + "xmlns:xupdate=\"http://www.xmldb.org/xupdate\">"
+ "<xupdate:update select=\"//problem [id=\"ID0001\"]/@status\">abcd</xupdate:update>"
+ "</xupdate:modifications>";

long num = service.update(xupdate);

}
catch (XMLDBException e) {
System.err.println("XML:DB Exception occured " + e.errorCode);
}
catch (Exception e) {
e.printStackTrace();
}
finally {
if (col != null) {
// コレクションのクローズ
col.close();
}

}


}

}

です。

環境は

Windows2000
JDK 1.4.1_05
Xindice 1.0
xerces-1.4.4.jar
xalan-2.0.1.jar

です。

どなたか、どうすればうまく動くのか教えていただけないでしょうか?
よろしくお願いします。
おくちん
会議室デビュー日: 2003/08/29
投稿数: 11
投稿日時: 2004-01-20 19:09
はじめまして、おくちんといいます。

Tamさんが作られたプログラムを自分の環境でも実行したところ同じ
エラーがでました。どうも

------------------------------------------------------

String xupdate = "<xupdate:modificationsversion=\"1.0\""
 + "xmlns:xupdate=\"http://www.xmldb.org/xupdate\">"
+ "<xupdate:update select=\"//problem [id=\"ID0001\"]/@status\">abcd</xupdate:update>"
+ "</xupdate:modifications>";

------------------------------------------------------
の部分の書き間違いのようです。改善したとこは
ます1つ目は
modificationsとversionがくっついている −>はなす
2つ目は
"1.0"とxmlnsがくっついている −>はなす
3つ目は
idの前に@がない −>付け加える
4つ目は
"ID0001"ではなく'ID0001'である −>書き直す

というとこです。この4つを書き直したらきちんと実行することができました。
参考になれば幸いです。

おくちん
会議室デビュー日: 2003/08/29
投稿数: 11
投稿日時: 2004-01-20 19:11
すいません、なぜか同じ返信を2度送っておりました。
申し訳ありません。

[ メッセージ編集済み 編集者: おくちん 編集日時 2004-01-20 19:13 ]
Tam
会議室デビュー日: 2002/11/27
投稿数: 4
投稿日時: 2004-01-21 09:10
おくちんさん、丁寧に教えていただきありがとうございます。

早速おくちんさんの指摘どおりに変更して実行してみたのですが、
結局同じエラーがでました。

しかし、もう一度他の部分(設定とか)が間違っていないか確認したところ、

startup.batに
-Djava.endorsed.dirs=%XINDICE_HOME%\java\lib\endorsed
を付け加えるところで、
"dirs"が"dir"になっていました。
それを修正したらうまく動きました。

何日かこれが動かなくて悩んでたので、動いたときは少し感動しました。
このたびはどうもありがとうございました。
1

スキルアップ/キャリアアップ(JOB@IT)