Weblogic 8.1上的Spring Call Remote EJB

时间:2014-11-21 14:59:17

标签: java spring java-ee ejb weblogic

我正在尝试使用spring在新的osgi容器中连接到遗留系统,我遇到了以下异常:

  

java.lang.Exception:无法将值org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean@310a250a转换为com.company.cpm.process.CounterpartyHandler

这是我设置的用于将counterpartyHandler bean注入via spring的类:

import com.company.cpm.domain.Counterparty;
import com.company.cpm.process.CounterpartyHandler;

public class CpmDataRetriever {
    private CounterpartyHandler counterpartyHandler;

    public void setCounterpartyHandler(CounterpartyHandler counterpartyHandler) {
        this.counterpartyHandler = counterpartyHandler;
    }

    public Counterparty getCounterparty()
    {
        // TODO: implement function
        return null;
    }
}

以下是我的弹簧配置:

<!-- set up cpm data retriever bean -->
<bean id="counterpartyHandler"
      class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean">
    <property name="jndiName" value="com.company.cpm.process.CounterpartyHandlerHome" />
    <property name="businessInterface" value="com.company.cpm.process.CounterpartyHandler"/>
    <property name="jndiEnvironment">
        <props>
            <prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
            <prop key="java.naming.provider.url">t3://someserver.domain.com:41700</prop>
        </props>
    </property>
</bean>

<bean id="cpmDataRetriever" class="com.company.fuse.esb.cpm.CpmDataRetriever">
    <property name="counterpartyHandler" ref="counterpartyHandler" />
</bean>

这是ejb-jar.xml:

<ejb-jar>
    <enterprise-beans>
        <session>
            <ejb-name>CounterpartyHandler</ejb-name>
            <home>com.company.cpm.process.CounterpartyHandlerHome</home>
            <remote>com.company.cpm.process.CounterpartyHandler</remote>
            <ejb-class>com.company.cpm.process.CounterpartyHandlerBean</ejb-class>
            <session-type>Stateless</session-type>
            <transaction-type>Container</transaction-type>
        </session>
    </enterprise-beans>
</ejb-jar>

我的问题是为什么要尝试将SimpleRemoteStatelessSessionProxyFactoryBean转换为我的业务界面CounterpartyHandler?不应该使用工厂通过home接口将业务接口连接到bean吗?或者我完全错过了什么?

修改

这里要说明的是weblogic-ejb-jar.xml,其中包含我要解决的jndi名称:

<weblogic-ejb-jar>
    <!-- CounterpartyHandler -->
    <weblogic-enterprise-bean>
        <ejb-name>CounterpartyHandler</ejb-name>
        <stateless-session-descriptor>
            <pool>
                <max-beans-in-free-pool>5</max-beans-in-free-pool>
                <initial-beans-in-free-pool>0</initial-beans-in-free-pool>
            </pool>
        </stateless-session-descriptor>
        <jndi-name>com.dteco.cpm.process.CounterpartyHandlerHome</jndi-name>
    </weblogic-enterprise-bean>
</weblogic-ejb-jar>

0 个答案:

没有答案