Thanks Niall,
thats it, you are right. Many thanks for opening my eyes...how blind can one
single person be ? :)

Well to be true, the exception send me in a complete wrong direction. It
took
me an hour to see that there is other xml in the background and that draw
me further in that wrong (very wrong) direction.....

So maybe another reaction from the ValidatorResources class on a silly null
input would be
perhaps useful for fools like me :)

Greetings,
Lian

On 2/26/07, Niall Pemberton <[EMAIL PROTECTED]> wrote:

Lian,

When I pass a null value for InputStream to the ValidatorResources
constructor I can reproduce the exact same stack trace and error.
There clearly is an error in the java code you posted with you not
initializing the InputSource at all. If you're saying you fixed that
then the implication is that
getClass().getResourceAsStream(validationDefinition) is returning
null. Either way, from what I can see thats where the error lies. Try
putting a check for null before you initialize the ValidatorResources:

if (in == null) {
      throw new IllegalArgumentException("resouces missing");
}
resources = new ValidatorResources(in);

Niall

On 2/26/07, Lian Ort <[EMAIL PROTECTED]> wrote:
> Hello Niall,
>
> no its actually regardless if i sent in that stream or a null value. The
> MalformedURLException happens before my own stream is parsed.
> It happens during Digester reads the file "digester-rules.xml" (which is
> from the validator jar file). In the logging output the error happens
> in the code following that line
>
> DEBUG [EMAIL PROTECTED] 16:27:26,068]
> org.apache.commons.validator.ValidatorResources: Loading rules from
> 'jar:file:/D:/cc/lib/commons/commons-
> validator-1.3.1.jar!/org/apache/commons/validator/digester-rules.xml'
> ......
>
> The case is very weird: as i mentioned before when i compile and run the
> validator example everything goes fine.
>
> Greetings,
> Lian
>
>
> On 2/26/07, Niall Pemberton <[EMAIL PROTECTED]> wrote:
> >
> > Is your InputStream null? I think you need to change the following
line:
> >
> >     getClass().getResourceAsStream(validationDefinition);
> >
> > to
> >
> >     in = getClass().getResourceAsStream(validationDefinition);
> >
> > Niall
> >
> > On 2/26/07, Lian Ort <[EMAIL PROTECTED]> wrote:
> > > Hello,
> > > i try to use Commons Validator outside of Struts (in an simple java
> > > application context). Therefore i wrote a simply xml:
> > >
> > > <!DOCTYPE form-validation PUBLIC
> > >      "-//Apache Software Foundation//DTD Commons Validator Rules
> > > Configuration 1.1//EN"
> > >      "http://jakarta.apache.org/commons/dtds/validator_1_1.dtd";>
> > >
> > >
> > > <form-validation>
> > >
> > > </form-validation>
> > >
> > > The code for is simple and is mostly copied from the example
> > > ValidateExample.java (i put that code in an init method):
> > >     private boolean init() {
> > >         InputStream in = null;
> > >         boolean initOk = true;
> > >
> > >         apps = null;
> > >         try {
> > >             apps = ResourceBundle.getBundle(resourceName);
> > >         } catch (Exception lEx) {
> > >             log.error("Error during open of properties file " +
> > resourceName
> > > + ": ", lEx);
> > >         }
> > >
> > >         try {
> > >
> > >             getClass().getResourceAsStream(validationDefinition);
> > >             resources = new ValidatorResources(in);
> > >
> > >         } catch (Exception ex) {
> > >             log.error("Error during reading the validation
definition
> > file
> > > "+validationDefinition+":\n"+ex.toString()+"\n");
> > >             ex.printStackTrace(System.err);
> > >             initOk = false;
> > >         } finally {
> > >             // Make sure we close the input stream.
> > >             if (in != null) {
> > >                  try {
> > >                      in.close();
> > >                  } catch (Exception ignore) {}
> > >             }
> > >         }
> > >         return initOk;
> > >     }
> > >
> > > This compiles in Eclipse.
> > >
> > > At runtime there is an MalformedURLException thrown at the line
> > "resources =
> > > new ValidatorResources(in);"
> > >
> > > java.net.MalformedURLException
> > >         at java.net.URL.<init>(Unknown Source)
> > >         at java.net.URL.<init>(Unknown Source)
> > >         at java.net.URL.<init>(Unknown Source)
> > >         at
> > >
> >
com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity
> > (Unknown
> > > Source)
> > >         at
> > >
> >
com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion
> > (Unknown
> > > Source)
> > >         at
> > > com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse
> > (Unknown
> > > Source)
> > >         at
> > > com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse
> > (Unknown
> > > Source)
> > >         at
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse
> > (Unknown
> > > Source)
> > >         at
> > > com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse
> > (Unknown
> > > Source)
> > >         at org.apache.commons.digester.Digester.parse(Digester.java
> > :1765)
> > >         at org.apache.commons.validator.ValidatorResources.<init>(
> > > ValidatorResources.java:156)
> > >         at org.apache.commons.validator.ValidatorResources.<init>(
> > > ValidatorResources.java:133)
> > >         at
de.bgnet.dmig.pdm.imp.validation.ImportValidationTest.init(
> > > ImportValidationTest.java:75)
> > >         at
> > de.bgnet.dmig.pdm.imp.validation.ImportValidationTest.getInstance
> > > (ImportValidationTest.java:41)
> > >         at de.bgnet.dmig.pdm.imp.processing.PdmImport.init(
> > PdmImport.java
> > > :119)
> > >         at de.bgnet.dmig.pdm.PdmBatch.init(PdmBatch.java:81)
> > >         at de.bgnet.dmig.pdm.PdmBatch.main(PdmBatch.java:38)
> > >
> > > I have no clue what goes wrong here. When i compile and run the
example
> > from
> > > the Validator package, everything goes fine.
> > >
> > > I would appreciate any help.
> > > Many thanks,
> > > Lian

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to