首先,我想强调一下,我已经阅读了StackOverflow中的其他文章(example),但也有类似的问题,但不幸的是我没有设法解决这个问题我在这些帖子上看到的答案。我不打算重新发布已经回答的问题,所以如果是这样的话,我很抱歉,我很感谢谁指出解决方案发布的位置。在Weblogic 10.3中调用EJB时NameNotFoundException
这里是我的问题:
我试图部署在WebLogic中10.3.2的EJB。目的是使用特定的WorkManager
来执行在该组件范围内生成的工作。记住
有了这个,我对我的WebLogic配置设置一个WorkManager
(名为ResponseTimeReqClass-0
),使用基于Web的界面(环境>工作管理>新)。下面是截图:
这里是我的会话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>
我在WebLogic编译放进一个.jar和部署它,作为一个库行政服务器和所有群集共享ñ在互联网上的教程)颂扬我的解决方案(它处于“活跃”状态)。
正如我在几个教程和示例所看到的,我用我的应用程序的代码,以调用豆:
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异常=> javax.naming.NameNotFoundException: 无法解析 'OrquestratorBean'。 已解决'[根异常是 javax.naming.NameNotFoundException: 无法解析'OrquestratorBean'。 已解决''];剩余名称 'OrquestratorBean'
见状后,我甚至试图改变这一行
Object obj = ic.lookup("OrquestratorBean");
这样:
Object obj = ic.lookup("OrquestratorBean#orquestrator.OrquestratorBean");
,但结果是一样的运行时异常。
任何人都可以请帮助我检测我在这里做错了什么?我正在调试这个很糟糕的时间,因为我不知道如何检查可能会导致此问题的原因...
在此先感谢您的耐心和帮助。
它是否在控制台>服务器> JNDI树视图中显示“OrquestratorBean”? – JoseK 2010-04-13 12:35:34
@josek如果你指的是“环境>服务器>管理服务器>常规>查看JNDI树”,我没有注意到任何“OrquestratorBean”条目。这是正确的地方吗? – XpiritO 2010-04-13 13:23:44