Skip to main content

MalformedURLException

java.net.MalformedURLException

MalformedURLException is described in the javadoc comments as:

Thrown to indicate that a malformed URL has occurred. Either no legal protocol could be found in a specification string or the string could not be parsed.
author: Arthur van Hoff version: 1.16, 12/19/03 since: JDK1.0

Where is this exception thrown?

Following, is a list of exception messages cross-referenced to the source code responsible for throwing them. Click on the method link to view the code and see how the exception is thrown.

How is this exception thrown?

The following sub-sections identify where this exception is thrown, and how (or why) the code is throwing the exception.

Any source code quoted in this section is subject to the Java Research License unless stated otherwise.

javax.management.remote.rmi.RMIConnector.findRMIServer(JMXServiceURL, Map)

private RMIServer findRMIServer(JMXServiceURL directoryURL, Map environment) throws NamingException, IOException {
    final boolean isIiop = RMIConnectorServer.isIiopURL(directoryURL, true);
    if (isIiop) {
        environment.put(EnvHelp.DEFAULT_ORB, resolveOrb(environment));
    }
    String path = directoryURL.getURLPath();
    if (path.startsWith('/jndi/')) return findRMIServerJNDI(path.substring(6), environment, isIiop); else if (path.startsWith('/stub/')) return findRMIServerJRMP(path.substring(6), environment, isIiop); else if (path.startsWith('/ior/')) return findRMIServerIIOP(path.substring(5), environment, isIiop); else {
        final String msg = 'URL path must begin with /jndi/ or /stub/ ' + 'or /ior/: ' + path;
        throw new MalformedURLException(msg);
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

javax.management.remote.rmi.RMIConnector.findRMIServerJRMP(String, Map, boolean)

private RMIServer findRMIServerJRMP(String base64, Map env, boolean isIiop) throws IOException {
    final byte[] serialized;
    try {
        serialized = base64ToByteArray(base64);
    } catch (IllegalArgumentException e) {
        throw new MalformedURLException('Bad BASE64 encoding: ' + e.getMessage());
    }
    final ByteArrayInputStream bin = new ByteArrayInputStream(serialized);
    final ClassLoader loader = EnvHelp.resolveClientClassLoader(env);
    final ObjectInputStream oin = (loader == null) ? new ObjectInputStream(bin) : new ObjectInputStreamWithLoader(bin, loader);
    final Object stub;
    try {
        stub = oin.readObject();
    } catch (ClassNotFoundException e) {
        throw new MalformedURLException('Class not found: ' + e);
    }
    return (RMIServer) PortableRemoteObject.narrow(stub, RMIServer.class);
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

javax.management.remote.JMXServiceURL.validate()

private void validate() throws MalformedURLException {
    final int protoEnd = indexOfFirstNotInSet(protocol, protocolBitSet, 0);
    if (protoEnd == 0 || protoEnd < protocol.length() || !alphaBitSet.get(protocol.charAt(0))) {
        throw new MalformedURLException('Missing or invalid protocol ' + 'name: \'' + protocol + '\'');
    }
    validateHost();
    if (port < 0) throw new MalformedURLException('Bad port: ' + port);
    if (urlPath.length() > 0) {
        if (!urlPath.startsWith('/') && !urlPath.startsWith(';')) throw new MalformedURLException('Bad URL path: ' + urlPath);
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

javax.management.remote.JMXServiceURL.validateHost(String)

private static void validateHost(String h) throws MalformedURLException {
    if (isNumericIPv6Address(h)) {
        try {
            InetAddress.getByName(h);
        } catch (Exception e) {
            MalformedURLException bad = new MalformedURLException('Bad IPv6 address: ' + h);
            EnvHelp.initCause(bad, e);
            throw bad;
        }
    } else {
        final int hostLen = h.length();
        char lastc = '.';
        boolean sawDot = false;
        char componentStart = 0;
        loop: for (int i = 0; i < hostLen; i++) {
            char c = h.charAt(i);
            boolean isAlphaNumeric = alphaNumericBitSet.get(c);
            if (lastc == '.') componentStart = c;
            if (isAlphaNumeric) lastc = 'a'; else if (c == '-') {
                if (lastc == '.') break;
                lastc = '-';
            } else if (c == '.') {
                sawDot = true;
                if (lastc != 'a') break;
                lastc = '.';
            } else {
                lastc = '.';
                break;
            }
        }
        try {
            if (lastc != 'a') throw randomException;
            if (sawDot && !alphaBitSet.get(componentStart)) {
                StringTokenizer tok = new StringTokenizer(h, '.', true);
                for (int i = 0; i < 4; i++) {
                    String ns = tok.nextToken();
                    int n = Integer.parseInt(ns);
                    if (n < 0 || n > 255) throw randomException;
                    if (i < 3 && !tok.nextToken().equals('.')) throw randomException;
                }
                if (tok.hasMoreTokens()) throw randomException;
            }
        } catch (Exception e) {
            throw new MalformedURLException('Bad host: \'' + h + '\'');
        }
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

javax.management.remote.JMXServiceURL.validateHost()

private void validateHost() throws MalformedURLException {
    if (host.length() == 0) {
        if (port != 0) {
            throw new MalformedURLException('Cannot give port number ' + 'without host name');
        }
        return;
    }
    validateHost(host);
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

javax.management.remote.rmi.RMIConnectorServer.isIiopURL(JMXServiceURL, boolean)

static boolean isIiopURL(JMXServiceURL directoryURL, boolean strict) throws MalformedURLException {
    String protocol = directoryURL.getProtocol();
    if (protocol.equals('rmi')) return false; else if (protocol.equals('iiop')) return true; else if (strict) {
        throw new MalformedURLException('URL must have protocol ' + '\'rmi\' or \'iiop\': \'' + protocol + '\'');
    }
    return false;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.rmi.Naming.parseURL(String)

/**
     * Dissect Naming URL strings to obtain referenced host, port and
     * object name.
     * @return an object which contains each of the above
     * components.
     * @exception MalformedURLException if given url string is malformed
     */
private static ParsedNamingURL parseURL(String str) throws MalformedURLException {
    try {
        URI uri = new URI(str);
        if (uri.getFragment() != null) {
            throw new MalformedURLException('invalid character, '#', in URL name: ' + str);
        } else if (uri.getQuery() != null) {
            throw new MalformedURLException('invalid character, '?', in URL name: ' + str);
        } else if (uri.getUserInfo() != null) {
            throw new MalformedURLException('invalid character, '@', in URL host: ' + str);
        }
        String scheme = uri.getScheme();
        if (scheme != null && !scheme.equals('rmi')) {
            throw new MalformedURLException('invalid URL scheme: ' + str);
        }
        String name = uri.getPath();
        if (name != null) {
            if (name.startsWith('/')) {
                name = name.substring(1);
            }
            if (name.length() == 0) {
                name = null;
            }
        }
        String host = uri.getHost();
        if (host == null) {
            host = '';
            if (uri.getPort() == -1) {
                String authority = uri.getAuthority();
                if (authority != null && authority.startsWith(':')) {
                    authority = 'localhost' + authority;
                    uri = new URI(null, authority, null, null, null);
                }
            }
        }
        int port = uri.getPort();
        if (port == -1) {
            port = Registry.REGISTRY_PORT;
        }
        return new ParsedNamingURL(host, port, name);
    } catch (URISyntaxException ex) {
        throw (MalformedURLException) new MalformedURLException('invalid URL string: ' + str).initCause(ex);
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.net.JarURLConnection.parseSpecs(URL)

private void parseSpecs(URL url) throws MalformedURLException {
    String spec = url.getFile();
    int separator = spec.indexOf('!');
    if (separator == -1) {
        throw new MalformedURLException('no ! found in url spec:' + spec);
    }
    jarFileURL = new URL(spec.substring(0, separator++));
    entryName = null;
    if (++separator != spec.length()) {
        entryName = spec.substring(separator, spec.length());
        entryName = ParseUtil.decode(entryName);
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

Comments

Popular posts from this blog

NullPointerException

java.lang.NullPointerException NullPointerException is described in the javadoc comments as: Thrown when an application attempts to use null in a case where an object is required. These include: Calling the instance method of a null object. Accessing or modifying the field of a null object. Taking the length of null as if it were an array. Accessing or modifying the slots of null as if it were an array. Throwing null as if it were a Throwable value. Applications should throw instances of this class to indicate other illegal uses of the null object. author: unascribed version: 1.19, 12/19/03 since: JDK1.0 Where is this exception thrown? Following, is a list of exception messages cross-referenced to the source code responsible for throwing them. Click on the method link to view the code and see how the exception is thrown. The message ' java.lang.NullPointerException: ' is thrown within the method: com.sun.corba.se.impl.interceptors.ClientRequestInfoImpl.get_r

Connection refused: No available router to destination

This is a simple symptom-cause-solution blog entry only. I hope these blogs will help fellow administrators. Symptom The following exception occurs in WebLogic server logs. Most likely to occur during WebLogic server start-up, but similar exceptions may occur at other times. java.net.ConnectException: t3://myserver:8000: Destination unreachable; nested exception is: java.net.ConnectException: Connection refused: connect; No available router to destination] at weblogic.jndi.internal.ExceptionTranslator.toNamingException(ExceptionTranslator.java:49) at weblogic.jndi.WLInitialContextFactoryDelegate.toNamingException(WLInitialContextFactoryDelegate.java:773) at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:363) at weblogic.jndi.Environment.getContext(Environment.java:307) at weblogic.jndi.Environment.getContext(Environment.java:277) Cause This message (Connection refused: connect; No available

Recovering WebLogic Passwords

In one of my previous articles ( here ) I explained that the SerializedSystemIni.dat file in WebLogic contains the key used to encrypt and decrypt passwords. If you're not currently keeping this file secure I suggest you do, as with it someone can (to name a few things): Decrypt the WebLogic admin username and password from boot.properties. Recover database passwords, if JDBC Connection pools are configured, from config.xml. Recover the keystore passwords from config.xml and obtain SSL certificates stored in the jks keystores. Essentially, they can do whatever they want, so if you don't know who can read your SerializedSystemIni.dat files, look... now. In this article I will show how easy it is for this file to be used to recover lost passwords via a simple WLST script. The Script The script I use to decrypt passwords is incredibly short, and it works with WebLogic 8, 9 and 10 (probably for version 7 too). To use it, just create a new file called decryptpwd.py and paste the fol