在Weblogic 10.3中调用EJB时​​出现NameNotFoundException

时间:2010-04-13 11:16:17

标签: deployment weblogic ejb workmanagers

首先,我想强调我已经阅读了StackOverflow中的其他帖子(example)有类似的问题,但不幸的是我没有设法用我看到的答案解决这个问题在那些帖子上。我无意重新发布一个已经回答过的问题,所以如果是这样的话,我会道歉,我会感谢谁指出解决方案的发布位置。

这是我的问题:

我正在尝试在WebLogic 10.3.2中部署EJB。目的是使用特定的WorkManager来执行在此组件范围内生成的工作。

考虑到这一点,我使用基于Web的界面( Environment &gt; <)在我的WebLogic配置上设置了WorkManager(名为ResponseTimeReqClass-0) em>工作经理&gt; )。这是一个截图:

http://img11.imageshack.us/img11/8607/screenshot0p.jpg http://img11.imageshack.us/img11/8607/screenshot0p.jpg

这是我的会话bean定义和描述符:

OrquestratorRemote.java

package orquestrator;

import javax.ejb.Remote;

@Remote
public interface OrquestratorRemote {

    public void initOrquestrator();

}

OrquestratorBean.java

package orquestrator;

import javax.ejb.Stateless;

import com.siemens.ecustoms.orchestration.eCustomsOrchestrator;

@Stateless(name = "OrquestratorBean", mappedName = "OrquestratorBean") 
public class OrquestratorBean implements OrquestratorRemote {

    public void initOrquestrator(){
        eCustomsOrchestrator orquestrator = new eCustomsOrchestrator();
        orquestrator.run();
    }

}

META-INF \ ejb-jar.xml中

<?xml version='1.0' encoding='UTF-8'?>
<ejb-jar xmlns='http://java.sun.com/xml/ns/javaee'
         xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
         metadata-complete='true'>

<enterprise-beans>
    <session>
        <ejb-name>OrquestradorEJB</ejb-name>
        <mapped-name>OrquestratorBean</mapped-name>
        <business-remote>orquestrator.OrquestratorRemote</business-remote>
        <ejb-class>orquestrator.OrquestratorBean</ejb-class>
        <session-type>Stateless</session-type>
        <transaction-type>Container</transaction-type>
    </session>
</enterprise-beans>

<assembly-descriptor></assembly-descriptor>

</ejb-jar>

META-INF \ WebLogic的EJB-jar.xml中

(我已将工作管理器配置放在此文件中,正如我在互联网上的教程中看到的那样)

<weblogic-ejb-jar xmlns="http://www.bea.com/ns/weblogic/90"
   xmlns:j2ee="http://java.sun.com/xml/ns/j2ee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.bea.com/ns/weblogic/90
   http://www.bea.com/ns/weblogic/90/weblogic-ejb-jar.xsd">

    <weblogic-enterprise-bean>
        <ejb-name>OrquestratorBean</ejb-name> 
        <jndi-name>OrquestratorBean</jndi-name> 
        <dispatch-policy>ResponseTimeReqClass-0</dispatch-policy> 
    </weblogic-enterprise-bean>

</weblogic-ejb-jar>

我已将其编译为JAR并将其部署在WebLogic上,作为管理服务器和我的解决方案上的所有群集节点共享的库(处于“活动”状态)。


正如我在几个教程和示例中看到的那样,我在我的应用程序中使用此代码,以便调用bean:

InitialContext ic = null;
try {
    Hashtable<String,String> env = new Hashtable<String,String>();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
    env.put(Context.PROVIDER_URL, "t3://localhost:7001");
    ic = new InitialContext(env);
}
catch(Exception e) {
    System.out.println("\n\t Didn't get InitialContext: "+e);
}
//
try {
    Object obj = ic.lookup("OrquestratorBean");
    OrquestratorRemote remote =(OrquestratorRemote)obj;
    System.out.println("\n\n\t++ Remote => "+ remote.getClass());
    System.out.println("\n\n\t++ initOrquestrator()");
    remote.initOrquestrator();
}
catch(Exception e) {
    System.out.println("\n\n\t WorkManager Exception => "+ e);
    e.printStackTrace();
}

不幸的是,这不起作用。它在运行时抛出异常,如下所示:

  

WorkManager Exception =&gt;   javax.naming.NameNotFoundException:   无法解析'OrquestratorBean'。   已解决''[根异常是   javax.naming.NameNotFoundException:   无法解析'OrquestratorBean'。   解决 ''];剩下的名字   'OrquestratorBean'

看到这个后,我甚至尝试改变这一行

Object obj = ic.lookup("OrquestratorBean");

到此:

Object obj = ic.lookup("OrquestratorBean#orquestrator.OrquestratorBean");

但结果是相同的运行时异常。

任何人都可以帮助我检测我在这里做错了什么吗?我正在调试这个问题,因为我不知道如何检查可能导致此问题的原因......

提前感谢您的耐心和帮助。

2 个答案:

答案 0 :(得分:3)

您的EJB绑定在以下JNDI名称下(当部署为EJB模块时):

Object obj = ic.lookup("OrquestratorBean#orquestrator.OrquestratorRemote");

请注意,我将代码(没有 weblogic-ejb-jar.xml )部署为EJB模块,而不是共享库。

答案 1 :(得分:0)

似乎是ejb-jar.xml中的映射名称“Orquestrator”可能会覆盖Bean的mappedName = OrquestratorBean设置。 您是否尝试过“Orquestrator”的ic.lookup?

相关问题