У меня есть хорошая рабочая конфигурация XML для Camel Context, которая использует JNDI с Spring.
Позже Solace.JndiObjectFactoryBean используется как connectionFactory.
<bean id="Solace.JmsComponent" class=" on">
<property name="connectionFactory" ref="Solace.JndiObjectFactoryBean" />
<property name="destinationResolver" ref="Solace.JndiDestinationResolver" />
</bean>
Я пытаюсь преобразовать это в класс Java, который расширяется от org.apache.camel.spring.javaconfig.CamelConfiguration
. Но есть одна проблема. Когда я пытаюсь установить фабрику соединений в компоненте JMS component.setConnectionFactory(getJndiObjectFactoryBean()); getJndiObjectFactoryBean(), я получаю исключение времени компиляции:
The method setConnectionFactory(ConnectionFactory) in the type JmsComponent
is not applicable for the arguments (JndiObjectFactoryBean)
Но когда я пытаюсь привести JndiObjectFactoryBean, возвращенный из getJndiObjectFactoryBean, явно к SolConnectionFactory, я получаю ошибку времени выполнения
016-02-05 17:39:09,234|[localhost-startStop-1]|[]|[]|[ERROR] web.context.ContextLoader [line:307] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getJMSConfiguration' defined in class path resource [com//camel
/CamelRoutesConfig.class]: Instantiation of bean failed; nested exception is org
.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.apache.camel.component.jms.JmsConfiguration com.camel.CamelRoutesConfig.getJMSConfiguration()] threw exception; nested exception is java.lang.ClassCastException: org.springframework.jndi.JndiObjectFactoryBean$$EnhancerByCG
LIB$$18b94f95 cannot be cast to com.solacesystems.jms.SolConnectionFactory
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsi
ngFactoryMethod(ConstructorResolver.java:581)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1029)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.createBeanInstance(AbstractAutowireCapableBeanFactory.java:925)
Я считаю, что на пути к классу есть необходимые банки. sol-common-xyzjar, sol-jcsmp-xyzjar, sol-jms-xyzjar