有关 ejb 3、weblogic 和 spring 的帮助

发布于 2024-09-02 07:13:50 字数 3476 浏览 2 评论 0原文

我创建了一个简单的 EJB3 测试项目,代码很简单:

@Stateless
@Remote( { ISumaSimple.class })
public class SumaSimpleBean implements ISumaSimple {

    /**
     * Default constructor.
     */
    public SumaSimpleBean() {
        // TODO Auto-generated constructor stub
    }

    @Override
    public int sumar(int a, int b) {
        // TODO Auto-generated method stub
        return a + b;
    }

}

public interface ISumaSimple {      
    public int sumar(int a, int b);
}

好吧,我的客户端是一个独立的 spring 应用程序,其配置是:

<bean id="sumaSimpleServicio"
    class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiEnvironment">
        <props>
            <prop key="java.naming.factory.initial">
                 org.apache.openejb.client.RemoteInitialContextFactory
            </prop>
            <prop key="java.naming.provider.url">
                 ejbd://localhost:4201
            </prop>
        </props>
    </property>
    <property name="jndiName" value="SumaSimpleBeanRemote" />
</bean>

<bean id="clienteService" class="qtx.cliente.simple.ClienteService">
    <property name="sumaSimpleServicio" ref="sumaSimpleServicio"></property>
</bean>

一切顺利,但后来我尝试使用 weblogic 10.3 进行部署,只需更改这些值:

weblogic.jndi .WLInitialContextFactory

t3://localhost:7010

在 weblogic jndi 树中,我的 ejb 位于: SimpleEJB3SimpleEJB_jarSumaSimple3_ISumaSimple

当然,我将 wlclient.jar 添加到我的 spring 客户端类路径中。

部署进行得很顺利,但我认为我在 weblogic 案例中遗漏了一些东西,但不知道。我的春季客户抛出了这个异常:

Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [qtx.ejb.simple._SumaSimple3_gwze0z_ISumaSimpleIntf_Stub] to required type [qtx.servicio.simple.ISumaSimple] for property 'sumaSimpleServicio'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [qtx.ejb.simple._SumaSimple3_gwze0z_ISumaSimpleIntf_Stub] to required type [qtx.servicio.simple.ISumaSimple] for property 'sumaSimpleServicio': no matching editors or conversion strategy found
    at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:391)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1288)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1249)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
    ... 14 more
Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [qtx.ejb.simple._SumaSimple3_gwze0z_ISumaSimpleIntf_Stub] to required type [qtx.servicio.simple.ISumaSimple] for property 'sumaSimpleServicio': no matching editors or conversion strategy found
    at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:219)
    at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138)
    at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:386)
    ... 18 more

任何帮助将不胜感激。

I've created a simple EJB3 test project, the code is simple:

@Stateless
@Remote( { ISumaSimple.class })
public class SumaSimpleBean implements ISumaSimple {

    /**
     * Default constructor.
     */
    public SumaSimpleBean() {
        // TODO Auto-generated constructor stub
    }

    @Override
    public int sumar(int a, int b) {
        // TODO Auto-generated method stub
        return a + b;
    }

}

public interface ISumaSimple {      
    public int sumar(int a, int b);
}

Ok, my client is a stand alone spring aplication which configuration is:

<bean id="sumaSimpleServicio"
    class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiEnvironment">
        <props>
            <prop key="java.naming.factory.initial">
                 org.apache.openejb.client.RemoteInitialContextFactory
            </prop>
            <prop key="java.naming.provider.url">
                 ejbd://localhost:4201
            </prop>
        </props>
    </property>
    <property name="jndiName" value="SumaSimpleBeanRemote" />
</bean>

<bean id="clienteService" class="qtx.cliente.simple.ClienteService">
    <property name="sumaSimpleServicio" ref="sumaSimpleServicio"></property>
</bean>

All worked smoothly, but then I tried deploying using weblogic 10.3, just changing these values:

weblogic.jndi.WLInitialContextFactory

t3://localhost:7010

In weblogic jndi tree my ejb is under: SimpleEJB3SimpleEJB_jarSumaSimple3_ISumaSimple

Of course I added wlclient.jar to my spring client classpath.

The deployment went perfectly, but I think I am missing something in weblogic case, but dunno. My spring client is throwing this exception:

Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [qtx.ejb.simple._SumaSimple3_gwze0z_ISumaSimpleIntf_Stub] to required type [qtx.servicio.simple.ISumaSimple] for property 'sumaSimpleServicio'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [qtx.ejb.simple._SumaSimple3_gwze0z_ISumaSimpleIntf_Stub] to required type [qtx.servicio.simple.ISumaSimple] for property 'sumaSimpleServicio': no matching editors or conversion strategy found
    at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:391)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1288)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1249)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
    ... 14 more
Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [qtx.ejb.simple._SumaSimple3_gwze0z_ISumaSimpleIntf_Stub] to required type [qtx.servicio.simple.ISumaSimple] for property 'sumaSimpleServicio': no matching editors or conversion strategy found
    at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:219)
    at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138)
    at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:386)
    ... 18 more

Any help would be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暗地喜欢 2024-09-09 07:13:50

OpenEJB 和 Weblogic 中的 Jndi 名称不同,必须根据托管 ejb 的服务器使用不同的正确 jndi 名称。

Jndi name differs in OpenEJB and Weblogic , have to use different correct jndi name as per server on which ejbs are hosted.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文