[greenstone-devel] Re: About running the demo-client application

From Anupama of Greenstone Team
DateWed Jun 18 15:10:54 2008
Subject [greenstone-devel] Re: About running the demo-client application
In-Reply-To (4857DF43-4050704-cis-strath-ac-uk)
Hi,

We have come a little bit further now since last time because now the
democlient app on your machine has managed to get past the stage where
it connects to the QBRSOAPServerlocalsite web service and parses the
WSDL file. At present, it's the method invokeWith() that is throwing the
latest exception, and that method is only called whenever the client app
wants to send an XML request message to the web service and get the XML
response message back.

I tested a new download of the democlient.zip on my Linux just now and
it works. That means we're going to have to figure this out in some
other way.

I looked at the kind of error that causes the Exception you encountered:
"Content is not allowed in prolog."

http://www.bennadel.com/blog/1206-Content-Is-Not-Allowed-In-Prolog-ColdFusion-XML-And-The-Byte-Order-Mark-BOM-.htm
explains that something preceding the proper start of the XML message
causes this exception to occur.

Since org.greenstone.gs3client.dlservices.GS3ServicesAPIA's
invokeWith(Object[] params) is a method on the client side that is
complaining about the XML it has encountered, the problem must be the
XML generated on the web service end.

If we configured the democlient's log4j.properties to display DEBUG
statements, the client app would log the XML messages in the file
democlientlog4j.properties. Both these files are located in the top
level of your democlient folder. However, in this case, the logging
statement won't even be reached since the exception is thrown in the
class GS3ServicesAPIA (actually its superclass) before the debug
statements are even printed.

Therefore, we have to get the webservice-generated XML messages printed
out to the log file on the server end.
The QBRSOAPServer web service logs on the Greenstone 3 server end.
However, the XML messages will only be sent to a logfile IF the logging
level in the log4j.properties on the GS3 server end includes DEBUG. This
means that at the default settings of your GS3 log4j.properties (if you
haven't changed it after installing GS3), nothing will be showing up.

So that's our first step. I've tested it out here just now, therefore I
think you can see the logging messages as well if you do the following:

1. Open your greenstone3/web/WEB-INF/log4j.properties file.

2. Change the line
log4j.disable=DEBUG
to
log4j.disable=TRACE

3. Add in the following lines into the file, which sets up the
QBRSOAPServer web services to send its "DEBUG" log statements to the
file greenstone3/web/logs/webservice.log:
## web services logger
log4j.category.org.greenstone.gsdl3.QBRSOAPServerlocalsite=DEBUG,
webservicelog
log4j.additivity.org.greenstone.gsdl3.QBRSOAPServerlocalsite=false

##webservice logger
log4j.appender.webservicelog=org.apache.log4j.RollingFileAppender
log4j.appender.webservicelog.File=${gsdl3.home}/logs/webservice.log

## web service logger layout
log4j.appender.webservicelog.layout=org.apache.log4j.PatternLayout
log4j.appender.webservicelog.layout.ConversionPattern=%-5p:
[%d{yyyy-MM-dd hh:mm:ss}] %C{1}.%M()%n %m%n

4. Now run your democlient application.

5. The output will (hopefully) be sent to the file
greenstone3/web/logs/webservice.log. If you open it up, we can maybe
inspect what's going on.

Sometimes invisible characters preceding the proper start of an XML
message will cause an exception like the one you saw to be thrown. If
you can't see any out-of-place characters in your file, you could try
viewing the file again in binary or--as Greenstone developer Oran tells
me--using a "hexeditor". That's a software that allows you to see the
contents of a file in hexadecimal.

6. If you can't see anything visibly wrong in the messages written out
to webservices.log, then try the following. (First read through these
steps to make sure you understand the process, and also to check that I
haven't said something obviously wrong such as getting filenames wrong.)

a. go to greenstone3/resources/java.

b. Make a backup copy of QBRSOAPServer.java.in

c. Now that the original is safe, we're going to mess about with
greenstone3/java/resources/QBRSOAPServer.java.in - which gets converted
to the web service on deployment.

d. Go to the method "protected String processInternal(Element message)"
Let's try getting rid of whitespace around the response message. Replace
what was in the method with the following:

LOG.debug(this.converter.getPrettyString(message));
/* Let the messagerouter process the request message and get the response */
Element response = mr.process(message);
/* won't be null, MR always returns some response */

// Return it as a String formatted for display
//return this.converter.getPrettyString(response);
/* converter.getString() won't format the XML for display - but
hopefully, it won't introduce extra whitespaces either? Additionally, we
trim it just to be doubly sure. */
return this.converter.getString(response).trim();

Try the following steps with the above code first. And if it doesn't
make any difference, try all this again with one additional change in
the final line:
return "<?xml version="1.0"
encoding="utf-8"?>"+this.converter.getString(response).trim();

e. Undeploy the old web service class because you've just modified it:
> greenstone 3
(make sure the greenstone3 server is still running, else do: ant start)
> ant soap-undeploy-site
> type the web service name, in your case QBRSOAPServerlocalsite

f. redeploy the modified QBRSOAPServer class as before:
> ant deploy site
(press Enter, type QBRSOAPServer, press Enter as you'd done before)
The above will compile up the class with the changes you made.

g. Start up the democlient application again. Does it work? If not, look
at the webservice.log file once more. Does it look different?


It's very hard to diagnose what's going wrong when it's still working on
the Windows and Linux machines here. But perhaps the Windows computer at
home may be in the same situation as yours and therefore cause the same
exception you just encountered. Therefore, I will try it on there this
weekend.

If it turns out to work there, perhaps it has to do with the fact that
you're working with Java 1.6 and I've only ever tested these things with
Java 1.5 so far.

Best of luck,
Anupama


Suthanya Doung-In wrote:
>
> Dear Anupama,
>
> Thank you very much for your help:-). I do following the steps as
> your suggestion from the email. I have downloaded and installed GS3
> and demo-client application on the same machine. I edited wsdlURL in
> gs3democlient.
>
> While I do this, Tomcat still running. After that, i meet the error,
> so i can?t use search and browse service.
> Then, i try to install GS3 and democlient again on another computer. The
> message error is the same.
>
> This is the error message:
>
> An error occurred while trying to parse the response:
> ERROR trying to invoke web service- in
> org.greenstone.gs3client.dlservices.GS3ServicesAPIA invokeWith(Object[]
> params):
> Java.lang.NullPointerException
> Exception message:
> Content is not allowed in prolog.
>
> I sent the file that I capture the screens (step by step) about
> run the demo-client application . Please find the attached file.
>
> Many thanks in advance.
>
> Best Wishes,
> Suthanya Doung-in