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

    Exception when creating ClassPathExtension with JSP

    Susan Newbie

      Hi!

      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");

      server.createMBean
      ("org.jboss.util.ClassPathExtension",
      objectName,
      new Object[]{"file:///c:/classes/test.jar"},
      new String[]{"java.lang.String"});

      Many thanks in advance!
      Susan

        • 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:
          try
          {
          ...
          }
          catch (RuntimeMBeanException e)
          {
          e.getTargetException().printStackTrace();
          }

          I bet it reports a ClassCastException.

          Regards,
          Adrian

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

            Hi!
            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

            Susan

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

              Hi!

              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,
              ReflectionException
              {
              ArrayList servers = MBeanServerFactory.findMBeanServer(null);

              if (servers == null)
              {
              System.out.println("No MBean Server found");
              }
              else
              {
              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);
              }//else

              }


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

              Now my application works fine...

              Thanks
              Susan