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

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 router to destination) is a kind of "catch…

BAD_CERTIFICATE - A corrupt or unuseable certificate...

This is a simple symptom-cause-solution blog entry only. I hope these blogs will help fellow administrators.
Symptom
In wls_utc, when trying to test a webservice using SSL, the following error message is received: javax.net.ssl.SSLKeyException: FATAL Alert:BAD_CERTIFICATE - A corrupt or unuseable certificate was received.
If SSL debugging is enabled, the following error also appears in the logs: ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)' <1254822672320>>
verification failed because RSA key public exponent [3] is too small
Cause
The certificate encryption is of a weaker strength than expected by newer versions of Java.
Solution
Add the flag "-Dweblogic.security.SSL.allowSmallRSAExponent=true" to the server startup parameters.
References


None.

WebLogic Admin Console

WebLogic Admin Console
The WebLogic Admin Console is a web-based, user interface used to configure and control a set of WebLogic servers or clusters (i.e. a "domain"). In any logical group of WebLogic servers there must exist one admin server, which hosts the WebLogic Admin Console application and manages the associated configuration files.
WebLogic Administrators will use the Administration Console for a number of tasks, including:
Starting and stopping WebLogic servers or entire clusters.Configuring server parameters, security, database connections and deployed applications.Viewing server status, health and metrics. Note: It is not strictly necessary to use the Weblogic Admin Console to perform these tasks, as they can be scripted using WLST (the WebLogic Scripting Tool).
Accessing the Admin Console
WebLogic Admin Console Url: http://hostname:port/console.
To access the WebLogic Administration Console, assuming the admin server has been started, goto the above url. Where hostname…