Well, I finally got the Digester to work outside a servlet, but I'm not sure
I would call the result "standalone". I never quite figured out where the
earlier NullPointerException was coming from, but somewhere along the line
it went away. Part of the solution seemed to be not using struts.jar, but
using the Struts source code directly.

What I did was to gradually clone enough of the Struts source tree to build
my application. (That is, I kept copying files until it all compiled!) That
seemed not to require too much until I had to include BeanUtils, at which
point a whole slew of dependencies added themselves in. By the time I was
done, I needed more than 30 Struts source files, and I had to have the JSDK
and JDBC 2.0 classes in my classpath. Seems a bit excessive for an XML
digester...

Unfortunately, that isn't the end of the story, though. Once I ran the
resulting application, I got a NoClassDefFoundError. Once I tracked that one
down, I discovered that I actually needed to have the JSDK in my classpath
to *run* Digester code. This makes no sense to me, but unfortunately it
seems to be the case.

Now, I know the Digester is really intended for use with Struts web
applications (parsing config files, etc), but it just seems like such an
easy-to-use way of handling simple XML files that it would be nice if it was
easy to use standalone. Is this something other people might use? Would it
be worth spending some time (perhaps mine) to isolate the Digester from the
rest of Struts?

--
Martin Cooper
Tumbleweed Communications


----- Original Message -----
From: "Craig R. McClanahan" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, January 03, 2001 12:01 AM
Subject: Re: Problem with Digester used "standalone"


> Martin Cooper wrote:
>
> > I've been trying to use the Digester module on its own (i.e. no other
Struts
> > code, no servlets, no JSP), and have been having problems. At first, I
> > thought it must be my application code, but then I tried copying the
code
> > from the Struts example DatabaseServlet into my own Java application and
> > came across the same problem.
> >
> > The problem happens when addSetProperties() is used. The call itself
> > succeeds, but later on, when Digester.parse() is called, I get the
following
> > error and call stack:
> >
>
> As you can see from the way that Struts itself uses the digester (for
example,
> when parsing struts-config.xml), you can see that the set properties rule
is
> quite common.  Would it be possible to run this in an environment with the
JIT
> turned off, so we can see what line number in SetPropertiesRule is
throwing the
> exception?  Also, could you post the logic you're using to initialize the
> digester -- at least for the patterns that match when you get the
exception?
> (It might also be useful to call digester.setDebug(999) so you can see
trace
> output on System.out).
>
> The most likely cause would be if there are no items on the object stack
> (perhaps because you didn't call an object create rule on the same pattern
> first), but the only way to know is to have a few more details.
>
> Craig
>
>


Reply via email to