Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 60510 invoked from network); 26 Feb 2007 15:51:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Feb 2007 15:51:41 -0000 Received: (qmail 40712 invoked by uid 500); 26 Feb 2007 15:51:44 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 40703 invoked by uid 500); 26 Feb 2007 15:51:44 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 40692 invoked by uid 99); 26 Feb 2007 15:51:44 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Feb 2007 07:51:44 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of niall.pemberton@gmail.com designates 66.249.92.174 as permitted sender) Received: from [66.249.92.174] (HELO ug-out-1314.google.com) (66.249.92.174) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Feb 2007 07:51:33 -0800 Received: by ug-out-1314.google.com with SMTP id 30so745474ugs for ; Mon, 26 Feb 2007 07:51:09 -0800 (PST) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=mb8cHXuBSpxdtCyhIfOJVUp0W2NZUT5qqziwaGKvzhDJVcZHV4IpP5qIF4cbcGYy4lG4XPDGEzsMbztUdwBgiMGo9eU3gECokQzr5dHSOp2+msQDV+DNPOk8faSZUFyITwmThH6rUz4YcFknheLYVrUg0slomrM5N9z1OXlsHLA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=jNUuDIrsJSxarpWPUSOVdUJHZ5R3yFeY/qqS5Nd3FQrDGCfC6KZznJKW7i/mG0qP2YZKvlq0JmfrWpcNMLXkp0ZV9mibiYqGxOCDWBLL1NMsyyHCoks8RiPMfvvjiDUJPpx/1TEDUgOh5g6QuHCw9mDRts2uoLHK5IG4Zx6IGAY= Received: by 10.78.165.16 with SMTP id n16mr234657hue.1172505066379; Mon, 26 Feb 2007 07:51:06 -0800 (PST) Received: by 10.78.66.6 with HTTP; Mon, 26 Feb 2007 07:51:06 -0800 (PST) Message-ID: <55afdc850702260751t72d68c5sc651f8ba9fbc8221@mail.gmail.com> Date: Mon, 26 Feb 2007 15:51:06 +0000 From: "Niall Pemberton" To: "Jakarta Commons Users List" Subject: Re: Validator MalformedURLException In-Reply-To: <641a64780702260731y6ae9ed63o609fb0010862a9a8@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <641a64780702260643p303bc06fm5799e977abd15985@mail.gmail.com> <55afdc850702260718t3b343a30xc823156f5ce62687@mail.gmail.com> <641a64780702260731y6ae9ed63o609fb0010862a9a8@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org 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 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 [main@2007-02-26 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 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 wrote: > > > Hello, > > > i try to use Commons Validator outside of Struts (in an simple java > > > application context). Therefore i wrote a simply xml: > > > > > > > > "-//Apache Software Foundation//DTD Commons Validator Rules > > > Configuration 1.1//EN" > > > "http://jakarta.apache.org/commons/dtds/validator_1_1.dtd"> > > > > > > > > > > > > > > > > > > > > > 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.(Unknown Source) > > > at java.net.URL.(Unknown Source) > > > at java.net.URL.(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.( > > > ValidatorResources.java:156) > > > at org.apache.commons.validator.ValidatorResources.( > > > 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: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org