EJB远程调用查找Weblogic-Liferay

时间:2018-07-13 22:32:59

标签: java liferay weblogic ejb-3.0

我是EJB的新手,我正试图从Liferay使用远程EJB。使用t3客户端(wlthint3client.jar)将EJB部署在WebLogic,Im上。 EJB的部分代码是:

Stateless(name = "myDataEJB", mappedName = "ejb/MyDataEJB",
description = "Get important Data")
@Remote({
    MyDataEJB.class,
    SecurityContext.class
})
@RolesAllowed({
    "MyRole"
})

@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public class MyDataEJBEJBImpl extends TheBaseSpringSecurityEJB implements MyDataEJBEJB {
//some stuff

下一个来自Liferay的代码:

Properties p = new Properties(); 
p.put(Context.PROVIDER_URL, "t3://someip:someip,anotherip:anotherport"); 
p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
p.put(Context.SECURITY_PRINCIPAL, "some");
p.put(Context.SECURITY_CREDENTIALS, "somepass");

try {
     Context ctx = new InitialContext(p);
     MyDataEJB mydataEJB =
         (MyDataEJB)ctx.lookup("ejb/MyDataEJB#com.company.proyect.worker.ejb.MyDataEJB");

我得到这个:

javax.naming.NameNotFoundException: While trying to lookup 'ejb.MyDataEJB#com.company.proyect.worker.ejb.MyDataEJB' didn't find subcontext 'MyDataEJB#com'. Resolved 'ejb'[Root exception is javax.naming.NameNotFoundException:While trying to lookup 'ejb.MyDataEJB#com.company.proyect.worker.ejb.MyDataEJB' didn't find subcontext 'ejb.MyDataEJB#com.Resolved 'ejb'] remaining name 'ejb.MyDataEJB#com/company/proyect/worker/ejb/MyDataEJB'' 

您对发生的事情有任何了解吗?

我的查询的格式ejb/MyDataEJB#com.company.proyect.worker.ejb.MyDataEJB是否错误? 非常感谢! :)

1 个答案:

答案 0 :(得分:0)

尝试使用 MyDataEJB mydataEJB =          (MyDataEJB)ctx.lookup(“ ejb / MyDataEJB”);

因为您的EJB由JNDI中的ejb / MyDataEJB映射。