首先,我想強調一下,我已經閱讀了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