problem with XUIDIterator

8 views
Skip to first unread message

dia...@free.fr

unread,
Feb 1, 2010, 11:45:46 AM2/1/10
to xam-develo...@googlegroups.com

Hi all,

I take the liberty of submitting you my problem, because I can't find anywere a
forum to do it.
the problem is :
when i execute the following codes :

results = sXSet.openXStream(XSet.XAM_JOB_QUERY_RESULTS, XSet.MODE_READ_ONLY);
List<XUID> xuids = new ArrayList<XUID>();
XUIDIterator iterator = new XUIDIterator(results);
int i = 1;
while (iterator.hasNext()) {
XUID xuid = (XUID)iterator.next();
xuids.add(xuid);
System.out.println("[" + i++ + "]" + "xuid = [" + xuid + "]");
}

I get the exception mentioned below on 'iterator.hasNext()':


org.snia.xam.InvalidXUIDException: byte[] too short 0
at org.snia.xam.util.XUIDIterator.hasNext(Unknown Source)


Your help will be appreciate

Thanks you in avance


Best regards
Diabate

Michael J. Allison

unread,
Feb 1, 2010, 12:23:51 PM2/1/10
to xam-develo...@googlegroups.com
It's hard to tell exactly what is happening. The XUID Iterator is trying to create an instance of a DefaultXUID class and apparently the passed in byte xuid values are too short (less than the minimum XUID length). This is difficult because you did not include the entire stack trace, but I think I know where it's broken.

Please answer the following questions:
* What VIM / XSystem are you using?
* How many iterations did the loop get through (i.e. what is the value of "i").
* This looks like you may be running Java 5 or later, but exactly what version?
* What OS is hosting the client?

Offhand it looks like an invalid XUID is being returned in the results.

Mike Allison

> --
> You received this message because you are subscribed to the "XAM Developers Group" group.
> To post to this group, send email to
> xam-develo...@googlegroups.com
> To unsubscribe from this group, send email to
> xam-developers-g...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/xam-developers-group?hl=en
> Reminder that due to the SNIA IP Policy, only bug reports can be accepted as feedback for the specification or code.

mdi

unread,
Feb 2, 2010, 5:52:54 AM2/2/10
to XAM Developers Group
Hi Mike,

1) I use the XAM HTTP VIM

2) There one iteration to loop as you can see on the log below :

Query[SELECT ".xset.xuid" WHERE "filename" like '%testDoc%']:
SUCCESS: <Create XSet>
SUCCESS: <Create Job Command Property>
SUCCESS: <Create Query Command XStream>
XStream Write
SUCCESS: <XSet SubmitJob>
Waiting until query is finished
Query job is completed!
XUID result set found = 1 *********
Open Query Results XStream

3) I use java 6

4) The client is hosting to a professionnal windows xp.


For your information, the same program of test work fine with the
Reference VIM.


best regards,
Diabate


On 1 fév, 18:23, "Michael J. Allison" <alliso...@sbcglobal.net> wrote:
> It's hard to tell exactly what is happening. The XUID Iterator is trying to create an instance of a DefaultXUID class and apparently the passed in byte xuid values are too short (less than the minimum XUID length). This is difficult because you did not include the entire stack trace, but I think I know where it's broken.
>
> Please answer the following questions:
>         * What VIM / XSystem are you using?
>         * How many iterations did the loop get through (i.e. what is the value of "i").
>         * This looks like you may be running Java 5 or later, but exactly what version?
>         * What OS is hosting the client?
>
> Offhand it looks like an invalid XUID is being returned in the results.
>
> Mike Allison
>

Michael J. Allison

unread,
Feb 2, 2010, 11:48:05 AM2/2/10
to xam-develo...@googlegroups.com
Hmmm, that code tested fine. Perhaps you could code it slightly differently to try and determine where the error is. I'd take the following approach:

Open the result XStream
Read 80 bytes from the stream
Build an XSet from it
Process your results

That's more or less what the XUID iterator does (it will also wait until the query job has results, but that's not important here). If that code works, the error is in the XUIDIterator. If this new code is unable to read all 80 bytes of the XUID, then error is probably in the HTTP VIM transport.

I'd also put in some debugging to show how long the result stream is. It should be exactly 80 bytes. If the result stream has less than 80 bytes, it's an error in the XAM System at the remote end (I assume it is the Reference VIM, but you didn't state what system is at the far end).

If you can reduce your test program to a small reproducible test case I can run it in my environment and see if I can get it to fail.

Mike A

mdi

unread,
Feb 3, 2010, 4:29:21 AM2/3/10
to XAM Developers Group
Hi Mike,

I am sorry but it's not possible to attach files to this area.
You can find below my test case. The superclass ExampleBase contain
the following methods : initLibrary(), connectToVIM(s_xri) and
authenticate(xsystem).


public class QueryExecutor extends ExampleBase {

private static XSet sXSet;
private static XStream sXStream;
private static XSystem xsystem;
private static final int BUFFER_SIZE = 80;


public static void main(String[] args) {

String query = "SELECT \".xset.xuid\" WHERE \"filename\" like
'%testDoc%'";

try {
// Have to init and load VIM since it's being run in this
JVM
initLibrary();

// Now do the client connect to the VIM
System.out.println("Client application connecting to the
VIM");
xsystem = connectToVIM(s_xri);

// Authenticate our user credentials
System.out.println("\nClient application authenticating
user credentials");
authenticate(xsystem);

System.out.print("Query[" + query + "]: ");

execQuery(query, true);

xsystem.close();
System.out.println("\nClosed connection to XSystem (" + s_xri
+ ")");

} catch (Exception ex) {
ex.printStackTrace();
}finally{
System.exit(0);
}
}


private static void execQuery(String query, boolean wait) throws
Exception {

XSet xSet = QueryFactory.Query( xsystem, query );

if (wait) {
System.out.println("Waiting until query is finished");
checkQuery();
}

sXSet.close();
}


private static void checkQuery() throws XAMException {
boolean finished = false;

while (!finished) {
String status = "N/A";
try {
// Make sure that there is nothing wrong with query job
status = sXSet.getString(XSet.XAM_JOB_ERRORHEALTH);
} catch (FieldDoesNotExistException e) {
// Ignore field not found exceptions, they are not fatal
here
}

if (status.equals(XSet.XAM_JOB_ERRORHEALTH_ERROR)) {
sXSet.haltJob();
break;
}

// Check job status and show the results if job already
finished
status = sXSet.getString(XSet.XAM_JOB_STATUS);
if (status.equals(XSet.XAM_JOB_STATUS_COMPLETE)) {
finished = true;
System.out.println("Query job is completed!");
// Check whether the results field
(xam.job.query.results.count)
// exists or not
if (!sXSet.containsField(XSet.XAM_JOB_QUERY_RESULTS_COUNT))
break;

// Get how many results set are returned from query job
int resultCount = (int) sXSet.getLong
(XSet.XAM_JOB_QUERY_RESULTS_COUNT);
if (resultCount == 0)
break;

displayXUIDs(resultCount);
}
}
}


private static void displayXUIDs(long inCount) throws XAMException {

System.out.println("XUID result set found = " + inCount);

XStream results = null;
try {
results = sXSet.openXStream(XSet.XAM_JOB_QUERY_RESULTS,
XSet.MODE_READ_ONLY);
System.out.println("Open Query Results XStream");
} catch (FieldDoesNotExistException e) {
System.out.println("\nQuery Results XStream Unavailable");
return;
}

System.out.println("\n --------------- <Start XUID List>
------------------");

List<XUID> xuids = new ArrayList<XUID>();
XUIDIterator iterator = new XUIDIterator(results);
int i = 1;
while (iterator.hasNext()) {
XUID xuid = (XUID)iterator.next();
xuids.add(xuid);
System.out.println("[" + i++ + "]" + "xuid = [" + xuid + "]");
}

System.out.println("---------------- <End XUID
List>---------------------- \n");

results.close();
System.out.println("Close Query Results XStream");
}


}


thanks you,
diabate

Michael J. Allison

unread,
Feb 3, 2010, 11:23:02 AM2/3/10
to xam-develo...@googlegroups.com
I'll try to run it later today. It will tell us if the error is in the code, or something unique to your configuration.

On Feb 3, 2010, at 1:29 AM, mdi wrote:

> Hi Mike,
>

Michael J. Allison

unread,
Feb 3, 2010, 1:31:41 PM2/3/10
to xam-develo...@googlegroups.com
Thanks, this reproduces the problem here. I'll see about debugging it and trying to produce a fix for you. I'll post the result here when I get it.

On Feb 3, 2010, at 1:29 AM, mdi wrote:

> Hi Mike,
>

Mike A

unread,
Feb 3, 2010, 8:15:39 PM2/3/10
to XAM Developers Group
I managed to reproduce the problem, and have come up with a small fix
that corrects this problem. I'm embarrased to say that it's broken
because the code was not tested properly. In fact this caused failures
reading from an XStream when a byte value was <= 0. It took until now
for the error to be uncovered. I'll post the fix in a separate and
follow up message in this group. You'll need to apply some fixes to
your source copy of a file in the HTTP Vim.

Mike A


On Feb 3, 10:31 am, "Michael J. Allison" <alliso...@sbcglobal.net>
wrote:

mdi

unread,
Feb 4, 2010, 3:58:00 AM2/4/10
to XAM Developers Group
thank you Mike for your rapidity.

Diabate

Reply all
Reply to author
Forward
0 new messages