3 Replies Latest reply on Mar 20, 2003 1:48 PM by Brent Quinlan

    RMI and MalformedUrlException

    Jason Evans Newbie

      Hello, I am running JBoss 3.0.2 on Windows 2000. From within a servlet, I am trying to create an RMI remote object and export it to an externally started rmiregistry process. This worked fine under JBoss2.4.4/Tomcat3.0.1, but now when I try to bind the object to the rmiregistry, I get UnmarshalException, with an underlying "MalformedUrlException: no protocol".

      Here is my code:

      Registry rmiRegistry = LocateRegistry.getRegistry (port);
      Object myObject = // Get my object to export somehow...
      rmiRegistry.rebind (bindname, myObject);

      Anyone have any ideas?



        • 1. Re: RMI and MalformedUrlException
          Jason Evans Newbie

          I just tried the same code outside of the servlet (cut and paste to a standalone test app), and everything works fine. I am stumped as to why it wouldn't work from within JBoss.

          • 2. Re: RMI and MalformedUrlException
            Jason Evans Newbie

            Ha! I solved it! Basically what was happening is this:

            My TEMP and TMP environment variables were set to a path that contained "Documents and Settings". JBoss uses these directories to expand war and ear files into. These then become part of the classpath used by the the web application ClassLoader.

            Somehow I think this classpath was being sent to the rmiregistry as part of the server codebase (not completely sure about this). So when rmiregistry tried to download the stub class from the codebase, it was trying to form a url that contained a space, which apparently is illegal. It then threw an exception, "MalformedUrlException: no protocol: and". Of course, the "and" was from "Documents and Settings".

            So what I did was (in the JBoss run.bat) to change my TMP and TEMP environment variables to point to a directory with no spaces. I'm not sure which of these variables it is actually using, so I set both. This fixed the problem.

            Also, in the process I went to the http://myserver:8080/jmx-console page, which is where I saw the classpath for my web application, which is how I figured this out. This is a great tool to see what is going on in the server.


            • 3. Re: RMI and MalformedUrlException
              Brent Quinlan Newbie

              Good Post. Thanks for taking the time to post your own solution, saved me a lot of time :-)