Cannot instantiate EJBs with JBoss AS 7.1

I defined an EJB and I'm trying to use it from another war: In ejb-api.jar: @Remote public interface Example { // ... } ----- In ejb-impl.war (uses ejb-api.jar): @Stateless(mappedName = "ExampleEjb") public class ExampleBean implements Example { // ... } ----- In ejb-user.war (uses ejb-api.jar): @WebServlet("/ejbuser") public class UserServlet extends HttpServlet { @Override public void doGet(...) throws Exception { Example example = null; try { InitialContext context = new InitialContext(); example = (Example)context.lookup("ExampleEjb"); } catch (NamingException e) { e.printStackTrace(); } } } I deployed ejb-impl.war and ejb-user.war to an instance of JBoss AS 7.1. If I put all classes in the same war file, then the EJB is found. But this way, it's not (I get a NamingException). Furthermore, if I add a jndi.properties file with these contents... java.naming.factory.initial = org.jboss.naming.remote.client.InitialContextFactory java.naming.provider.url = remote://localhost:4447 jboss.naming.client.ejb.context = true java.naming.factory.url.pkgs = org.jboss.ejb.client.naming ... then I get this kind of warning: 16:55:46,268 WARNING [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-7) javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jnp.interfaces.NamingContextFactory from classloader ModuleClassLoader for Module "deployment.example.war:main" from Service Module Loader: javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jnp.interfaces.NamingContextFactory from classloader ModuleClassLoader for Module "deployment.example.war:main" from Service Module Loader at org.jboss.as.naming.InitialContextFactoryBuilder.createInitialContextFactory(InitialContextFactoryBuilder.java:64) at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:681) [rt.jar:1.7.0_03] at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307) [rt.jar:1.7.0_03] at javax.naming.InitialContext.init(InitialContext.java:242) [rt.jar:1.7.0_03] at javax.naming.InitialContext.(InitialContext.java:192) [rt.jar:1.7.0_03] at com.sun.faces.config.WebConfiguration.processJndiEntries(WebConfiguration.java:687) [jsf-impl-2.1.7-jbossorg-2.jar:] at com.sun.faces.config.WebConfiguration.(WebConfiguration.java:134) [jsf-impl-2.1.7-jbossorg-2.jar:] at com.sun.faces.config.WebConfiguration.getInstance(WebConfiguration.java:194) [jsf-impl-2.1.7-jbossorg-2.jar:] at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:163) [jsf-impl-2.1.7-jbossorg-2.jar:] at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:] at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:] at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final] at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_03] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_03] at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_03] Do you know what I'm doing wrong?

以上就是Cannot instantiate EJBs with JBoss AS 7.1的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏