Announcement Announcement Module
Collapse
No announcement yet.
My JMX beans no longer work in RC2? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • My JMX beans no longer work in RC2?

    I'm using the MBeanExporter in combination with jdk 1.5 annotations (via the MetadataMBeanInfoAssembler and AnnotationJmxAttributeSource classes). Things were working fine in RC1, but with RC2 one of my MBeans works, but the rest produce an exception whenever I try to invoke an operation on them (see stack trace below - the key message seems to be "java.lang.IllegalArgumentException: object is not an instance of declaring class").

    I'm at a bit of a loss to explain why. There is no obvious difference between the mbean that works and the ones that don't, except that they are exported by different MBeanExporters (although they are both set up in the same way). Any ideas what might be causing this?


    Thanks,
    Charles

    Code:
    java.lang.reflect.UndeclaredThrowableException
    	at $Proxy9.invoke(Unknown Source)
    	at org.mc4j.console.bean.operation.OperationExecutionResultsVisualPanel$2.run(OperationExecutionResultsVisualPanel.java:126)
    	at java.lang.Thread.run(Thread.java:595)
    Caused by: java.lang.reflect.InvocationTargetException
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at org.mc4j.console.connection.proxy.JMXRemotingMBeanServerProxy.invoke(JMXRemotingMBeanServerProxy.java:61)
    	... 3 more
    Caused by: javax.management.RuntimeOperationsException: RuntimeException occured in RequiredModelMBean while trying to invoke operation retrieveScheduledTasksAsString
    	at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1076)
    	at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:952)
    	at com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke(DynamicMetaDataImpl.java:213)
    	at com.sun.jmx.mbeanserver.MetaDataImpl.invoke(MetaDataImpl.java:220)
    	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:815)
    	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:784)
    	at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:429)
    	at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1408)
    	at javax.management.remote.rmi.RMIConnectionImpl.access$100(RMIConnectionImpl.java:81)
    	at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1245)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1348)
    	at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:782)
    	at sun.reflect.GeneratedMethodAccessor155.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
    	at sun.rmi.transport.Transport$1.run(Transport.java:153)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
    	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
    	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
    	at java.lang.Thread.run(Thread.java:595)
    	at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
    	at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
    	at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
    	at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source)
    	at javax.management.remote.rmi.RMIConnectionImpl_Stub.invoke(Unknown Source)
    	at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.invoke(RMIConnector.java:969)
    	... 8 more
    Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1070)
    	at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:952)
    	at com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke(DynamicMetaDataImpl.java:213)
    	at com.sun.jmx.mbeanserver.MetaDataImpl.invoke(MetaDataImpl.java:220)
    	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:815)
    	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:784)
    	at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:429)
    	at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1408)
    	at javax.management.remote.rmi.RMIConnectionImpl.access$100(RMIConnectionImpl.java:81)
    	at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1245)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1348)
    	at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:782)
    	at sun.reflect.GeneratedMethodAccessor155.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
    	at sun.rmi.transport.Transport$1.run(Transport.java:153)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
    	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
    	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
    	... 1 more
    java.lang.reflect.InvocationTargetException
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at org.mc4j.console.connection.proxy.JMXRemotingMBeanServerProxy.invoke(JMXRemotingMBeanServerProxy.java:61)
    	at $Proxy9.invoke(Unknown Source)
    	at org.mc4j.console.bean.operation.OperationExecutionResultsVisualPanel$2.run(OperationExecutionResultsVisualPanel.java:126)
    	at java.lang.Thread.run(Thread.java:595)
    Caused by: javax.management.RuntimeOperationsException: RuntimeException occured in RequiredModelMBean while trying to invoke operation retrieveScheduledTasksAsString
    	at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1076)
    	at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:952)
    	at com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke(DynamicMetaDataImpl.java:213)
    	at com.sun.jmx.mbeanserver.MetaDataImpl.invoke(MetaDataImpl.java:220)
    	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:815)
    	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:784)
    	at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:429)
    	at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1408)
    	at javax.management.remote.rmi.RMIConnectionImpl.access$100(RMIConnectionImpl.java:81)
    	at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1245)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1348)
    	at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:782)
    	at sun.reflect.GeneratedMethodAccessor155.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
    	at sun.rmi.transport.Transport$1.run(Transport.java:153)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
    	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
    	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
    	at java.lang.Thread.run(Thread.java:595)
    	at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
    	at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
    	at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
    	at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source)
    	at javax.management.remote.rmi.RMIConnectionImpl_Stub.invoke(Unknown Source)
    	at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.invoke(RMIConnector.java:969)
    	... 8 more
    Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1070)
    	at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:952)
    	at com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke(DynamicMetaDataImpl.java:213)
    	at com.sun.jmx.mbeanserver.MetaDataImpl.invoke(MetaDataImpl.java:220)
    	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:815)
    	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:784)
    	at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:429)
    	at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1408)
    	at javax.management.remote.rmi.RMIConnectionImpl.access$100(RMIConnectionImpl.java:81)
    	at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1245)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1348)
    	at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:782)
    	at sun.reflect.GeneratedMethodAccessor155.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
    	at sun.rmi.transport.Transport$1.run(Transport.java:153)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
    	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
    	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
    	... 1 more
    javax.management.RuntimeOperationsException: RuntimeException occured in RequiredModelMBean while trying to invoke operation retrieveScheduledTasksAsString
    	at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1076)
    	at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:952)
    	at com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke(DynamicMetaDataImpl.java:213)
    	at com.sun.jmx.mbeanserver.MetaDataImpl.invoke(MetaDataImpl.java:220)
    	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:815)
    	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:784)
    	at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:429)
    	at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1408)
    	at javax.management.remote.rmi.RMIConnectionImpl.access$100(RMIConnectionImpl.java:81)
    	at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1245)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1348)
    	at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:782)
    	at sun.reflect.GeneratedMethodAccessor155.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
    	at sun.rmi.transport.Transport$1.run(Transport.java:153)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
    	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
    	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
    	at java.lang.Thread.run(Thread.java:595)
    	at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
    	at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
    	at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
    	at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source)
    	at javax.management.remote.rmi.RMIConnectionImpl_Stub.invoke(Unknown Source)
    	at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.invoke(RMIConnector.java:969)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at org.mc4j.console.connection.proxy.JMXRemotingMBeanServerProxy.invoke(JMXRemotingMBeanServerProxy.java:61)
    	at $Proxy9.invoke(Unknown Source)
    	at org.mc4j.console.bean.operation.OperationExecutionResultsVisualPanel$2.run(OperationExecutionResultsVisualPanel.java:126)
    	at java.lang.Thread.run(Thread.java:595)
    Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1070)
    	at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:952)
    	at com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke(DynamicMetaDataImpl.java:213)
    	at com.sun.jmx.mbeanserver.MetaDataImpl.invoke(MetaDataImpl.java:220)
    	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:815)
    	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:784)
    	at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:429)
    	at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1408)
    	at javax.management.remote.rmi.RMIConnectionImpl.access$100(RMIConnectionImpl.java:81)
    	at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1245)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1348)
    	at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:782)
    	at sun.reflect.GeneratedMethodAccessor155.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
    	at sun.rmi.transport.Transport$1.run(Transport.java:153)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
    	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
    	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
    	... 1 more
    java.lang.IllegalArgumentException: object is not an instance of declaring class
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1070)
    	at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:952)
    	at com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke(DynamicMetaDataImpl.java:213)
    	at com.sun.jmx.mbeanserver.MetaDataImpl.invoke(MetaDataImpl.java:220)
    	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:815)
    	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:784)
    	at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:429)
    	at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1408)
    	at javax.management.remote.rmi.RMIConnectionImpl.access$100(RMIConnectionImpl.java:81)
    	at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1245)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1348)
    	at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:782)
    	at sun.reflect.GeneratedMethodAccessor155.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
    	at sun.rmi.transport.Transport$1.run(Transport.java:153)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
    	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
    	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
    	at java.lang.Thread.run(Thread.java:595)

  • #2
    Do you have multiple Spring versions on your classpath - that can often cause confusion similar to this.

    Rob

    Comment


    • #3
      Hi Rob,

      I've found the problem. The mbeans that don't work also have @Transactional annotations on them. If I remove these @Transactional annotations things work fine. For example, this works:

      Code:
      @ManagedOperation(description = "Does something")
      public void doSomething()
      {
      }
      But this doesn't:

      Code:
      @Transactional
      @ManagedOperation(description = "Does something")
      public void doSomething()
      {
      }

      Cheers,
      Charles

      Comment


      • #4
        MMM, very interesting. I'll raise a bug for this and do some further investigation.

        Thanks

        Rob

        Comment


        • #5
          Charles,

          We committed some fairly substantial updates the to the handling on proxies and JMX today. Can you try your code again with a new snapshot. It might take until tomorrow for our code to sync across to the public CVS.

          Rob

          Comment


          • #6
            Hi Rob,

            Thanks for the fixes, sorry I've not been able to test them sooner. I've just given it a go with build 259 (2005-05-03). Things work fine if I use the SimpleReflectiveMBeanInfoAssembler. However as soon as I switch to the MetadataMBeanInfoAssembler (primed with an AnnotationJmxAttributeSource) I get the following error when the mbeans with @Transactional annotations are being exported:

            org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'jmxExporter' defined in class path resource [qtripjmx.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: MetadataMBeanInfoAssembler does not support JDK dynamic proxies - export the target beans directly or use CGLIB proxies instead

            From the error message I assume I've bumped into a limitation of JMX implementation, but I have no idea how to resolve it. How do I go about using CGLIB proxies instead of JDK dynamic proxies for my transactional classes?

            Funny thing is though, this stuff works in RC1.

            Cheers,
            Charles

            Comment


            • #7
              This was a restriction we introduced recently - mainly because the semantics of JDK proxies when using annotations are very strange and in most cases undesirable.

              To switch to a CGLIB proxy, simply set the proxyTargetClass property of your ProxyFactoryBean to true. This can be done as part of your configuration.

              Rob

              Comment


              • #8
                Fair enough. I'm not actually using ProxyFactoryBean though - I'm using the DefaultAdvisorAutoProxyCreator. I discovered that you can set proxyTargetClass on the DefaultAdvisorAutoProxyCreator as well, but I tried this and it doesn't work! It creates a CGLIB proxy sure enough, but none of my methods actually get intercepted. Heres my config setup:

                Code:
                    <bean id="autoProxyCreator" class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator">
                        <property name="proxyTargetClass" value="true"/>
                    </bean>
                
                    <bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager">
                        <property name="sessionFactory" ref="sessionFactory"/>
                    </bean>
                
                	<bean id="transactionAttributeSource" class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"/>
                
                    <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
                        <property name="transactionManager" ref="transactionManager"/>
                        <property name="transactionAttributeSource" ref="transactionAttributeSource"/>
                    </bean>
                
                    <bean id="transactionAdvisor"
                        class="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor">
                        <constructor-arg>
                            <ref bean="transactionInterceptor" />
                        </constructor-arg>
                    </bean>

                And an extract from the log file:

                Code:
                <DefaultAdvisorAutoProxyCreator> <Candidate advisor &#91;org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor@848ecc&#93; accepted for class &#91;com.eb2.qtrip.main.service.admin.DbAdminImpl&#93;>
                <DefaultAdvisorAutoProxyCreator> <Creating implicit proxy for bean 'dbAdmin' with 0 common interceptors and 1 specific interceptors>
                <CollectionFactory> <Creating java.util.IdentityHashMap>
                <Cglib2AopProxy> <Creating CGLIB2 proxy for &#91;com.eb2.qtrip.main.service.admin.DbAdminImpl&#93;>
                <Cglib2AopProxy> <Method public void com.eb2.qtrip.main.service.admin.DbAdminImpl.loadTestData&#40;&#41; has return type that ensures this cannot be returned- using DISPATCH_TARGET>
                The loadTestData method is annotated by @Transaction, but the Cglib2AopProxy class sets it up with a DISPATCH_TARGET callback, which according to the comments is "used for unadvised calls to static targets that cannot return this". This doesn't seem quite right.

                Any ideas what's going on here?

                Cheers,
                Charles

                Comment


                • #9
                  OK, I think I've found what's going on here. I had my @Transaction annotation on the Interface method declaration, not the implementation. This works using JDK proxies, but not CGLIB proxies. For example, the following works if you use JDK proxies (proxyTargetClass=false) but not CGLIB (proxyTargetClass=true)

                  Code:
                  public inteface Foo &#123;
                      @Transactional
                      public void doSomething&#40;&#41; &#123; &#125;
                  &#125;
                  
                  public class FooImpl implements Foo &#123;
                      public void doSomething&#40;&#41; &#123; &#125;
                  &#125;

                  Maybe this is intentional, but it caught me by surprise.

                  Cheers,
                  Charles

                  Comment


                  • #10
                    (After a long delay...)

                    I can't seem to find any jira issue for this. Shall I file one, or is this something that is just gonna "be that way"?

                    We had the same problem with jmx in the early 1.2 RCs, and code like

                    AopProxyUtils.getTargetClass(managedBean)

                    was put in to fix things. But it doesn't look so straight forward in the TransactionAttributeSourceAdvisor.

                    Comment


                    • #11
                      Hmm, this is not right. AnnotationTransactionAttributeSource.findAllAttrib utes(Class) is invoked before the object is proxied, and the class is the real class.

                      So I don't understand why the attributes on the interface are not returned from Class.getAnnotations().

                      Comment


                      • #12
                        Ok, now I understand. Class.getAnnotations does not get annotations from an interface, only classes up the hierarchy. If using an interface for a Dao and defining default @Transactional's on the interface is to work in spring, spring will need to check the interfaces itself. This of course leaves the issue of mutliple interfaces declaring conflicting @Transactional's.

                        I don't know what a clean solution is. For now I have to either:

                        * Declare a pure abstract as the Dao
                        * Just put the transactional annotations on the concrete Dao
                        * Don't use annotations - put the transaction attributes in the config file

                        Surely someone must have struggled with this already...

                        Comment


                        • #13
                          Barry,

                          Please do add a JIRA issue for this. It would be great if you can summarise your findings and even better if you have a test case for it. Please link back to this post in the JIRA issue.

                          Rob

                          Comment


                          • #14
                            Rob,

                            I'm not sure there is anything to change in spring. It is working as designed. The only change I can envision to spring is to work up the /interface/ hierarchy to collection annotations. But then we would have to deal with the issue of handling conflicting annotations in mutliple parent interfaces. If I recall from early discussions on the annation design, this is one of the reasons that Class.getAnnotations is limited to classes and not interfaces.

                            Does this make sense? Do you think spring should try to work up interfaces and handle possible conflicts? My question about "struggle" was not about struggling the spring impl, but with the general design issue.

                            -barry

                            Comment


                            • #15
                              I don't think that is a feature we will adding anytime soon. It would be nice but the resolution algorithm could beome quite complex.

                              Rob

                              Comment

                              Working...
                              X