在JBOSS上部署的EJB的端点(Endpoint for an EJB deployed on JBOSS)

系统教程 行业动态 更新时间:2024-06-14 16:58:30
在JBOSS上部署的EJB的端点(Endpoint for an EJB deployed on JBOSS)

我在war文件中部署了一个ejb(不是ear文件)。 我之前已成功使用了部署在ear文件中的ejb,但现在我得到了javax.naming.NameNotFoundException,因为我的EJB托管在war文件中。 如果我的Web应用程序被称为SpeechServices并且bean在com.xyz.ejb包下并且其名称是Service,那么我应该使用的JNDI查找字符串是什么? 我现在正在使用以下内容。

ServiceRemote remote = (ServiceRemote) ct.lookup("SpeechServices/Service/remote-com.xyz.ejb.ServiceRemote");

请帮我纠正上述陈述中的错误。

我的完整代码如下,如果它们在耳边,它可以连接到ejbs,

Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); env.put(Context.PROVIDER_URL, "jnp://localhost:1099"); env.put(Context.SECURITY_PRINCIPAL, "admin"); env.put(Context.SECURITY_CREDENTIALS, "admin"); env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.security.jndi.JndiLoginInitialContextFactory"); InitialContext ct = new InitialContext(env); ServiceRemote remote = (ServiceRemote) ct.lookup("SpeechServices/Service/remote-com.xyz.ejb.ServiceRemote"); System.out.println(remote.parseNotes(null, null, null));

I have deployed an ejb in a war file(not an ear file). I have successfully consumed an ejb deployed in an ear file previously but now I am getting javax.naming.NameNotFoundException because my EJB is hosted in the war file. If my web app is called SpeechServices and the bean is under com.xyz.ejb package and its name is Service then what will be the JNDI lookup string i should be using? I am using the following right now.

ServiceRemote remote = (ServiceRemote) ct.lookup("SpeechServices/Service/remote-com.xyz.ejb.ServiceRemote");

Please help me rectify the error in above statement.

My full code is following, which works to connect to ejbs if they are in an ear,

Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); env.put(Context.PROVIDER_URL, "jnp://localhost:1099"); env.put(Context.SECURITY_PRINCIPAL, "admin"); env.put(Context.SECURITY_CREDENTIALS, "admin"); env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.security.jndi.JndiLoginInitialContextFactory"); InitialContext ct = new InitialContext(env); ServiceRemote remote = (ServiceRemote) ct.lookup("SpeechServices/Service/remote-com.xyz.ejb.ServiceRemote"); System.out.println(remote.parseNotes(null, null, null));

最满意答案

检查JNDI以确保使用正确的密钥。 去做这个:

在JMX-Console中访问JBoss:service = JNDIView 调用list()方法 验证EJB是否正确绑定并确认您使用的密钥是否正确

Check the JNDI to make sure that you are using the right key. To do this:

Access JBoss:service=JNDIView in JMX-Console invoke list() method Verify whether your EJB is bound properly and confirm that the key you are using is correct

更多推荐

本文发布于:2023-04-15 03:27:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/b9d7c9e603ce00f72c7272753284a260.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:EJB   JBOSS   deployed   Endpoint

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!