Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-3839

ClassUtils.forName() fails on byte arrays types

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.6, 2.1 M3
    • Fix Version/s: 2.0.7, 2.1 M4
    • Component/s: Core
    • Labels:
      None
    • Last commented by a User:
      false

      Description

      I was trying to set up a JMX client proxy. one of the interface method signatures contains byte[], and when setting up the client proxy, I get the exception below. seems like byte[].class.getName() returns '[B', and ClassUtils tries to use that as the name of the class when calling loadClass, a call which, evidently, fails.

      btw, I tried changing the signature to Byte[], but then I got the same error for '[Ljava.lang.Byte;'.

      java.lang.ClassNotFoundException: [B
      at java.net.URLClassLoader$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at org.springframework.util.ClassUtils.forName(ClassUtils.java:201)
      at org.springframework.util.ClassUtils.forName(ClassUtils.java:171)
      at org.springframework.jmx.support.JmxUtils.parameterInfoToTypes(JmxUtils.java:141)
      at org.springframework.jmx.access.MBeanClientInterceptor.retrieveMBeanInfo(MBeanClientInterceptor.java:239)
      at org.springframework.jmx.access.MBeanClientInterceptor.afterPropertiesSet(MBeanClientInterceptor.java:169)
      at org.springframework.jmx.access.MBeanProxyFactoryBean.afterPropertiesSet(MBeanProxyFactoryBean.java:81)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1201)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1171)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:284)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
      at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:91)
      at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:75)

        Activity

        Hide
        juergen.hoeller Juergen Hoeller added a comment -

        It seems that JMX uses the JVM's internal class names for primitive array classes there... I've revised "ClassUtils.forName" to support those internal class names too (for primitive arrays as well as for object arrays).

        Thanks for pointing this out!

        Juergen

        Show
        juergen.hoeller Juergen Hoeller added a comment - It seems that JMX uses the JVM's internal class names for primitive array classes there... I've revised "ClassUtils.forName" to support those internal class names too (for primitive arrays as well as for object arrays). Thanks for pointing this out! Juergen

          People

          • Assignee:
            juergen.hoeller Juergen Hoeller
            Reporter:
            zvizvi Zvika Markfeld
            Last updater:
            Trevor Marshall
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Days since last comment:
              10 years, 16 weeks, 5 days ago