the call to getResources with null resourceName is causing this error 
referencing the javadoc for rev 117 located@
http://www.opensymphony.com/xwork/api/

getResources
public static Iterator<URL> getResources(String resourceName,
                                         Class callingClass,
                                         boolean aggregate)
                                  throws IOException
Load all resources with a given name, potentially aggregating all results 
 from the searched classloaders.  If no results are found, the resource name
 is prepended by '/' and tried again.

 This method will try to load the resources using the following methods (in 
order):
 From Thread.currentThread().getContextClassLoader()
  From ClassLoaderUtil.class.getClassLoader()
  callingClass.getClassLoader()
 

Parameters:resourceName - The name of the resources to loadcallingClass - The 
Class object of the calling object
Throws:
IOException

but wait theres an open bug on this issue

http://mail-archives.apache.org/mod_mbox/struts-issues/200806.mbox/[EMAIL 
PROTECTED]

but this bug that was quashed with the release of 2.1.3.GA
https://issues.apache.org/struts/browse/WW-2653

Op Noted that he wanted a default validators.xml to be read and a default.xml 
if that did'nt work the patch is to make specific reference to resourceName of 
com/opensymphony/xwork2/validator/validators/default.xml
(note the validator classes listed in default.xml)
<validators>
    <validator name="required" 
class="com.opensymphony.xwork2.validator.validators.RequiredFieldValidator"/>
 
if that fails the routine looks for validators.xml which contains a litany of 
validators definitions e.g.
<validators>
    <validator name="required" 
class="com.opensymphony.xwork2.validator.validators.RequiredFieldValidator"/>

It is very likely you have a pre June 08 version of xwork so the choices are 
1)resync with latest xwork and rebuild the latest xwork jars and redeploy to 
all of your struts webapp(s)
2)pull down the struts libraries that have this xwork patch 2.1.3.GA and 
redeploy to struts webapp(s)

//Here is a brief synopsis of mikes patch which will Parse default validator 
configurations 
            String resourceName = 
"com/opensymphony/xwork2/validator/validators/default.xml";             
            retrieveValidatorConfiguration(resourceName);
        // Overwrite and extend defaults with application specific validator 
configurations
        resourceName = "validators.xml";
        retrieveValidatorConfiguration(resourceName);

        // Add custom (plugin) specific validator configurations
        for (File file : files) {
            retrieveValidatorConfiguration(file.getName());
        }
so deploying from Struts 2.1.3.GA will fix this error..please let us know if 
this is not the case

Thanks
Martin 
______________________________________________ 
Disclaimer and confidentiality note 
Everything in this e-mail and any attachments relates to the official business 
of Sender. This transmission is of a confidential nature and Sender does not 
endorse distribution to any party other than intended recipient. Sender does 
not necessarily endorse content contained within this transmission. 




> Date: Thu, 11 Dec 2008 07:28:13 -0800
> From: [EMAIL PROTECTED]
> To: user@struts.apache.org
> Subject: Validation throwing IllegalArgumentException
> 
> 
> I am using Struts 2 with the XML based validation and it is throwing the
> following exception:
> 
> info: CORE3282: stdout: ERROR - ValidatorFactory.parseValidators(335) |
> Unable to load file:C:/Projects/test/webapps/default/WEB-INF/classes
> info: CORE3282: stdout: java.lang.IllegalArgumentException: URI is not
> hierarchical
> info: CORE3282: stdout:         at java.io.File.<init>(File.java:335)
> info: CORE3282: stdout:         at
> com.opensymphony.xwork2.validator.ValidatorFactory.parseValidators(ValidatorFactory.java:332)
> info: CORE3282: stdout:         at
> com.opensymphony.xwork2.validator.ValidatorFactory.<clinit>(ValidatorFactory.java:234)
> info: CORE3282: stdout:         at
> com.opensymphony.xwork2.validator.ValidatorFileParser.addValidatorConfigs(ValidatorFileParser.java:205)
> info: CORE3282: stdout:         at
> com.opensymphony.xwork2.validator.ValidatorFileParser.parseActionValidatorConfigs(ValidatorFileParser.java:85)
> info: CORE3282: stdout:         at
> com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.loadFile(AnnotationActionValidatorManager.java:361)
> info: CORE3282: stdout:         at
> com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.buildClassValidatorConfigs(AnnotationActionValidatorManage
> r.java:252)
> ........ (continues listing Struts classes without any further error
> messages)
> 
> I examined the code of ValidatorFactory.parseValidators and line 326 seems
> to be throwing the exception:
> 
> 318             List<File> files = new ArrayList<File>();
> 319           try {
> 320               Iterator<URL> urls = ClassLoaderUtil.getResources("",
> ValidatorFactory.class, false);
> 321               while (urls.hasNext()) {
> 322                   URL u = urls.next();
> 323                   try {
> 324                       URI uri = new URI(u.toExternalForm().replaceAll("
> ", "%20"));
> 325                       if ("file".equalsIgnoreCase(uri.getScheme())) {
> 326                           File f = new File(uri);
> 327                           FilenameFilter filter = new FilenameFilter() {
> 328                               public boolean accept(File file, String
> fileName) {
> 329                                   return
> fileName.contains("-validators.xml");
> 330                               }
> 331                           };
> 332                          
> files.addAll(Arrays.asList(f.listFiles(filter)));
> 333                       }
> 334                   } catch (Exception ex) {
> 335                       LOG.error("Unable to load " + u.toString(), ex);
> 
> Code Located at:
> http://svn.opensymphony.com/fisheye/browse/xwork/branches/2.0/src/java/com/opensymphony/xwork2/validator/ValidatorFactory.java?r=1850
> 
> Does anyone have any suggestions about what I can do to make the URL
> hierarchial so that the validator doesn't throw this exception? The path
> provided in the stack trace does point to the location where my Java class
> files and my Form-validation.xml file is located. Any suggestions would be
> appreciated.
> 
> Thanks!!
> 
> Note: I also included my struts config files below in case there is anything
> useful in them.
> 
> My Form-validation.xml file (located in
> C:/Projects/test/webapps/default/WEB-INF/classes/org/web):
> 
> <!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator
> 1.0.2//EN" 
> "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd";>
> 
> <validators>
>     <field name="name">
>         <field-validator type="required">
>             <message>The user name field is required!</message>
>         </field-validator>
>     </field>
> </validators>
> 
> My form.jsp page:
> 
> <%@ page language="java" %>
> <%@ taglib uri="/struts-tags" prefix="s" %>
> <html>
> <body>
> <form action="Form" theme="simple">
> <p>
> Please enter your name: <input type="text" name="name" /><br />
> <s:fielderror />
> <s:actionerror />
> <input type="submit" value="submit" />
> </p>
> </form>
> </body>
> </html>
> 
> My Struts action code:
> 
> package org.web;
> import com.opensymphony.xwork2.ActionSupport;
> public class Form extends ActionSupport {
> 
> public String name;
> 
> public String execute() {
> return "success";
> }
> 
> public getName() {
> return name;
> }
> 
> public setName(String name) {
> this.name = name;
> }
> 
> My Struts.xml file:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts PUBLIC
>     "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
>     "http://struts.apache.org/dtds/struts-2.0.dtd";>
> 
> <struts>
>     <package name="default" namespace="/" extends="struts-default">
>     <action name="Form" class="org.web.Form">
>           <result name="success">success.jsp</result>
>           <result name="input">form.jsp</result>
>     </action>
> </struts>
> -- 
> View this message in context: 
> http://www.nabble.com/Validation-throwing-IllegalArgumentException-tp20957607p20957607.html
> Sent from the Struts - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

_________________________________________________________________
You live life online. So we put Windows on the web. 
http://clk.atdmt.com/MRT/go/127032869/direct/01/

Reply via email to