0 Replies Latest reply on Jan 8, 2016 2:45 PM by Matt Madhavan

    activemq ra.ActiveMQConnectionFactory : object is not an instance of declaring class Exception

    Matt Madhavan Newbie

      Hello,

      I am stumped on this exception!

       

      I have successfully configured activemq (external) rar on Wildfly 9.0.2.

       

      I do jndi lookup as follows:

      @Bean(name = "amqXaConnectionFactory")
          public ConnectionFactory activeMQXAConnectionFactory() {
              JndiObjectFactoryBean jndiObjectFactoryBean = new JndiObjectFactoryBean();
              jndiObjectFactoryBean.setJndiName(env.getProperty("jndi.name.jms.xaConnectionFactory"));
              jndiObjectFactoryBean.setProxyInterface(ConnectionFactory.class); // org.apache.activemq.ra.ActiveMQConnectionFactory
      
              try {
                  jndiObjectFactoryBean.afterPropertiesSet(); 
              } catch (IllegalArgumentException | NamingException e) {
                  e.printStackTrace();
                  LOG.error("Error looking up ActiveMQ Connection Factory", e);
                  throw new RuntimeException(e);
              }
              LOG.info("\n\n\n");
              LOG.info("Connection Factory is : " + jndiObjectFactoryBean.getObject());
      
              ConnectionFactory fac = (ConnectionFactory) jndiObjectFactoryBean.getObject();
              
              try {
                  fac.createConnection();
              } catch (Exception e) {
                  e.printStackTrace();
                  System.exit(0);
              }
              return (ConnectionFactory) jndiObjectFactoryBean.getObject();
          }
      
      

       

      When I try to create a Connection I am getting the following exception:

       

      org.springframework.aop.AopInvocationException: AOP configuration seems to be invalid: 
         tried calling method [public abstract javax.jms.Connection javax.jms.ConnectionFactory.createConnection() 
         throws javax.jms.JMSException] on target [org.apache.activemq.ra.ActiveMQConnectionFactory@281b4aa]; 
         nested exception is java.lang.IllegalArgumentException: object is not an instance of declaring class
         
         
          at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:325)
          at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:201)
          at com.sun.proxy.$Proxy107.createConnection(Unknown Source)
          at org.facs.ncdb.measuremesh.service.config.ResourcesConfig.activeMQXAConnectionFactory(ResourcesConfig.java:130)
          at org.facs.ncdb.measuremesh.service.config.ResourcesConfig$$EnhancerBySpringCGLIB$$6c4cf297.CGLIB$activeMQXAConnectionFactory$3(<generated>)
          at org.facs.ncdb.measuremesh.service.config.ResourcesConfig$$EnhancerBySpringCGLIB$$6c4cf297$$FastClassBySpringCGLIB$$cb0ad8e6.invoke(<generated>)
          at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
          at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:309)
           at org.facs.ncdb.measuremesh.service.config.ResourcesConfig$$EnhancerBySpringCGLIB$$6c4cf297.activeMQXAConnectionFactory(<generated>)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      
      

       

      I am completely confused and stuck for the whole day? Any ideas please?

       

      Thanks in advance!

       

      Matt'M