Announcement Announcement Module
Collapse
No announcement yet.
Failed to convert SpyConnectionFactory to ConnectionFactory Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Failed to convert SpyConnectionFactory to ConnectionFactory

    I'm getting this:
    ERROR [ContextLoader] Context initialization failed org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'jmsTemplate' defined in ServletContext resource [/WEB-INF/applicationContext-services.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyAccessExceptions Exception: PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.TypeMismatchException: Failed to convert property value of type [org.jboss.mq.SpyConnectionFactory] to required type [javax.jms.ConnectionFactory] for property 'connectionFactory']

    Any help is greatly appreciated!

    I'm using Spring 1.2.3 + JBoss 4.0.3 RC2.
    Here is a snippet of my applicationContext.xml:

    <beans>

    <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory">
    <ref bean="connectionFactory"/>
    </property>
    </bean>

    <bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiName">
    <value>ConnectionFactory</value>
    </property>
    <property name="jndiTemplate">
    <ref local="jndiTemplate"/>
    </property>
    <property name="resourceRef">
    <value>false</value>
    </property>
    </bean>

    <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
    <property name="environment">
    <props>
    <prop key="java.naming.factory.initial">org.jnp.interfac es.NamingContextFactory</prop>
    <prop key="java.naming.provider.url">jnp://localhost:1099</prop>
    <prop key="java.naming.factory.url.pkgs">org.jboss.namin g:org.jnp.interfaces</prop>
    </props>
    </property>
    </bean>

    </beans>

  • #2
    This sounds like a classloading error. Do you have multiple versions of the javax.jms.* classes on the classpath for your app? Perhaps you have jms.jar in your WAR file?

    Rob

    Comment


    • #3
      Yes, I have a jms.jar in my .WAR file!!!
      Removing it solved my problem. :lol:

      How did you figure that out???

      You're the best, Rob!!!

      Comment


      • #4
        Same problem converting SpyConnectionFactory-tried the above

        Hi,

        I'm getting the same problem but in a standalone prototype environment. I guess the only difference is that my app is running in a separate VM - does this mean I need to get into the proxy stuff - if so an example would be nice

        The only items on my classpath are:
        spring.jar
        jboss-common.jar
        jnpserver.jar
        j2ee.jar
        commons-logging.jar

        The error is:
        javax.naming.NamingException: Located JNDI object [Reference Class Name: org.jboss.mq.SpyConnectionFactory
        Type: DCF
        Content: [B@16de49c
        ] is not assignable to expected type [javax.jms.QueueConnectionFactory]

        The xml is:
        <beans>
        <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory">
        <ref bean="connectionFactory"/>
        </property>
        </bean>

        <bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryB ean">
        <property name="expectedType" value="javax.jms.QueueConnectionFactory"/>
        <property name="jndiName">
        <value>ConnectionFactory</value>
        </property>
        <property name="jndiTemplate">
        <ref local="jndiTemplate"/>
        </property>
        <property name="resourceRef">
        <value>false</value>
        </property>
        </bean>

        <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
        <property name="environment">
        <props>
        <prop key="java.naming.factory.initial">org.jnp.interfac es.NamingContextFactory</prop>
        <prop key="java.naming.provider.url">jnp://localhost:1099</prop>
        <prop key="java.naming.factory.url.pkgs">org.jboss.namin g:org.jnp.interfaces</prop>
        </props>
        </property>
        </bean>
        </beans>

        Thanks!

        Comment


        • #5
          Do you have multiple jms.jar files in your classpath or multiple copies of any of the JMS classes in any JARs?

          Rob

          Comment


          • #6
            Thanks Rob but no joy.

            I've tried this on 2 machines with the same result. Both machines fail if I remove j2ee.jar from the classpath with a ClassNotFoundException for javax.jms.JMSException, which suggests to me that I'm definitely NOT picking up other JMS classes.

            Any other ideas greatly appreciated!

            Comment


            • #7
              More investigation

              After a little more investigating, I have found that by removing the "expectedType" property from my "connectionFactory" bean, I get the following error:
              org.springframework.beans.TypeMismatchException: Failed to convert property value of type [javax.naming.Reference] to required type [javax.jms.ConnectionFactory]

              So it's having a problem converting a JNDI Reference to a ConnectionFactory - no surprise there!! But why is the JndiObjectFactoryBean only returning a Reference rather than the actual object??
              Any ideas?

              Comment


              • #8
                Hey Guys,

                Rob is having a correct question.
                The root cause is multiple JMSConnector.java jar files.

                1) org.apache.axis.transport.jms.JMSConnector is the first JMSConnector class file and,
                2) org.mule.providers.jms.JmsConnector can be the other JMS connector file and
                one more JMSConnector class is available in JBOSS-EJB3.jar

                I suggest you remove all your library files and take only the required library files.

                Let me know if it is not meeting to ur answer.

                Regards,
                Maulik

                Comment

                Working...
                X