#2 Trouble with the sample client

closed
None
5
2002-08-31
2002-08-31
Anonymous
No

Hi there,

I've downloaded version 1.0 of the JZKit and I'm trying
to get the sample client working. I'm attempting to
connect to the LoC Voyager database, because the
database the client is setup to contact seems to be down.

I had quite a few problems with classpaths and such
because I'm new to Java, but they seem to be sorted. I
had to modify some of the client code because it
wouldn't compile as was. The code as it stands is as
follows:

import java.io.*;
import java.net.*;
import java.util.*;

import java.io.PrintStream;
import java.io.IOException;
import java.math.BigInteger;

// for OID Register
import com.k_int.codec.util.*;
import com.k_int.codec.runtime.*;

// Information Retrieval Interfaces
import com.k_int.IR.*;
import com.k_int.z3950.IRClient.*;

public class TestClient
{
public static void main(String args[]) throws
TimeoutExceededException, PresentException, SearchException
{
// OIDRegister reg = OIDRegister.getRegister();

// Properties for the search
Properties p = new Properties();
p.put("ServiceHost","z3950.loc.gov");
p.put("ServicePort","7090");
p.put("default_record_syntax","xml");

// Create an anonymous inner class to listen for
search events...
Observer fragment_count_observer = new Observer()
{
public void update(Observable o, Object arg)
{
FragmentSourceEvent e;
try {
if (arg.getClass().getName() ==
"com.k_int.IR.IREvent") {
e = new
FragmentSourceEvent(((IREvent)arg).event_type,
((IREvent)arg).event_info);
}
else {
e = (FragmentSourceEvent)arg;
}
if ( e.event_type ==
FragmentSourceEvent.SOURCE_RESET )
{
System.err.println("Fragment source reset");
}
else if ( e.event_type ==
FragmentSourceEvent.FRAGMENT_COUNT_CHANGE )
{
System.err.println("Available number of fragments
has changed to "+e.event_info);
}
}
catch (Exception ex) {
String s = arg.getClass().getName();
System.err.println("Tried to cast a " + s + "
to FragmentSourceEvent");
System.exit(1);
}
}
};

Observer[] all_observers = new Observer[] {
fragment_count_observer };

Searchable s = new Z3950Origin();
s.init(p);

IRQuery e = new IRQuery();

e.hints = new Hashtable();
e.hints.put("record_syntax", "usmarc");
e.collections = new Vector();
e.collections.add("Voyager");

e.query_syntax = "PREFIX";
e.query = new String("@attrset bib-1 @attr 1=1016
legislation");

System.err.println("Searching");
SearchTask st = (SearchTask) s.createTask(e, null);
//, all_observers );
System.err.println("Private task status:
"+st.lookupPrivateStatusCode(st.getPrivateTaskStatusCode()));
st.evaluate(100000);

System.err.println("Private task status:
"+st.lookupPrivateStatusCode(st.getPrivateTaskStatusCode()));

InformationFragmentSource ifs = st.getTaskResultSet();
System.err.println("Search returned " +
ifs.getFragmentCount() + " records");
for ( int i = 1; i<= ifs.getFragmentCount(); i++ )
{
InformationFragment frag = ifs.getFragment(i);
System.out.println(frag);
}

// Test fetching a batch of records
System.err.println("Test2");
InformationFragment f[] = ifs.getFragment(1,10);

// Test fetching another batch of records
System.err.println("Test3");
InformationFragment f2[] = ifs.getFragment(10,10);

// Make sure we can call getDocument
System.out.println("Test 4 : Get document");
org.w3c.dom.Document d = f2[2].getDocument();

System.exit(0);
}
}

As you can see, most of the changes are in the inner
class, because of the casting to subclasses, and a
couple of debugging prints.

What I'm finding now is that when I run it, I get the
following output:

C:\j2sdk1.4.0\mick\jz>java TestClient
log4j:ERROR No appenders could be found for category
(Z3950Origin).
log4j:ERROR Please initialize the log4j system properly.
Searching
Fragment source reset
Private task status: Idle
java.lang.NoSuchMethodError:
com.k_int.codec.runtime.SerializationManager.choice
(Ljava/lang/Object;[[Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;
at
com.k_int.gen.Z39_50_APDU_1995.PDU_codec.serialize(PDU_codec.java:66)

at
com.k_int.z3950.util.ZEndpoint.encodeAndSend(ZEndpoint.java:410)
at
com.k_int.z3950.util.ZEndpoint.sendInitRequest(ZEndpoint.java:265)
at
com.k_int.z3950.util.ZEndpoint.connect(ZEndpoint.java:572)
at
com.k_int.z3950.util.ZEndpoint.run(ZEndpoint.java:455)

Private task status: Idle
Search returned 0 records
Test2
Exception in thread "main"
com.k_int.IR.PresentException: Present out of range,
only 0 records available
at
com.k_int.z3950.IRClient.Z3950SearchTask.getFragment(Z3950SearchTask.
java:105)
at TestClient.main(TestClient.java:92)

Obviously the final exception is trivial, and I don't
really understand the logging errors but they don't
seem to be fatal. But I decompiled the
SerializationManager class because I couldn't find any
documentation, and it doesn't seem to have a 3-argument
choice() method, only a 4-argument method.
Decompilation of the PDU_codec class shows it trying to
call the choice() method with only 3 arguments.

My question then is: am I using outdated classes (I
can't see anything more recent on this site), or are
there patches available, or am I doing something really
dumb that I just haven't twigged to? I'm completely
new to Z39.50, fairly new to Java so I'm sure it's
quite possible, but I've been wading through this stuff
for a few days now and decided to try sending this plea.

Cheers,

Mick

Discussion

  • Ian Ibbotson

    Ian Ibbotson - 2002-08-31

    Logged In: YES
    user_id=88018

    Sounds like something *very* strange is going on. 1.0 should
    work without any problems of this kind. I'll look into the
    message in a little more detail. You can download the source
    for the codec stuff from the a2j project at sourceforge. In
    the interim, I'd try downloading the latest build from
    http://www.k-int.com/products/jzkit/download.php. Not sure
    why your decompilation of BEROutputStream indicates a four
    arg method, it's certainly only a three arg method.. sounds
    very strange. Can you offer any more info about your
    environment? Classpath would be handy.

    Ian.

     
  • Ian Ibbotson

    Ian Ibbotson - 2002-08-31
    • assigned_to: nobody --> ianibbo
    • status: open --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks