EJB を定義しましたが、それを別の war から使用しようとしています:
でejb-api.jar
:
@Remote
public interface Example {
// ...
}
でejb-impl.war
(を使用ejb-api.jar
):
@Stateless(mappedName = "ExampleEjb")
public class ExampleBean implements Example {
// ...
}
でejb-user.war
(を使用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();
}
}
}
JBoss AS 7.1 のインスタンスにデプロイしましたejb-impl.war
。ejb-user.war
すべてのクラスを同じ war ファイルに入れると、EJB が見つかります。しかし、この方法ではそうではありません (私は を取得しますNamingException
)。
jndi.properties
さらに、これらの内容のファイルを追加すると...
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
...次に、この種の警告が表示されます。
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.<init>(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.<init>(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]
私が間違っていることを知っていますか?