The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

import-bot (20211) [Avatar] Offline
#1
[Originally posted by bigbadbuford]

I have managed to create the JAR files, but I am having problems running them
and it is driving me crazy. When I use the build.xml file, it builds and
tests fine, but when I run the code, it tells me that the XMLEntityReader
class cannot be found. I have tried everything I can think of to get it to
work with no luck. I have the Xerces.jar file from the website in the antlib
directory, and I am using the batch files to run the code listed on Running
Jar Files thread. Do I have to see a CLASSPATH environment variable or
something else to get it to work? Any help would be greatly appreciated!

John
import-bot (20211) [Avatar] Offline
#2
Re: Running Source Code
[Originally posted by iainshigeoka]

> I have managed to create the JAR files, but I am having problems running them
> and it is driving me crazy. When I use the build.xml file, it builds and
> tests fine, but when I run the code, it tells me that the XMLEntityReader
> class cannot be found. I have tried everything I can think of to get it to
> work with no luck. I have the Xerces.jar file from the website in the antlib
> directory, and I am using the batch files to run the code listed on Running
> Jar Files thread. Do I have to see a CLASSPATH environment variable or
> something else to get it to work? Any help would be greatly appreciated!

Are you using jdk 1.4.* or have other SAX libraries on your classpath? There
can be some class mixups because jdk 1.4 includes a SAX parser and you will be
surprised how many other tools will put things like Xerces onto the classpath
which can mix up Xerces versions.

The Xerces SAX parser hack described in the book to make it handle streaming
XML is tightly tied to that particular version of Xerces. I haven't checked
but wouldn't be surprised if earlier or later versions of Xerces don't use the
same internal classes.

My suggestion is to make sure that the Xerces library from the website is
being included in your classpath when running the server. If you're using a
batch file to startup the server, then unset the CLASSPATH environmental
variable in the batch file, and set up your classpath on the command line
using the -cp option.

If this advice doesn't help, please send the batch file you're using for
startup, as well as your basic configuration, your OS, and your jvm version
(java -version). Also running "set" on the commandline should dump your
current environmental variables which should also help (you can delete
anything not relevant to to java to protect your privacy).

On a related note, I'd like your opinion on the example. I've found a much
cleaner way of doing XML parsing using a less well known standard called "pull
parsing" (www.xmlpull.org). What is your opinion on me porting the example
code to using xml pull? This will solve these Xerces problems and actually
improves performance of the server significantly. The downside will be that
the online example files for the server won't follow the examples in the book
and XML pull is not as well known as SAX (xml push parsing).

-iain
import-bot (20211) [Avatar] Offline
#3
Re: Running Source Code
[Originally posted by micael]


> On a related note, I'd like your opinion on the example. I've found a much
> cleaner way of doing XML parsing using a less well known standard called "pull
> parsing" (www.xmlpull.org). What is your opinion on me porting the example
> code to using xml pull? This will solve these Xerces problems and actually
> improves performance of the server significantly. The downside will be that
> the online example files for the server won't follow the examples in the book
> and XML pull is not as well known as SAX (xml push parsing).
>
> -iain

I would like to be able to do both. Could you provide both options with some
small README.txt file explaining the basic details?

-Micael
import-bot (20211) [Avatar] Offline
#4
Re: Running Source Code
[Originally posted by iain.shigeoka]

>
> > On a related note, I'd like your opinion on the example. I've found a much
> > cleaner way of doing XML parsing using a less well known standard called
"pull
> > parsing" (www.xmlpull.org). What is your opinion on me porting the example
> > code to using xml pull? This will solve these Xerces problems and actually
> > improves performance of the server significantly. The downside will be that
> > the online example files for the server won't follow the examples in the
book
> > and XML pull is not as well known as SAX (xml push parsing).
> >
> > -iain
>
> I would like to be able to do both. Could you provide both options with some
> small README.txt file explaining the basic details?

Let me look into this. The basic way to work around this is to use XPP as the
parser and then convert the pull tokens into SAX events so the rest of the
code doesn't change. The only big difference from an outsider viewpoint is
that Xerces is no longer needed and the Xerces streaming XML workaround can be
eliminated.

Making this switchable is the tricky part. I think it may be cleaner to
abandon the Xerces support as it appears to not work with newer versions of
Xerces anyhow and I don't want to keep creating workarounds for every version
of Xerces.

-iain
import-bot (20211) [Avatar] Offline
#5
Re: Running Source Code
[Originally posted by micael]

Sounds good to me. You going to keep us updated here? I love the book, by
the way. Almost finished it in one day (24 hrs). I am really tired!
import-bot (20211) [Avatar] Offline
#6
Re: Running Source Code
[Originally posted by iain.shigeoka]

> Sounds good to me. You going to keep us updated here? I love the book, by
> the way. Almost finished it in one day (24 hrs). I am really tired!

Yes, I'll definitely try to remember to announce it on the forums.

Glad you enjoyed the book. Please leave a review at Amazon.com. That really
helps me out.

Thanks.

-iain
import-bot (20211) [Avatar] Offline
#7
Re: Running Source Code
[Originally posted by micael]


> Glad you enjoyed the book. Please leave a review at Amazon.com. That really
> helps me out.
>

I left a review. I am Swords and Plowshares, Ltd.
import-bot (20211) [Avatar] Offline
#8
Re: Running Source Code
[Originally posted by iain.shigeoka]

>
> > Glad you enjoyed the book. Please leave a review at Amazon.com. That really
> > helps me out.
> >
>
> I left a review. I am Swords and Plowshares, Ltd.

Thanks.

-iain
import-bot (20211) [Avatar] Offline
#9
Re: Running Source Code
[Originally posted by darren_t_johnson]

Hello Iain and others.
I'm having a very similar (if not the same) problem. I can build the source
(from chpsmilie. But when i try to run it, it complains about not finding the
XMLEntityReader class. I'm using xerces 1.4.4. If i remove those libraries
from my path, it fails to even compile. It complains about the SAX class,
streaming readers ... I'm assuming that would remove the possibility of
haveing other xerces/sax jar/class files being included?

Now, your book says to use xerces2 2.0.0. So i've tried the libraries from
the following releases of xerces

Xerces-J-bin.2.0.0
Xerces-J-bin.2.2.1
deprecatedXerces-J-bin.2.0.0
oldXerces-J-bin.2.0.0.beta4


Any ideas you might have would be more than welcome. That goes for anyone
else that may read this.


On a second not, you book was fantastic. Very easy to read, but it also
contained alot of usefull information. As you suggested, i'll put a review on
amazon for you.

Darren
import-bot (20211) [Avatar] Offline
#10
Re: Running Source Code
[Originally posted by iain.shigeoka]

Hi Darren,

Glad you got things running and thanks for writing the review. The Xerces
workaround seems to be pretty troublesome. I'm investigating other ways to
obtain the same SAX streaming XML reading without the workaround.

Hope you manage to get your classpath cleaned up. It can get pretty complex.
If you're on windows, I'd strongly suggest using a batch file to launch things
so you can explicitly set your classpath for use with the code. otherwise,
things tend to mess with your classpath when you don't expect it causing
headaches.

-iain
import-bot (20211) [Avatar] Offline
#11
Re: Running Source Code
[Originally posted by darren_t_johnson]

Hi again.
After even more messing around, i just specified the exerces.jar file
explicitly when i execute the jar files and this works. So now i just need to
figure out why its not being found in my classpath.

So dont bother responding to these 2 messages. Its been resolved.