3 Replies Latest reply on Apr 3, 2002 12:28 PM by Susan

    Exception when creating ClassPathExtension with JSP

    Susan Newbie


      I want to create a ClassPathExtension from my Application (with a JSP), but I've got always the Exception:
      javax.management.RuntimeMBeanException: RuntimeException thrown in postRegister method.

      I tried the same code with RMIClientConnectorImpl and everything works fine. Also by HTLMAdaptor everything works fine. Only my application can't create a classpathextension-MBean

      It would be very nice to know why it doesn't work with my application deployed in JBoss.

      Here is my code:

      objectName = new ObjectName("DefaultDomain:service=ClassPathExtension, name=testload");

      new Object[]{"file:///c:/classes/test.jar"},
      new String[]{"java.lang.String"});

      Many thanks in advance!

        • 1. Re: Exception when creating ClassPathExtension with JSP
          Adrian Brock Master

          The ClassPathExtension MBean assumes it is running
          under an Mlet classloader.
          This won't be the case for a JSP or an ejb

          Wrap your code with the following:
          catch (RuntimeMBeanException e)

          I bet it reports a ClassCastException.


          • 2. Re: Exception when creating ClassPathExtension with JSP
            Susan Newbie

            Thanks for your reply!

            So I can catch the Exception, but the problem is, that the MBean for ClassPathExtension isn't registered in the right way...

            Normally there is an log-output "Added library: ...".
            But this log output doesnt appear. And also the classpath isnt loaded.

            With the HTML Adapter everything works fine. But with the application it doesnt work


            • 3. Re: Exception when creating ClassPathExtension with JSP
              Susan Newbie


              I changed the source from ClassPathExtension.java:

              deleted line:
              MLet mlet = (MLet)Thread.currentThread().getContextClassLoader();

              and added the Method:

              public void addURL(URL u) throws MalformedObjectNameException, InstanceNotFoundException,MBeanException,
              ArrayList servers = MBeanServerFactory.findMBeanServer(null);

              if (servers == null)
              System.out.println("No MBean Server found");
              MBeanServer server=(MBeanServer)servers.get(0);

              ObjectName mletObjectName=null;
              mletObjectName = new ObjectName ("DefaultDomain:service=MLet");
              Object[] params = new Object[]{u};
              String[] signature = new String[]{"java.net.URL"};
              server.invoke(mletObjectName, "addURL", params, signature);


              And every "mlet.addURL(..)" I changed to "addURL(..)", whats calling the new "addURL(URL u)" method.

              Now my application works fine...