10 Replies Latest reply: Jan 2, 2013 11:11 PM by EJP RSS



      I am using jetty 6_1_8 for creating a Http Server Adapter. I am able to access it in linux but I am getting the following exception in windows
      java.lang.IllegalArgumentException: name
           at sun.misc.URLClassPath$Loader.findResource(URLClassPath.java:458)
           at sun.misc.URLClassPath.findResource(URLClassPath.java:145)
           at java.net.URLClassLoader$2.run(URLClassLoader.java:362)
           at java.security.AccessController.doPrivileged(Native Method)
           at java.net.URLClassLoader.findResource(URLClassLoader.java:359)
           at java.lang.ClassLoader.getResource(ClassLoader.java:978)
           at org.mortbay.jetty.webapp.WebAppClassLoader.getResource(WebAppClassLoader.java:258)
           at org.mortbay.resource.Resource.newSystemResource(Resource.java:202)
      I saw jetty code and it is like


      name is the location of webdefault.xml which is (E:\DEV_E\install_524_mssql_2008\install\noapp\etc\webdefault.xml) for windows
      and for windows it is /ais_local/share/alodha/52/gis_CATA_5241_18000/platform_core/install/noapp/etc/webdefault.xml

      I want to understand why it is throwing illegalArgumentException:name?

      Also when I dont use this custom webdefault.xml (using jetty provided default webdefault.xml) then it works fine.

      Edited by: 821458 on Dec 27, 2012 1:31 AM
        • 1. Re: IllegalArgumentException:name
          Well the one thing you can assume from it is that something is wrong with the name being passed. If the exception does not further define what is wrong with it, then its anyone's guess.

          Its a path, so you can check off a couple of easy assumptions to make.

          - path/file does not actually exist
          - typo in path/name
          - the server doesn't have the rights to read the given file

          For further assistance you might want to try finding a Jetty forum or mailing list.

          One thing you can try is on Windows to also just use Linux style slashes and see if that changes anything. So use:
          • 2. Re: IllegalArgumentException:name
            I have checked this path, by creating File object and saw that the file exist.
            • 3. Re: IllegalArgumentException:name
              That's one of the suggestions I made, now on to the others.
              • 4. Re: IllegalArgumentException:name
                I want to know why and when ClassLoader.getResource(name) can give this exception.

                The below is the code for URLClassLoader which throws the exception. I just want to understand in what conditions it can throw MalformedURLException which ultimately throws IllegalArgumentException:name
                Resource getResource(final String name, boolean check) {
                                final URL url;
                                try {
                                    url = new URL(base, ParseUtil.encodePath(name, false));
                                } catch (MalformedURLException e) {
                                    throw new IllegalArgumentException("name");
                • 5. Re: IllegalArgumentException:name
                  When the URL is illegal. In your case, when it contains backslashes. You are using a file name where you should be using a URL, and a relative URL at that, relative to your CLASSPATH. That's how getResource() works.
                  • 6. Re: IllegalArgumentException:name
                    Can you please tell me what is the role of base in the below line

                    url = new URL(base, ParseUtil.encodePath(name, false));

                    I think it has something to do with this issue.
                    • 7. Re: IllegalArgumentException:name
                      • 8. Re: IllegalArgumentException:name
                        I think it has something to do with this issue.
                        It doesn't. As I've already told you, the 'name' argument you are supplying is already wrong, in the way I have already described. That's why the exception says 'name', not 'base'.
                        • 9. Re: IllegalArgumentException:name
                          your hardcoding the "name" in exception
                           throw new IllegalArgumentException(e.getMessage()+" and path is"+name);
                          • 10. Re: IllegalArgumentException:name
                            No he isn't. getResource() is doing that, in 'throw new IllegalArgumentException("name");'. The code you quoted doesn't hardcode 'name' at all.