简体   繁体   English

我们如何在Weblogic12中为EJB3提供自定义的jndi名称

[英]How do we provide custom jndi name for EJB3 in Weblogic12

I am trying to deploy an ejb but would like to provide custom jndi name for it. 我正在尝试部署ejb,但想为其提供自定义的jndi名称。 I created below: weblogic-ejb-jar.xml 我在下面创建了:weblogic-ejb-jar.xml
` `

    <?xml version='1.0' encoding='UTF-8'?>
<weblogic-ejb-jar xmlns="http://xmlns.oracle.com/weblogic/weblogic-ejb-jar" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-ejb-jar http://xmlns.oracle.com/weblogic/weblogic-ejb-jar/1.2/weblogic-ejb-jar.xsd">
  <weblogic-enterprise-bean>
    <ejb-name>test</ejb-name>
    <jndi-name>ejb/test</jndi-name>
    <enable-call-by-reference>true</enable-call-by-reference>
  </weblogic-enterprise-bean>
</weblogic-ejb-jar>

` `
But when I try to look up bean using this jndi name, I get javax.naming.NameNotFoundException. 但是,当我尝试使用此jndi名称查找bean时,会得到javax.naming.NameNotFoundException。

Is there any configuration that I am missing here? 我在这里缺少任何配置吗?

It is likely that you are not looking up the bean correctly. 您可能没有正确查找bean。 You could try the following. 您可以尝试以下方法。

Context initialContext = new InitialContext();
test testInstance = (test)
initialContext.lookup("java:comp/env/ejb/test");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM