在 Weblogic 10.3 中调用 EJB 时出现 NameNotFoundException

发布于 2024-08-28 11:52:20 字数 4502 浏览 6 评论 0原文

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

这是我的问题:

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

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

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异常=> javax.naming.NameNotFoundException: 无法解析“OrquestratorBean”。 已解决 '' [根异常是 javax.naming.NameNotFoundException: 无法解析“OrquestratorBean”。 已解决''];剩余名称 'OrquestratorBean'

看到这个之后,我什至尝试将这一行更改

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

为:

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

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

谁能帮我检测我在这里做错了什么?我在调试这个问题时遇到了麻烦,因为我不知道如何检查可能导致此问题的原因...

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

First of all, I'd like to underline that I've already read other posts in StackOverflow (example) with similar questions, but unfortunately I didn't manage to solve this problem with the answers I saw on those posts. I have no intention to repost a question that has already been answered, so if that's the case, I apologize and I'd be thankful to whom points out where the solution is posted.

Here is my question:

I'm trying to deploy an EJB in WebLogic 10.3.2. The purpose is to use a specific WorkManager to execute work produced in the scope of this component.

With this in mind, I've set up a WorkManager (named ResponseTimeReqClass-0) on my WebLogic configuration, using the web-based interface (Environment > Work Managers > New). Here is a screenshot:

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

Here is my session bean definition and descriptors:

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

(I've placed work manager configuration in this file, as I've seen on a tutorial on the internet)

<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>

I've compiled this into a JAR and deployed it on WebLogic, as a library shared by administrative server and all cluster nodes on my solution (it's in "Active" state).


As I've seen in several tutorials and examples, I'm using this code on my application, in order to call the 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();
}

Unfortunately, this don't work. It throws an exception on runtime, as follows:

WorkManager Exception =>
javax.naming.NameNotFoundException:
Unable to resolve 'OrquestratorBean'.
Resolved '' [Root exception is
javax.naming.NameNotFoundException:
Unable to resolve 'OrquestratorBean'.
Resolved '']; remaining name
'OrquestratorBean'

After seeing this, I've even tried changing this line

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

to this:

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

but the result was the same runtime exception.

Can anyone please help me detecting what am I doing wrong here? I'm having a bad time debugging this, as I don't know how to check out what may be causing this issue...

Thanks in advance for your patience and help.

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

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

发布评论

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

评论(2

秋意浓 2024-09-04 11:52:20

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

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

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

Your EJB gets bound under the following JNDI name (when deployed as EJB module):

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

Note that I deployed your code (without the weblogic-ejb-jar.xml) as an EJB module, not as a shared library.

鸠魁 2024-09-04 11:52:20

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

seems like your mapped-name in ejb-jar.xml "Orquestrator" may be overriding the mappedName=OrquestratorBean setting of the Bean.
Have you tried ic.lookup for "Orquestrator" ?

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