使用蓝图 xml 建立带有 JndiObjectFactoryBean 的 Weblogic 组件时出错

Error using Blueprint xml to establish a Weblogic component with a JndiObjectFactoryBean

所以,我正在尝试使用下面的代码片段让 Weblogic 组件在我们的应用程序的蓝图文件中工作,尽管我不确定除了用于连接到 JMS 之外还包括什么队列。

> <bean id="wmqjndiFactoryBean"
> class="org.springframework.jndi.JndiObjectFactoryBean">
>         <property name="jndiName" value="jms/ConnectionFactory"/>
>         <property name="jndiTemplate">
>             <bean class="org.springframework.jndi.JndiTemplate">
>                 <property name="environment">
>                     <props>
>                         <prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
>                         <prop key="java.naming.provider.url">t3://localhost</prop>
>                         <prop key="java.naming.security.principal">weblogic</prop>
>                         <prop key="java.naming.security.credentials">weblogic</prop>
>                     </props>
>                 </property>
>             </bean>
>         </property>
>         <property name="lookupOnStartup" value="false"/>
>         <property name="proxyInterface" value="javax.jms.ConnectionFactory"/>
>     </bean>
>     <bean id="weblogic-jms" class="org.apache.camel.component.jms.JmsComponent">
>         <property name="configuration">
>             <bean class="org.apache.camel.component.jms.JmsConfiguration">
>                 <property name="connectionFactory" ref="wmqjndiFactoryBean"/>
>             </bean>
>         </property>
>     </bean>

并且发生此异常:

    org.osgi.service.blueprint.container.ComponentDefinitionException: Error setting property: PropertyDescriptor <name: connectionFactory, getter: class org.apache.camel.component.jms.JmsConfiguration.getConnectionFactory(), setter: [class org.apache.camel.component.jms.JmsConfiguration.setConnectionFactory(interface javax.jms.ConnectionFactory)]
    at org.apache.aries.blueprint.container.BeanRecipe.setProperty(BeanRecipe.java:941)
    at org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:907)
    at org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:888)
    at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:820)
    at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)
    at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:106)
    at org.apache.aries.blueprint.container.BeanRecipe.setProperty(BeanRecipe.java:933)
    at org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:907)
    at org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:888)
    at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:820)
    at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)
    at org.apache.aries.blueprint.di.AbstractRecipe.call(AbstractRecipe.java:79)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)
    at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:245)
    at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:183)
    at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:668)
    at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:370)
    at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:261)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106)
    at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access1(ScheduledThreadPoolExecutor.java:178)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.Exception: Unable to convert value org.springframework.jndi.JndiObjectFactoryBean to type javax.jms.ConnectionFactory
    at org.apache.aries.blueprint.container.AggregateConverter.convert(AggregateConverter.java:184)
    at org.apache.aries.blueprint.container.BlueprintRepository.convert(BlueprintRepository.java:402)
    at org.apache.aries.blueprint.utils.ReflectionUtils$PropertyDescriptor.convert(ReflectionUtils.java:394)
    at org.apache.aries.blueprint.utils.ReflectionUtils$MethodPropertyDescriptor.internalSet(ReflectionUtils.java:628)
    at org.apache.aries.blueprint.utils.ReflectionUtils$PropertyDescriptor.set(ReflectionUtils.java:378)
    at org.apache.aries.blueprint.container.BeanRecipe.setProperty(BeanRecipe.java:939)
    ... 29 more

过去几天在网上搜索了几个小时后,我还没有找到解决办法。我不能确切地告诉你它不是什么,因为很难记住我已经尝试过的东西,但我看过的大多数 articles/other 问题甚至都不适用。

那么为什么会出现此异常,我该如何解决?

我们团队中有人终于找到了答案。首先,他们稍微改变了路线:

    <bean id="jmsInConnectionFactoryJndiLookupFactory" class="org.springframework.jndi.JndiObjectFactoryBean" init-method="afterPropertiesSet">
            <property name="jndiName" value="jms/ConnectionFactory"/>
            <property name="jndiTemplate">
                <bean class="org.springframework.jndi.JndiTemplate">
                    <property name="environment">
                        <props>
                          <prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
                          <prop key="java.naming.provider.url">t3://localhost</prop>
                          <prop key="java.naming.security.principal">weblogic</prop>
                          <prop key="java.naming.security.credentials">weblogic</prop>
                        </props>
                    </property>
                </bean>
            </property>
        </bean>
        <bean id="jmsInConnectionFactory" factory-ref="jmsInConnectionFactoryJndiLookupFactory" factory-method="getObject" />
        <bean id="weblogic-jms" class="org.apache.camel.component.jms.JmsComponent">
            <property name="configuration">
            <bean class="org.apache.camel.component.jms.JmsConfiguration">
                <property name="connectionFactory" ref="jmsInConnectionFactory"/>
            </bean>
            </property>
        </bean>

其次,他们 运行 进入另一个问题,已在此处解决: https://issues.jboss.org/browse/ENTESB-1567

然后它显然被修复了!希望对您有所帮助。