Results 1 to 8 of 8

Thread: Failed to convert SpyConnectionFactory to ConnectionFactory

  1. #1
    Join Date
    Aug 2004
    Location
    Bridgewater, NJ
    Posts
    10

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Southampton, UK
    Posts
    826

    Default

    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
    Rob Harrop
    Lead Engineer, dm Server
    SpringSource
    http://www.springsource.com

    Co-Author - Pro Spring

  3. #3
    Join Date
    Aug 2004
    Location
    Bridgewater, NJ
    Posts
    10

    Default

    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!!!

  4. #4
    Join Date
    Sep 2005
    Posts
    3

    Default 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!

  5. #5
    Join Date
    Aug 2004
    Location
    Southampton, UK
    Posts
    826

    Default

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

    Rob
    Rob Harrop
    Lead Engineer, dm Server
    SpringSource
    http://www.springsource.com

    Co-Author - Pro Spring

  6. #6
    Join Date
    Sep 2005
    Posts
    3

    Default

    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!

  7. #7
    Join Date
    Sep 2005
    Posts
    3

    Default 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?

  8. #8

    Default

    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

Similar Threads

  1. Context initialization failed
    By kanonmicke in forum Container
    Replies: 7
    Last Post: Sep 29th, 2005, 12:35 AM
  2. Failed to convert property value
    By vammpiro in forum Container
    Replies: 2
    Last Post: Jun 9th, 2005, 12:06 PM
  3. Replies: 10
    Last Post: Apr 25th, 2005, 08:03 AM
  4. Failed to convert property value
    By humberto in forum Container
    Replies: 1
    Last Post: Dec 14th, 2004, 09:32 PM
  5. Failed to convert property
    By pak in forum Web
    Replies: 2
    Last Post: Sep 14th, 2004, 03:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •