gpt4 book ai didi

javax.命名.NameNotFoundException

转载 作者:太空狗 更新时间:2023-10-29 23:02:53 25 4
gpt4 key购买 nike

我正在运行一个使用 JBoss5 容器的 ejb 示例。我正在使用一个例子 from here(Part one) .
在示例中,我在 JBoss 中部署了 bean,在 Tomcat 中部署了一个应用程序(以从 JBoss 访问 bean)。我在 tomcat 服务器的屏幕上收到错误
javax.naming.NameNotFoundException: greetJndi 未绑定(bind)

(greetJndi 是 jboss.xml 文件中的 jndi-name )在JBoss中部署有什么特定的目录结构吗?

谢谢

最佳答案

I am getting the error (...) javax.naming.NameNotFoundException: greetJndi not bound

这意味着没有任何内容绑定(bind)到 jndi 名称 greetJndi,很可能是因为部署问题,因为本教程的质量极低(检查服务器日志) .我会回来的。

Is there any specific directory structure to deploy in JBoss?

ejb-jar 的内部结构应该是这样的(使用上述链接中的糟糕的命名约定和默认包):

.├── greetBean.java├── greetHome.java├── greetRemote.java└── META-INF    ├── ejb-jar.xml    └── jboss.xml

But as already mentioned, this tutorial is full of mistakes:

  • there is an extra character (<enterprise-beans>] <-- HERE) in the ejb-jar.xml (!)
  • a space is missing after PUBLIC in the ejb-jar.xml and jboss.xml (!!)
  • the jboss.xml is incorrect, it should contain a session element instead of entity (!!!)

Here is a "fixed" version of the ejb-jar.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>greetBean</ejb-name>
<home>greetHome</home>
<remote>greetRemote</remote>
<ejb-class>greetBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>

还有jboss.xml:

<?xml version="1.0"?>
<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.2//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">
<jboss>
<enterprise-beans>
<session>
<ejb-name>greetBean</ejb-name>
<jndi-name>greetJndi</jndi-name>
</session>
</enterprise-beans>
</jboss>

完成这些更改并重新打包 ejb-jar 后,我能够成功部署它:

21:48:06,512 INFO  [Ejb3DependenciesDeployer] Encountered deployment AbstractVFSDeploymentContext@5060868{vfszip:/home/pascal/opt/jboss-5.1.0.GA/server/default/deploy/greet.jar/}21:48:06,534 INFO  [EjbDeployer] installing bean: ejb/#greetBean,uid1998144821:48:06,534 INFO  [EjbDeployer]   with dependencies:21:48:06,534 INFO  [EjbDeployer]   and supplies:21:48:06,534 INFO  [EjbDeployer]    jndi:greetJndi21:48:06,624 INFO  [EjbModule] Deploying greetBean21:48:06,661 WARN  [EjbModule] EJB configured to bypass security. Please verify if this is intended. Bean=greetBean Deployment=vfszip:/home/pascal/opt/jboss-5.1.0.GA/server/default/deploy/greet.jar/21:48:06,805 INFO  [ProxyFactory] Bound EJB Home 'greetBean' to jndi 'greetJndi'

该教程需要重大改进;我建议远离 roseindia.net。

关于javax.命名.NameNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3911856/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com