首页 文章

Weblogic 10.3.0中的EJB 3.0查找

提问于
浏览
1

1:我们的应用程序在Weblogic Application Server版本10.3.0上运行

2:在我们的系统中,我们需要部署符合EJB 3.0规范的EJB .

请查看我们的UAT环境的示例代码,如下所示:

/*The remote interface*/

package com.serverside.ejb.session;
import javax.ejb.Remote;

@Remote
public interface ASimpleSessionBeanRemote { 

 public void printThis(String print);

}


/*The bean class*/

package com.serverside.ejb.session;

import javax.ejb.Remote;
import javax.ejb.Stateless;

/**
 * Session Bean implementation class ASimpleSessionBean
 */
@Stateless(name="ASimpleSessionBean", **mappedName = "ASimpleSessionEJB"**)
@Remote(ASimpleSessionBeanRemote.class)
public class ASimpleSessionBean implements ASimpleSessionBeanRemote {

    /**
     * Default constructor. 
     */
    public ASimpleSessionBean() {
        // TODO Auto-generated constructor stub
    }

 @Override
 public void printThis(String print) {
  // TODO Auto-generated method stub
  System.out.println("ASimpleSessionBean : "+print); 
 }

}

3:打包在jar中的上述文件成功部署在服务器上 .

4:根据EJB 3.0规范,部署描述符不是必需的 . 因此,jar不包含ejb-jar.xml和weblogic-ejb-jar.xml

5:请在下面找到根据Weblogic Application Server文档的EJB3.0注释参考:

Annotation : @Stateless

Package: javax.ejb.Stateless

Attribute : mappedName

Description : 

Specifies the product-specific name to which the stateless session bean should be mapped.
You can also use this attribute to specify the JNDI name of this stateless session bean. WebLogic Server uses the value of the mappedName attribute when creating the bean’s global JNDI name. In particular, the JNDI name will be:
mappedName#name_of_businessInterface
where name_of_businessInterface is the fully qualified name of the business interface of this session bean.
For example, if you specify mappedName="bank" and the fully qualified name of the business interface is com.CheckingAccount, then the JNDI of the business interface is bank#com.CheckingAccount.

6:符合上述规范,部署在我们的应用服务器上的示例EJB具有绑定名称(如jndi树中所示),如下所示:

ASimpleSessionEJB#com.serverside.ejb.session.ASimpleSessionBeanRemote

使用此名称的jndi查找成功:

InitialContext.doLookup("ASimpleSessionEJB#com.serverside.ejb.session.ASimpleSesionBeanRemote");

7:现在,我们希望绑定名称是一个简单的字符串,即查找必须是这样的:

InitialContext.doLookup("ASimpleSessionEJB");

8:为了实现第7点,我们尝试使用ejb-jar.xml和weblogic-ejb-jar.xml,如下所示( Sorry,couldn't figure out how to attach/render xml files ):

9:尽管有第8点,但绑定名称仍然如下:

ASimpleSessionEJB#com.serverside.ejb.session.ASimpleSessionBeanRemote

10:请指导我们参加第7点的解决方案和实施 .

谢谢 !

3 回答

  • 1

    这是weblogic-ejb-jar.xml的示例配置

    <wls:weblogic-enterprise-bean>      
         <wls:ejb-name>BasketBean</wls:ejb-name>            
         <wls:jndi-name>BasketBean</wls:jndi-name>
    </wls:weblogic-enterprise-bean>
    

    然后你可以像这样进行jndi查找:InitialContext.doLookup(“BasketBean”);

  • 0

    你能以某种方式粘贴你的weblogic-ejb.xml吗?至少名称元素 .

    您还可以指定运行此查找代码的位置吗?我希望它在Web容器内运行,否则你将看不到weblogic-ejb.xml . :)

    如果没有什么可以帮助您为什么不创建一个属性文件,您可以在其中指定您的密钥和一个长远程名称,然后只使用该密钥进行查找?

    干杯 .

    JS

  • 0

    在weblogic-ejb-jar.xml中,您应该能够使用jndi-name部分添加weblogic-enterprise-bean部分 . 这对我来说非常适合Weblogic版本10.3.1,10.3.3和10.3.4 . 我在10.3.0上遇到了一个问题 . ejb似乎部署得很好,jndi条目就在那里,但是当我尝试调用它时,我发现它无法找到bean类 . 不确定是什么导致了这一点,但希望jndi-name部分会为你做 .

    祝好运 .

相关问题