1 2 3 Previous Next 33 Replies Latest reply on Jan 12, 2010 11:54 PM by Dave Berry-Oracle

    SEVERE: Error while registering Oracle JDBC Diagnosability MBean

    Shawn Clowater
      I get the following when using the 11g JDBC driver (ojdbc6.jar) when the OracleDriver class is accessed multiple times within the same JVM

      [dbunit] Aug 30, 2007 9:12:44 AM oracle.jdbc.driver.OracleDriver registerMBeans
      [dbunit] SEVERE: Error while registering Oracle JDBC Diagnosability MBean.
      [dbunit] javax.management.InstanceAlreadyExistsException: com.oracle.jdbc:type=diagnosability,name=java.net.URLClassLoader@14318bb
      [dbunit] at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:453)
      [dbunit] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.internal_addObject(DefaultMBeanServerInterceptor.java:1484)
      [dbunit] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:963)
      [dbunit] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:917)
      [dbunit] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:312)
      [dbunit] at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:482)
      [dbunit] at oracle.jdbc.driver.OracleDriver.registerMBeans(OracleDriver.java:305)
      [dbunit] at oracle.jdbc.driver.OracleDriver$1.run(OracleDriver.java:213)
      [dbunit] at java.security.AccessController.doPrivileged(Native Method)
      [dbunit] at oracle.jdbc.driver.OracleDriver.<clinit>(OracleDriver.java:209)
      [dbunit] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      [dbunit] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      [dbunit] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      [dbunit] at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
      [dbunit] at java.lang.Class.newInstance0(Class.java:355)
      [dbunit] at java.lang.Class.newInstance(Class.java:308)
      [dbunit] at org.dbunit.ant.DbUnitTask.createConnection(DbUnitTask.java:340)
      [dbunit] at org.dbunit.ant.DbUnitTask.execute(DbUnitTask.java:266)
      [dbunit] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
      [dbunit] at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
      [dbunit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      [dbunit] at java.lang.reflect.Method.invoke(Method.java:597)
      [dbunit] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
      [dbunit] at org.apache.tools.ant.Task.perform(Task.java:348)
      [dbunit] at org.apache.tools.ant.Target.execute(Target.java:357)
      [dbunit] at org.apache.tools.ant.Target.performTasks(Target.java:385)
      [dbunit] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
      [dbunit] at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
      [dbunit] at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
      [dbunit] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)
      [dbunit] at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
      [dbunit] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
      [dbunit] at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
      [dbunit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      [dbunit] at java.lang.reflect.Method.invoke(Method.java:597)
      [dbunit] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
      [dbunit] at org.apache.tools.ant.Task.perform(Task.java:348)
      [dbunit] at org.apache.tools.ant.Target.execute(Target.java:357)
      [dbunit] at org.apache.tools.ant.Target.performTasks(Target.java:385)
      [dbunit] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
      [dbunit] at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
      [dbunit] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
      [dbunit] at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
      [dbunit] at org.apache.tools.ant.Main.runBuild(Main.java:698)
      [dbunit] at org.apache.tools.ant.Main.startAnt(Main.java:199)
      [dbunit] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
      [dbunit] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)

      In our case we're calling multiple DB operations within the same build file and then after the 1st call we encounter that error for every operation.

      It doesn't fail anything but it would seem that there is a static block in the OracleDriver class that tries to register the MBean every time it is touched whether or not it was previously registered.

      Might consider a flag or some check to prevent this every time as it made some people skittish when they encountered it, lol.
        • 1. Re: SEVERE: Error while registering Oracle JDBC Diagnosability MBean
          dsurber-Oracle
          This should not happen. The MBean is registered only when the driver class is loaded. If the driver class is loaded more than once, then it should be loaded by different ClassLoaders in which case the name of the MBean will be different and you won't get the exception. It should not be possible to load the class multiple times with the same ClassLoader. Can you provide a stand alone test case?

          Douglas
          • 2. Re: SEVERE: Error while registering Oracle JDBC Diagnosability MBean
            Shawn Clowater
            This looks to be a class loader issue. After playing around with this for a bit and looking to see how Ant's class loader behaves I think the following code snippet is indicative to the behviour

            import java.net.URL;
            import java.net.URLClassLoader;

            public class OracleDriverTest {
            public static void main(String[] args) throws Exception {
            OracleDriverTest test = new OracleDriverTest();
            test.test();
            }

            public void test() throws Exception {
            String oracleJar = "/ojdbc6.jar";
            String oracleDriverName = "oracle.jdbc.driver.OracleDriver";

            for (int i = 0; i < 5; i++) {
            MyClassLoader p = new MyClassLoader(new URL[]{this.getClass().getResource(oracleJar)}, this.getClass().getClassLoader());
            Class driver = p.loadClass2(oracleDriverName);
            System.out.println("Driver classloader is " + driver.getClassLoader());
            driver.newInstance();
            }
            System.out.println("Thread classloader = " + Thread.currentThread().getContextClassLoader());
            }

            private class MyClassLoader extends URLClassLoader {
            public MyClassLoader(URL[] urls, ClassLoader parent) {
            super(urls, parent);
            }

            /**
            * Load method to skip checking the parent class loader
            *
            * @param name
            * @return
            * @throws ClassNotFoundException
            */
            public Class<?> loadClass2(String name) throws ClassNotFoundException {
            return super.findClass(name);
            }
            }
            }

            Essentially, what this is simulating is the class loader behavior where the child classloader skips looking to the parent classloader when trying to resolve a class.

            As you can see by my stellar sysouts the driver class is loaded by each individual class loader for each iteration.

            However, the MBean registration looks to be using the Thread's class loader which is the same for each failure.

            for the 5 iterations you will see the original exception displayed 4 times. The first time it registers w/o any issues and then subsequently fails.

            I'm, by far, not a class loader expert so I don't know which side of the fence this undesired behavior falls (Ant or Oracle). I originally logged posted here since this was new behavior since we upgraded to the 11g drivers.
            • 3. Re: SEVERE: Error while registering Oracle JDBC Diagnosability MBean
              dsurber-Oracle
              I don't where the error lies either. I'll contact our ClassLoader gurus and see what they say, but I would like to hear from any other ClassLoader experts as well.

              Joe, Anyone at BEA you can ask?

              Douglas
              • 5. Re: SEVERE: Error while registering Oracle JDBC Diagnosability MBean
                dsurber-Oracle
                This has been filed as bug 6362104. It will be fixed in the first patch release. I'm still not convinced that a correctly working ClassLoader should demonstrate this problem, but it was easy enough to fix and the fixed version is more robust.

                Douglas
                • 6. Re: SEVERE: Error while registering Oracle JDBC Diagnosability MBean
                  597862
                  I´m having the same problem using JBOSS + hibernate

                  Herrera
                  • 7. Re: SEVERE: Error while registering Oracle JDBC Diagnosability MBean
                    600714
                    I am facing the same issue with Tomcat 5.5.4 & Oracle 11g.
                    • 8. Re: SEVERE: Error while registering Oracle JDBC Diagnosability MBean
                      604348
                      I am having the same problem with Oracle 10g Express edition + Eclipse 3.3, Tomcat 6.0:



                      SEVERE: Error while registering Oracle JDBC Diagnosability MBean.
                      javax.management.MalformedObjectNameException: Invalid character '
                      ' in value part of property
                           at javax.management.ObjectName.construct(ObjectName.java:602)
                           at javax.management.ObjectName.<init>(ObjectName.java:1394)
                           at oracle.jdbc.driver.OracleDriver.registerMBeans(OracleDriver.java:303)
                           at oracle.jdbc.driver.OracleDriver$1.run(OracleDriver.java:213)
                           at java.security.AccessController.doPrivileged(Native Method)
                           at oracle.jdbc.driver.OracleDriver.<clinit>(OracleDriver.java:209)
                           at java.lang.Class.forName0(Native Method)
                           at java.lang.Class.forName(Class.java:169)
                           at org.example.ch03.Database.lookupFullname(Database.java:24)
                           at org.example.ch03.HelloServlet.doGet(HelloServlet.java:38)
                           at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
                           at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
                           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
                           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
                           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
                           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
                           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                           at java.lang.Thread.run(Thread.java:619)
                      • 9. Re: SEVERE: Error while registering Oracle JDBC Diagnosability MBean
                        dsurber-Oracle
                        Try redownloading the drivers from OTN. So many people are hitting this problem that we added the patch to the download. If you want to know whether you have the patched jar or not run

                        > java -jar ojdbc6.jar

                        The unpatched jar prints

                        Oracle 11.1.0.6.0-Production JDBC 4.0 complied with JDK6

                        and the patched jar prints

                        Oracle 11.1.0.6.0-Production+ JDBC 4.0 complied with JDK6

                        If you use ojdbc5 it will say 3.0 and 1.5.

                        Douglas
                        • 10. Re: SEVERE: Error while registering Oracle JDBC Diagnosability MBean
                          Shawn Clowater
                          This seems to fix my issues I was having with ant. Am I to assume that this is a very isolated patch and doesn't contain any other changes?
                          • 11. Re: SEVERE: Error while registering Oracle JDBC Diagnosability MBean
                            dsurber-Oracle
                            There are two patches in the plus jars. The first is the fix to the MBean problem. The second is only in the ojdbc(5|6)dms.jar files and has no impact on non-dms jars.

                            Douglas
                            • 12. Re: SEVERE: Error while registering Oracle JDBC Diagnosability MBean
                              619355
                              I was getting "SEVERE: Error while registering Oracle JDBC Diagnosability MBean". I was using the patched jar though. I switched to an older driver and the problem went away.

                              Message was edited by:
                              dangerismymiddlename.com
                              • 13. Re: SEVERE: Error while registering Oracle JDBC Diagnosability MBean
                                619898
                                Hi dozzy,

                                I've had the same error message

                                SEVERE: Error while registering Oracle JDBC Diagnosability MBean.
                                javax.management.MalformedObjectNameException: Invalid character '
                                ' in value part of property

                                yesturday and implemented a workaround for it.
                                The bug is related to the code in OracleDataSource implementation. Oracle assumes, that Thread.currentThread().getContextClassLoader().toString() will not contain characters that are invalid in javax.management.ObjectName . Oops - Tomcat's class loaders toString() implementations mostly contain newlines (\r\n) - and these characters are not escaped and that's why a MalformedObjectNameException is thrown.

                                I've written a detailed explanation and workaround on my page: http://www.robert-stupp.de/blog/2008/01/oracle_malicious_11g_data_source_implementation.html

                                Regards
                                Robert
                                • 14. Re: SEVERE: Error while registering Oracle JDBC Diagnosability MBean
                                  619898
                                  Hi!

                                  I just saw, that there is already a patch on OTN. But I cannot find it on OTN - tried to look in the list of "new downloads" (http://www.oracle.com/technology/software/new_downloads.html) - but there is no updated JDBC driver?! Even in other categories I did not find any 11g JDBC driver as a seperate package.
                                  1 2 3 Previous Next