3.4.5. Deploying and Testing the New WS

The implementation of our WS is complete. We now have to pack it in a WAR file so that it can be deployed and tested on our application server. For the QALL-ME Framework we have done the WAR packaging using small Ant scripts. We’ll do the same for our new WS implementation now.

We assume you have unpacked both the QALL-ME Framework SDK and the DemoKit into the same directory. The new code you have developed recently has been compiled to the same bin directory as the framework and demo code. The OpenNLP library JAR file lies directly under the lib directory. We can then derive the Ant build script from the existing ones under subdirectories of deploy/demos; here is such a derived Ant script which you can put into a new directory deploy/demos/lang_en/my_termannotation:

<?xml version="1.0" encoding="UTF-8"?>
<project default="war-package"
         name="Tutorial: My English TermAnnotatorWS"

	<property name="deploy-src-dir"
	          value="deploy/demos/lang_en/my_termannotation/" />

	<target name="war-package" description="packages the WAR file">
		<property name="war.file"
		          value="${deploy-src-dir}/en-my_termannotation.war" />
		<delete file="${war.file}" />
		<war destfile="${war.file}" needxmlfile="false">
			<classes dir="bin/">
				<include name="com/example/DictionaryTermAnnotatorWSProvider*" />
				<include name="de/dfki/qallme/Util*" />
				<include name="net/sf/qallme/WebServiceTools*" />
				<include name="net/sf/qallme/gen/ws/termannotation/" />
				<exclude name="net/sf/qallme/gen/ws/termannotation/TermAnnotatorWS.class" />
				<include name="net/sf/qallme/gen/ws/InternalServiceFault.*" />
				<include name="net/sf/qallme/gen/ws/ObjectFactory.*" />
				<include name="net/sf/qallme/gen/ws/package-info.*" />
				<include name="net/sf/qallme/gen/ws/AnnotatedSentence*" />
				<include name="net/sf/qallme/gen/ws/RDFGraph*" />
				<include name="net/sf/qallme/gen/ws/SpatiotemporalContext*" />
			<lib dir="lib/">
				<include name="opennlp-tools-1.4.3.jar" />
			<fileset dir="${deploy-src-dir}" includes="res/" />


Because you have added all the annotations in your source code, you don’t have to write an extra deployment descriptor for the WS. Instead, you can rely on the application server to create one automatically. In order for the war Ant task to not complain about the missing deployment descriptor, we have set the needxmlfile attribute to false.


The needxmlfile attribute of Ant’s war task requires at least Ant 1.7.

Before you can run the above Ant script, there’s one little thing missing still: the terms dictionary that your new WS implementation shall use. As you can see from the Ant script and your source code, you have to create the dictionary as a simple UTF-8 encoded text file named terms.list in a new res directory next to the Ant build script. Add the terms you wish to annotate in this file, one term per line – for example:

hard disk drive
power button
video card
All required files for the new WS WAR package should now be in place; you can now run the Ant script.

Now proceed to the deployment of your freshly created WAR file (as described previously in section 3.2). Hopefully you won’t get any error messages. If the delpoyment appears to be successfull, make sure it really is: first make sure that your deployed web application is really there by going to ApplicationsWeb Applications in the GlassFish navigation; this is usually the case if there were no errors. Then go to Web Services and make sure your new WS implementation is also listed here. Even if there were no errors during the deployment, the latter may often be missing. The reason is usually a missing dependency class in your WAR package or missing Java annotations in your WS implementation providing source code. You can often find traces of the former problem in the application server log files. In GlassFish you can find these in the General tab under the Application Server menu: click View Log Files to bring up the Log Viewer. Look for severe entries of recent problems related to NoClassDefFoundErrors. Then check the contents of your WAR file (using some ZIP file viewer) and make sure the class that was not found is available in WEB-INF/classes or in a JAR file under WEB-INF/lib by properly including it in the Ant build script.

If your WS implementation appears under Web Services, then at least the deployment has been successful. You can now start testing the new WS. We suggest to use soapUI for this – again as described previously in section 3.2. Good luck!