Building a simple HTTP-to-Z39.50 gateway using Yaz4j and Tomcat

Yaz4J is a wrapper library over the client-specific parts of YAZ, a C-based Z39.50 toolkit, and allows you to use the ZOOM API directly from Java. Initial version of Yaz4j has been written by Rob Styles from Talis and the project is now developed and maintained at Index Data. ZOOM is a relatively straightforward API and with a few lines of code you can write a basic application that can establish connection to a Z39.50 server. Here we will try to build a very simple HTTP-to-Z3950 gateway using yaz4j and the Java Servlet technology.

COMPILING AND INSTALLING YAZ4J

Yaz4j is still an experimental piece of software and as such is not distributed via Index Data’s public Debian Apt repository and there is no Windows build (yet) either. While it is possible to use the pre-built Linux binaries, users of other OSes will have to compile yaz4j from source. No need to worry (yet) - the process of compiling yaz4j is quite simple and we will be up and running in no time :).

As a prerequisite, to complete th build process you will need JDK, Maven, Swig and Yaz (development package) installed on your machine. On Debian/Ubuntu you can get those easily via apt:

apt-get install sun-java6-jdk maven2 libyaz4-dev swig

The Yaz4j’s source code can be checked-out out from our Git repository, and assuming you have Git installed on your machine you can do that with:

git clone git://git.indexdata.com/yaz4j

The compilation of both native and Java source code is controlled by Maven2, to build the library, invoke the following commands:

cd yaz4j
mvn install

That’s it. If the build has completed successfully you end up with two files: os-independent jar archive with Java ZOOM API classes (yaz4j/any/target/yaz4j-any-VERSION.jar) and os-dependent shared library (yaz4j/linux/target/libyaz4j.so or yaz4j/win32/target/yaz4j.dll) that contains all necessary JNI “glue” to make the native calls possible from Java. If we were writing a command line Java application, like any other external Java library, yaz4j-any-VERSION.jar would have to be placed on your application classpath and the native, shared library would have to be added to your system shared library path (LD_LIBRARY_PATH on linux, PATH on Windows) or specified as a Java system property (namely the java.library.path) just before your application is executed:

java -cp /path/to/yaz4j-*.jar -Djava.library.path=/path/to/libyaz4j.so MyApp

SETTING UP THE DEVELOPMENT ENVIRONMENT

Setting up a development/runtime environment for a web (servlet) application is a bit more complicated. First, you are not invoking the JVM directly, but the servlet container (e.g Tomcat) run-script is doing that for you. At this point the shared library (so or dll) has to be placed on the servlet container’s shared libraries load path. Unless your library is deployed to the standard system location for shared libs (/usr/lib on Linux) or it’s location is already added to the path, the easiest way to do this in Tomcat is by editing (create it if it does not exist) the CATALINA_HOME/bin/setenv.sh (setenv.bat on Windows) script and putting the following lines in there:

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/libyaz4j.so
export LD_LIBRARY_PATH

on Windows (though no Windows build is yet provided)

 set PATH=%PATH;X:\path\to\yaz4j.dll

That’s one way of doing it, another would be to alter the standard set of arguments passed to the JVM before the Tomcat starts and add -Djava.library.path=/path/to/lib there. Depending on a situation this might be preferable/easier (on Debian/Ubuntu you can specify JVM arguments in the /etc/default/tomcat6 file).

With the shared library installed we need to install the pure-Java yaz4j-any*jar with ZOOM API classes by placing it in Tomcat’s lib directory (CATALINA_HOME/lib). As this library makes the Java System call to load the native library into the JVM you cannot simply package it along with your web application (inside the .war file) - it would try to load the library each time you deploy the webapp and all consecutive deployments would fail.

WRITING A SERVLET-BASED GATEWAY

With your servlet environment set up all that is left is to write the actual application (peanuts :)). At Index Data we use Maven for managing builds of our Java software components but Maven is also a great tool for quickly starting up a project. To generate a skeleton for our webapp use the Maven archetype plugin:

mvn -DarchetypeVersion=1.0.1 -Darchetype.interactive=false \
-DarchetypeArtifactId=webapp-jee5 -DarchetypeGroupId=org.codehaus.mojo.archetypes \ 
-Dpackage=com.indexdata.zgate -DgroupId=com.indexdata -DartifactId=zgate \ 
archetype:generate --batch-mode

This will generate a basic webapp project structure:

|– pom.xml
<code>-- src&#10;|-- main&#10;|   |-- java&#10;|   |</code>– com
|   |       <code>-- indexdata&#10;|   |</code>– zgate
|   <code>-- webapp&#10;|       |-- WEB-INF&#10;|       |</code>– web.xml
|       <code>-- index.jsp&#10;</code>– test
    <code>-- java&#10;</code>– com
            <code>-- indexdata&#10;</code>– zgate

Maven has already added basic JEE APIs for web development as the project dependencies, we need to do the same for yaz4j, so edit the pom.xml and add the following lines in the dependencies section:

<dependency>
  <groupId>org.yaz4j</groupId>
  <artifactId>yaz4j-any</artifactId>
  <version><span class="caps">VERSION</span></version>
 <scope>provided</scope>
</dependency>

It’s crucial that the scope of this dependency is set to provided otherwise the library would end up packaged in the .war archive and we don’t want that.

The implementation of our simple gateway will be contained in a single servlet - ZGateServlet - which we need to place under src/main/webapp/com/indexdata/zgate. The gateway will work by answering HTTP GET requests and will be controlled solely by HTTP parameters, the servlet doGet method is shown below:

protected void doGet(HttpServletRequest request, HttpServletResponse response)
  throws ServletException, <span class="caps">IOE</span>xception {
    String zurl = request.getParameter(“zurl”);
    if (zurl == null || zurl.isEmpty()) {
      response.sendError(400, “Missing parameter ‘zurl’ ”);
      return;
    }

    String query = request.getParameter(“query”);
    if (query == null || query.isEmpty()) {
      response.sendError(400, “Missing parameter ‘query’ ”);
      return;
    }

    String syntax = request.getParameter(“syntax”);
    if (syntax == null || syntax.isEmpty()) {
      response.sendError(400, “Missing parameter ‘syntax’ ”);
      return;
    }

    int maxrecs=10;
    if (request.getParameter(“maxrecs”) != null
      && !request.getParameter(“maxrecs”).isEmpty()) {
      try {
        maxrecs = Integer.parseInt(request.getParameter(“maxrecs”));
      } catch (NumberFormatException nfe) {
        response.sendError(400, “Malformed parameter ‘maxrecs’ ”);
        return;
      }
    }

    response.getWriter().println(“<span class="caps">SEARCH</span> <span class="caps">PARAMETERS</span>”);
    response.getWriter().println(“zurl: ” + zurl);
    response.getWriter().println(“query: ” + query);
    response.getWriter().println(“syntax: ” + syntax);
    response.getWriter().println(“maxrecs: ” + maxrecs);
    response.getWriter().println();

    Connection con = new Connection(zurl, 0);
    con.setSyntax(syntax);
    try {
      con.connect();
      ResultSet set = con.search(query, Connection.QueryType.PrefixQuery);
      response.getWriter().println(“Showing “+maxrecs+” of “+set.getSize());
      response.getWriter().println();
      for(int i=0; i<set.getSize() && i<maxrecs; i++) {
        Record rec = set.getRecord(i);
        response.getWriter().print(rec.render());
      }
    } catch (ZoomException ze) {
      throw new ServletException(ze);
    } finally {
      con.close();
    }
 }

With the code in-place we can try to compile the project:

mvn compile

If all is OK, the next step is to register our servlet and map it to an URL in src/main/webapp/WEB-INF/web.xml:

<servlet>
  <servlet-name>ZgateServlet</servlet-name>
  <servlet-class>com.indexdata.zgate.ZgateServlet</servlet-class>
</servlet>
<servlet-mapping>
  <servlet-name>ZgateServlet</servlet-name>
 <url-pattern>/zgate</url-pattern>
</servlet-mapping>

On top of that, we will also make sure that our servlet is automatically triggered when accessing the root path of our application:

<welcome-file-list>
  <welcome-file>zgate</welcome-file>
 <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

Now we are ready to build our webapp:

mvn package

The resulting .war archive is located under target/zgate.war, we can deploy it on tomcat (e.g by using the /admin Tomcat admin console) and test by issuing the following request with your browser or curl (assuming Tomcat is running on localhost:8080):

http://localhost:8080/zgate/?zurl=z3950.loc.gov:7090/voyager…

That’s it! You just build yourself a HTTP-to-Z3950 gateway! Just be careful with exposing it to the outside world - it’s not very secure and could be easily exploited. The source code and the gateway’s Maven project is available in the Yaz4j’s Git repository under examples/zgate. In the meantime, Index Data is working on a Debian/Ubuntu package to make the installation of Yaz4j and Tomcat configuration greatly simplified - so stay tuned!. If you are interested in Windows support - e.g. Visual Studio based build or an installer - please let us know.

28 Comments

import

import org.yaz4j.Connection;
import org.yaz4j.Record;
import org.yaz4j.ResultSet;
import org.yaz4j.exception.ZoomException;

public class Main {

public static void main(String[] args) {
Connection con = new Connection("z3950.loc.gov:7090/voyager", 0);
try {
con.setSyntax("rusmarc");
con.connect();
ResultSet set = con.search("@attr 1=7 0253333490", Connection.QueryType.PrefixQuery);

Record rec = set.getRecord(0);
System.out.print(rec.render());
} catch (ZoomException ze) {
//fail(ze.getMessage());
} finally {
con.close();
}
}

This code crushed java, bc type of records rusmarc. epic fail :(

Looks like the LC server just doesn't support RUSMARC

Sergios,

I don't think this is YAZ4J's fault, or indeed the fault of any of the client-side software. Using zoomsh to invoke the underlying ZOOM-C functions directly, we can verify that the LC server just plain doesn't support the RUSMARC record syntax:

mike@xeno:~$ zoomsh
ZOOM>open z3950.loc.gov:7090/voyager
ZOOM>set preferredRecordSyntax rusmarc
ZOOM>find @attr 1=7 0253333490
z3950.loc.gov:7090/voyager: 1 hits
ZOOM>show 0
z3950.loc.gov:7090/voyager error: Record not available in requested syntax (Bib-1:238) 1.2.840.10003.5.28
ZOOM>

I know that lc does not

I know that lc does not support rusmarc. In this case, it should throw an exception on that record type is not supported, but java destroyed. This problem exists with any z server, including zebra

Please be more explicit about what happens

What do you mean by saying that "java destroyed"? Surely you're not saying that your Java implementation's JVM crashes? (If so, that is a bug in Java itself.) What is actually printed when you run your program?

ubuntu 9.10 (32) (new

ubuntu 9.10 (32) (new installations) running on vmware 7. jdk, swig, yaz etc installed from apt-get.

#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0xb7675f93, pid=20362, tid=3067304816
#
# JRE version: 6.0_15-b03
# Java VM: Java HotSpot(TM) Client VM (14.1-b02 mixed mode, sharing linux-x86 )
# Problematic frame:
# C [libc.so.6+0x72f93] strlen+0x33
#
# An error report file with more information is saved as:
# /home/sergios/NetBeansProjects/JavaApplication1/hs_err_pid20362.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

Windows build

Hello,

I tried to follow your instructions on a windows machine, but unfortunately it seems that there is a directory (win32) missing to perform the build. I just copied the linux directory and renamed it, but of course that did not work without adapting the pom.xml for windows. At the moment it is complaining that the yaz-config executable is missing, which does not seem to exist on windows.

Do you have any hints on how to do that? Or do you already have built on the windows platform and can provide me with binaries?

Thanks in advance for any help!

Best Regards,
Christoph

Hi Christoph, As mentioned at

Hi Christoph,

As mentioned at the end of the article we do not provide Windows build files or binaries for yaz4j at this point. Main reason for that is that we generally do not use Windows for development or deployment of our software and currently yaz4j is being used in an UNIX-only (Linux, MacOSX) environment. We are always open for enhancement requests, however, at the moment we can only introduce Windows support as a result of sponsored development.

Yours,

Jakub Skoczen
Index Data

Hi Jakub, thank you for your

Hi Jakub,

thank you for your reply.

With a lot of ugly hacks (unfortunately I know nothing about maven) I managed to build the .dll under windows using mingw.
I even manged to build it again with Visual Studio using the generated source. If you are interested, I can send you the pom.xml I used to build under windows (and the binary), however since I don't know much about maven it is full of hacks and hardcoded paths.

I now tried the library and used it to do a lot of searches with one connection. However, after about 100 requests I get an exception "TooManyResultSetsCreated". Therefore, I have to close the connection and open it again. Is that expected behavior, or is there a way to "close" a resultset, so that I can create another search?

Best Regards,
Christoph

Yes, please send the patch to

Yes, please send the patch to jakub AT indexdata.dk and maybe I'll manage to get it to the next release.

TooManyResultSetsCreated is a Bib1 diagnostic returned by the server to indicate that you have exhausted the number of result sets allowed by the server. By default YAZ will create a new server-side result set for every client-side one. One way to avoid it is to keep only one "server-side" result set, and you can do that by "naming" it:

con.option("setname", "default")

Name "default" is highly recommended as some server do not support name result sets at all (but they will work with "default").

Now, if you need to keep more server-side result sets alive you need to figure out the number supported by the server and set the "setname" option (to whatever) on the connection object just before you execute search() and then keep on overwriting old result sets as you need to create new ones.

btw, for any further question please send them to the yaz-mailing list http://lists.indexdata.dk/cgi-bin/mailman/listinfo/yazlist

Hi Christoph, Can you send me

Hi Christoph,

Can you send me the pom.xml used to build yaz4j under windows.

Best Regards.
Boubakeur

yaz4j on windows

please
somebody can share
pom for build yaz4j on windows
or the final yaz4j.dll?

thanks in advance
manny

Find below the pom.xml for

Find below the pom.xml for windows and pom.xml in the main directory.

However, both contain hardcoded paths, as I am unsure how to handle them
differently under windows (I don't know enough about maven).

POM.XML in root:

<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.yaz4j</groupId>
<artifactId>yaz4j</artifactId>
<version>1.2-SNAPSHOT</version>
<packaging>pom</packaging>

<!-- Project Information -->
<name>yaz4j</name>
<url>http://www.indexdata.com/yaz4j/</url>
<inceptionYear>2008</inceptionYear>
<licenses>
<license>
<name>BSD</name>
<url>http://www.opensource.org/licenses/bsd-license.php</url>
</license>
</licenses>
<description>Java wrapper for the ZOOM API of YAZ</description>

<developers>
<developer>
<name>Rob Styles</name>
<id>rob</id>
<email>Rob.Styles@talis.com</email>
<organization>Talis</organization>
<organizationUrl>http://www.talis.com/</organizationUrl>
<roles />
<timezone />
</developer>
<developer>
<name>Adam Dickmeiss</name>
<id>adam</id>
<email>adam@indexdata.dk</email>
<organization>Index Data</organization>
<organizationUrl>http://www.indexdata.com/</organizationUrl>
<roles />
<timezone />
</developer>
<developer>
<name>Jakub Skoczen</name>
<id>jakub</id>
<email>jakub@indexdata.dk</email>
<organization>Index Data</organization>
<organizationUrl>http://www.indexdata.com/</organizationUrl>
<roles />
<timezone />
</developer>
<developer>
<name>Juan Cayetano</name>
<id>cayetano</id>
<email>juancayetano.delgado@gmail.com</email>
<organization />
<organizationUrl />
<roles />
<timezone />
</developer>
</developers>

<modules>
<module>any</module>
</modules>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.3.1</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<inherited>false</inherited>
<configuration>
<tasks>
<echo message="Using yaz prefix: ${yaz.prefix}"/>
<mkdir dir="target/generated-sources/java/org/yaz4j/jni"/>
<mkdir dir="target/generated-sources/native" />
<exec executable="../swigwin-1.3.40/swig">
<arg value="-Isrc/main/native" />
<arg value="-I${yaz.prefix}/include"/>
<arg value="-outdir"/>
<arg value="${basedir}/target/generated-sources/java/org/yaz4j/jni"/>
<arg value="-package"/>
<arg value="org.yaz4j.jni"/>
<arg value="-o"/>
<arg value="${basedir}/target/generated-sources/native/libyaz4j.cpp"/>
<arg value="-c++"/>
<arg value="-java"/>
<arg value="src/main/swig/libyaz4j.i"/>
</exec>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<!-- Reporting -->
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<enableRSS>false</enableRSS>
<include>**/*.java</include>
<sourceDirectory>src/main/java</sourceDirectory>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>
maven-project-info-reports-plugin
</artifactId>
<reportSets>
<reportSet>
<reports>
<report>dependencies</report>
<report>project-team</report>
<report>mailing-list</report>
<report>issue-tracking</report>
<report>summary</report>
<report>scm</report>
<report>index</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<chartset>UTF-8</chartset>
<excludePackageNames>org.yaz4j.jni</excludePackageNames>
</configuration>
</plugin>
</plugins>
</reporting>
<!-- ////////////// -->

<!-- Environment Information -->
<mailingLists>
<mailingList>
<name>Yazlist</name>
<subscribe />
<unsubscribe />
<post>yazlist@lists.indexdata.dk</post>
<archive>http://lists.indexdata.dk/pipermail/yazlist/</archive>
</mailingList>
</mailingLists>

<scm>
<connection>scm:git:git://git.indexdata.com/yaz4j</connection>
<url>http://git.indexdata.com/?p=yaz4j.git</url>
</scm>

<issueManagement>
<system>Bugzilla</system>
<url>http://bugzilla.indexdata.dk</url>
</issueManagement>

<profiles>
<profile>
<id>win32</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<properties>
<platform>win32</platform>
</properties>
<modules>
<module>win32</module>
</modules>
</profile>

<profile>
<id>linux</id>
<activation>
<os>
<family>unix</family>
</os>
</activation>
<properties>
<platform>linux</platform>
</properties>
<modules>
<module>linux</module>
</modules>
</profile>
</profiles>
</project>

POM.xml in win32:

<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.yaz4j</groupId>
<artifactId>yaz4j</artifactId>
<version>1.2-SNAPSHOT</version>
</parent>
<groupId>org.yaz4j</groupId>
<artifactId>libyaz4j</artifactId>
<name>yaz4j</name>
<packaging>dll</packaging>

<properties>
<yaz.prefix>C:/YAZ</yaz.prefix>
<yaz.cflags>-DYAZ_POSIX_THREADS=1 -DYAZ_HAVE_XML2=1 -DYAZ_HAVE_XSLT=1 -DYAZ_HAVE_EXSLT=1</yaz.cflags>
<yaz.libs>-lyaz4</yaz.libs>
<mingw.dir>c:/development/yaz4j/mingw/</mingw.dir>
</properties>

<build>
<finalName>yaz4j</finalName>
<testSourceDirectory>../src/test</testSourceDirectory>

<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-1</version>
<executions>
<execution>
<id>read-yaz-config</id>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${basedir}/target/yaz-config.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>native-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<javahOS>win32</javahOS>
<compilerProvider>generic</compilerProvider>
<compilerExecutable>${mingw.dir}/bin/c++</compilerExecutable>
<compilerStartOptions>
<compilerStartOption>-fPIC</compilerStartOption>
<compilerStartOption>-I${yaz.prefix}/include</compilerStartOption>
<compilerStartOption>-Wall</compilerStartOption>
<compilerStartOption>-D_JNI_IMPLEMENTATION_</compilerStartOption>
</compilerStartOptions>
<compilerEndOptions>
<compilerEndOption>${yaz.cflags}</compilerEndOption>
</compilerEndOptions>
<sources>
<source>
<includes>
<include>**/*.cpp</include>
</includes>
<directory>../src/main/native</directory>
</source>
<source>
<includes>
<include>**/*.cpp</include>
</includes>
<directory>../target/generated-sources/native</directory>
</source>
</sources>
<linkerExecutable>${mingw.dir}/bin/c++</linkerExecutable>
<linkerStartOptions>
<linkerStartOption>-shared</linkerStartOption>
<linkerStartOption>-L${yaz.prefix}/lib</linkerStartOption>
<linkerStartOption>-Wl,--output-def,yaz4j.def</linkerStartOption>
<linkerStartOption>-Wl,--kill-at</linkerStartOption>
</linkerStartOptions>
<linkerEndOptions>
<linkerEndOption>${yaz.libs}</linkerEndOption>
</linkerEndOptions>
</configuration>
</plugin>

<!-- this is to compile and execute tests, that are arch-dependent
because they need to load so/dll -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
<source>1.6</source>
<target>1.6</target>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
</configuration>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>include-generated-test-sources</id>
<phase>generate-test-sources</phase>
<goals><goal>add-test-source</goal></goals>
<configuration>
<sources>
<source>../src/main/java</source>
<source>../target/generated-sources/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>once</forkMode>
<workingDirectory>target</workingDirectory>
<argLine>-Djava.library.path=${project.build.directory}</argLine>
</configuration>
</plugin>
</plugins>
</build>

<repositories>
<repository>
<id>Codehaus Snapshots</id>
<url>http://snapshots.repository.codehaus.org/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>Codehaus Snapshots</id>
<url>http://snapshots.repository.codehaus.org/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled> <!-- Workaround for MNG-2974, see note below -->
</releases>
</pluginRepository>
</pluginRepositories>
</project>

help on yaz4j win32 pom

hi list,
i try to use the pom.xml to compile
yaz4j in windows environment, but unsuccessfully
I get it from
http://www.indexdata.com/blog/2010/02/building-simple-http-z3950-gateway...
then i changed some hard-coded entry 'cause my pc path
C:\YAZ;C:/swigwin-2.0.4;C:/MinGW (differently from original by Chrsitoph)...
and java version (1.5)
=======================================================================================
when i run mvn clean install -DskipTests
it fails on libyaz4j (native) section
[INFO] [native:initialize {execution: default-initialize}]
[INFO] [properties:read-project-properties {execution: read-yaz-config}]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Properties file not found: D:\eclipse-work\Workspaces\Eclipse 3.6 Java\yaz4j-1.2\win32\target\yaz-config.properties
=======================================================================================
it seems that pom file miss a section where have to create yaz-config.properties

in the linux version (i use it on centos without problem)
this job is business of
write-yaz-config section by yaz-config script, i suppose

but on win32 version I don't find anything like....
here is my win32 pom version
========================================parent
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.yaz4j</groupId>
<artifactId>yaz4j</artifactId>
<version>1.2-SNAPSHOT</version>
<packaging>pom</packaging>

<!-- Project Information -->
<name>yaz4j</name>
<url>http://www.indexdata.com/yaz4j/</url>
<inceptionYear>2008</inceptionYear>
<licenses>
<license>
<name>BSD</name>
<url>http://www.opensource.org/licenses/bsd-license.php</url>
</license>
</licenses>
<description>Java wrapper for the ZOOM API of YAZ</description>

<developers>
<developer>
<name>Rob Styles</name>
<id>rob</id>
<email>Rob.Styles@talis.com</email>
<organization>Talis</organization>
<organizationUrl>http://www.talis.com/</organizationUrl>
<roles />
<timezone />
</developer>
<developer>
<name>Adam Dickmeiss</name>
<id>adam</id>
<email>adam@indexdata.dk</email>
<organization>Index Data</organization>
<organizationUrl>http://www.indexdata.com/</organizationUrl>
<roles />
<timezone />
</developer>
<developer>
<name>Jakub Skoczen</name>
<id>jakub</id>
<email>jakub@indexdata.dk</email>
<organization>Index Data</organization>
<organizationUrl>http://www.indexdata.com/</organizationUrl>
<roles />
<timezone />
</developer>
<developer>
<name>Juan Cayetano</name>
<id>cayetano</id>
<email>juancayetano.delgado@gmail.com</email>
<organization />
<organizationUrl />
<roles />
<timezone />
</developer>
</developers>

<modules>
<module>any</module>
</modules>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.3.1</version>
<scope>test</scope>
</dependency>
</dependencies>

<properties>
<yaz.prefix>C:/YAZ</yaz.prefix>
<swig.dir>C:/swigwin-2.0.4</swig.dir>
</properties>

<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<inherited>false</inherited>
<configuration>
<tasks>
<echo message="Using yaz prefix: ${yaz.prefix}"/>
<mkdir dir="target/generated-sources/java/org/yaz4j/jni"/>
<mkdir dir="target/generated-sources/native" />
<!--<exec executable="../swigwin-1.3.40/swig">-->
<exec executable="${swig.dir}/swig">
<arg value="-Isrc/main/native" />
<arg value="-I${yaz.prefix}/include"/>
<arg value="-outdir"/>
<arg value="${basedir}/target/generated-sources/java/org/yaz4j/jni"/>
<arg value="-package"/>
<arg value="org.yaz4j.jni"/>
<arg value="-o"/>
<arg value="${basedir}/target/generated-sources/native/libyaz4j.cpp"/>
<arg value="-c++"/>
<arg value="-java"/>
<arg value="src/main/swig/libyaz4j.i"/>
</exec>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<!-- Reporting -->
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<enableRSS>false</enableRSS>
<include>**/*.java</include>
<sourceDirectory>src/main/java</sourceDirectory>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>
maven-project-info-reports-plugin
</artifactId>
<reportSets>
<reportSet>
<reports>
<report>dependencies</report>
<report>project-team</report>
<report>mailing-list</report>
<report>issue-tracking</report>
<report>summary</report>
<report>scm</report>
<report>index</report>
</reports>
</reportSet>
</reportSets>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<chartset>UTF-8</chartset>
<excludePackageNames>org.yaz4j.jni</excludePackageNames>
</configuration>
</plugin>
</plugins>
</reporting>
<!-- ////////////// -->

<!-- Environment Information -->
<mailingLists>
<mailingList>
<name>Yazlist</name>
<subscribe />
<unsubscribe />
<post>yazlist@lists.indexdata.dk</post>
<archive>http://lists.indexdata.dk/pipermail/yazlist/</archive>
</mailingList>
</mailingLists>

<scm>
<connection>scm:git:git://git.indexdata.com/yaz4j</connection>
<url>http://git.indexdata.com/?p=yaz4j.git</url>
</scm>

<issueManagement>
<system>Bugzilla</system>
<url>http://bugzilla.indexdata.dk</url>
</issueManagement>

<profiles>
<profile>
<id>win32</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<properties>
<platform>win32</platform>
</properties>
<modules>
<module>win32</module>
</modules>
</profile>
<!--
<profile>
<id>linux</id>
<activation>
<os>
<family>unix</family>
</os>
</activation>
<properties>
<platform>linux</platform>
</properties>
<modules>
<module>linux</module>
</modules>
</profile>
-->
</profiles>
</project>
==================================
================================== win32
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.yaz4j</groupId>
<artifactId>yaz4j</artifactId>
<version>1.2-SNAPSHOT</version>
</parent>
<groupId>org.yaz4j</groupId>
<artifactId>libyaz4j</artifactId>
<!--<name>yaz4j</name>-->
<name>libyaz4j</name>
<packaging>dll</packaging>

<properties>
<yaz.prefix>C:/YAZ</yaz.prefix>
<yaz.cflags>-DYAZ_POSIX_THREADS=1 -DYAZ_HAVE_XML2=1 -DYAZ_HAVE_XSLT=1 -DYAZ_HAVE_EXSLT=1</yaz.cflags>
<yaz.libs>-lyaz4</yaz.libs>
<mingw.dir>C:/MinGW</mingw.dir>
</properties>

<build>
<finalName>${artifactId}</finalName>
<testSourceDirectory>../src/test</testSourceDirectory>

<plugins>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-1</version>
<executions>
<execution>
<id>read-yaz-config</id>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${basedir}/target/yaz-config.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>native-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<javahOS>win32</javahOS>
<compilerProvider>generic</compilerProvider>
<compilerExecutable>${mingw.dir}/bin/c++</compilerExecutable>
<compilerStartOptions>
<compilerStartOption>-fPIC</compilerStartOption>
<compilerStartOption>-I${yaz.prefix}/include</compilerStartOption>
<compilerStartOption>-Wall</compilerStartOption>
<compilerStartOption>-D_JNI_IMPLEMENTATION_</compilerStartOption>
</compilerStartOptions>
<compilerEndOptions>
<compilerEndOption>${yaz.cflags}</compilerEndOption>
</compilerEndOptions>
<sources>
<source>
<includes>
<include>**/*.cpp</include>
</includes>
<directory>../src/main/native</directory>
</source>
<source>
<includes>
<include>**/*.cpp</include>
</includes>
<directory>../target/generated-sources/native</directory>
</source>
</sources>
<linkerExecutable>${mingw.dir}/bin/c++</linkerExecutable>
<linkerStartOptions>
<linkerStartOption>-shared</linkerStartOption>
<linkerStartOption>-L${yaz.prefix}/lib</linkerStartOption>
<linkerStartOption>-Wl,--output-def,yaz4j.def</linkerStartOption>
<linkerStartOption>-Wl,--kill-at</linkerStartOption>
</linkerStartOptions>
<linkerEndOptions>
<linkerEndOption>${yaz.libs}</linkerEndOption>
</linkerEndOptions>
</configuration>
</plugin>

<!-- this is to compile and execute tests, that are arch-dependent
because they need to load so/dll -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
<source>1.5</source>
<target>1.5</target>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
</configuration>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>include-generated-test-sources</id>
<phase>generate-test-sources</phase>
<goals><goal>add-test-source</goal></goals>
<configuration>
<sources>
<source>../src/main/java</source>
<source>../target/generated-sources/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>once</forkMode>
<workingDirectory>target</workingDirectory>
<argLine>-Djava.library.path=${project.build.directory}</argLine>
</configuration>
</plugin>
</plugins>
</build>

<repositories>
<repository>
<id>Codehaus Snapshots</id>
<url>http://snapshots.repository.codehaus.org/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>Codehaus Snapshots</id>
<url>http://snapshots.repository.codehaus.org/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled> <!-- Workaround for MNG-2974, see note below -->
</releases>
</pluginRepository>
</pluginRepositories>
</project>
=================================

What am I doing wrong?

please help me... i'm newbie about MAVEN

Thank you all for your time...
manny

I think I simply copied the

I think I simply copied the yaz-config.properties file from the linux build to the windows target directory.

Here are the contents of my yaz-config.properties:

yaz.cflags=-DYAZ_POSIX_THREADS=1 -DYAZ_HAVE_XML2=1 -DYAZ_HAVE_XSLT=1 -DYAZ_HAVE_EXSLT=1 -I/usr/include/libxml2
yaz.libs=-lyaz4

the same old problem about yaz4j pom fro windows

Hi Christoph,
after a lot of attemps
(I have tried many combinations starting from your pom and trying to follow your directions)

i arrive every time to the same bad result
=============================================
....
[INFO] cmd.exe /X /C "C:\MinGW\bin\c++ -shared -Wl,--output-def,yaz4j.def -Wl,--kill-at -LC:/YAZ/lib -o "D:\eclipse-work\Workspaces\Eclipse 3.6 Java\yaz4j-1.2\win32\target\libyaz4j.dll" target\objs\zoom-extra.obj target\objs\libyaz4j.obj -lyaz4"
target\objs\libyaz4j.obj:libyaz4j.cpp:(.text+0x2ebd): undefined reference to `ZOOM_resultset_get_facet_field_by_index@8'
target\objs\libyaz4j.obj:libyaz4j.cpp:(.text+0x2fc7): undefined reference to `ZOOM_resultset_facets_names@4'
collect2: ld returned 1 exit status
=============================================
it's seems that the initial libyaz4j.cpp is not correct or it's miss some include
besides I can't believe you use this 'yaz-config.properties'

yaz.cflags=-DYAZ_POSIX_THREADS=1 -DYAZ_HAVE_XML2=1 -DYAZ_HAVE_XSLT=1 -DYAZ_HAVE_EXSLT=1 -I/usr/include/libxml2
yaz.libs=-lyaz4
thats refer to a unix path (maybe is a "cut&paste" error)
==============================================
any idea?

at least can you send me your final DLL?
francesco.maniscoATgmail.com

I hope not to stress you
ciao
manny

IIRC, the values from the

IIRC, the values from the yaz-config.properties file are overwritten in the pom.xml, therefore they are not important.

You get a linker error, so the problem is not a missing include, but a missing source file or (more likely) a missing library.

Do you have the yaz4.lib file in C:/YAZ/lib?

I sent you an email containing the dll-files.

Z39.50 protocol.

Hello,I am Java developer.I want to connect library base with Z39.50 protocol in Java code.The sample java code necessary for me.Do you help me?

Thanks for the yaz4j! It's a

Thanks for the yaz4j! It's a great! But i have a one question: how about extended services z39.50 (for CRUD operations in zebra)?

Any Yaz4j next release ?

Hi,

It has been 1yr+ after v1.2 was released. Will IndexData be releasing updates done on v1.2 especially the sort feature in an official v1.3 release?

I think a lot of us using yaz4j will love to see the progress of this useful library.

Cheers.

YAZ4J release schedule

Hi, Explorer, thanks for your interest.

We generally don't plan to make releases of our software at specific intervals, but when enough interesting new functionality has been added to merit a release. And right now, YAZ4J is not seeing a lot of development. In general, we develop tools either when we're using them ourselves as part of a larger system that we're building, or when a customer requests specific changes. At the moment, neither of those things is happening with YAZ4J. But, yes, when they do there will surely be more releases.

Hi Christoph and Jakub

Hi Jacob. I am try yaz4j, It isn't work. Please Can you help me to solve this problem. Do you have integration video?

Please help me!

java.lang.UnsatisfiedLinkError: E:\1.Tools\YAZ\bin\yaz4j.dll: Can't find dependent libraries
java.lang.ClassLoader$NativeLibrary.load(Native Method)
java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1803)
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1728)
java.lang.Runtime.loadLibrary0(Runtime.java:823)
java.lang.System.loadLibrary(System.java:1028)
org.yaz4j.Connection.(Connection.java:56)
com.indexdata.zgate.ZgateServlet.doGet(ZgateServlet.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

+ My windows: Windows 7 Professional SP1 (x64)
+ My JRE: 1.6.20 (x86)
+ My Tomcat 7.0 (x86)
+ My YAZ (5.11.0 - x86)

RE: Please help me!

Hello, please post your question to the yazlist.

RE: link to git

The source code repository has moved from that mentioned in this article to https://github.com/indexdata/yaz4j

There is an updated article in the source code in the “examples” directory. The top-level README has improved instructions for Windows systems. For other assistance, please see the “yazlist” mail list, or report issues at GitHub.