当前位置: 首页 > 工具软件 > JBoss Wiki > 使用案例 >

java jndi jboss_java – 帮助在Tomcat 5.5.x中使用嵌入式JBoss配置JNDI

狄钧
2023-12-01

当我在我的代码中尝试以下查找时:

Context initCtx = new InitialContext();

Context envCtx = (Context) initCtx.lookup("java:comp/env");

return (DataSource) envCtx.lookup("jdbc/mydb");

我得到以下异常:

java.sql.sqlException: QueryResults: Unable to initialize naming context:

Name java:comp is not bound in this Context at

com.onsitemanager.database.ThreadLocalConnection.getConnection

(ThreadLocalConnection.java:130) at

...

我在JBoss wiki instructions之后安装了嵌入式JBoss.我使用configuration wiki page中指定的“默认扫描每个WAR”部署配置了Tomcat.

引用配置页面:

JNDI

Embedded JBoss components like connection pooling,EJB,JPA,and transactions make

extensive use of JNDI to publish services. Embedded JBoss overrides Tomcat’s JNDI

implementation by layering itself on top of Tomcat’s JNDI instantiation. There are a few > reasons for this:

To avoid having to declare each and every one of these services within server.xml

To allow seemeless integration of the java:comp namespace between web apps and

EJBs.

Tomcat’s JNDI implementation has a few critical bugs in it that hamper some JBoss

components ability to work

We want to provide the option for you of remoting EJBs and other services that can > be remotely looked up

@H_404_41@

任何人都有任何关于如何配置JBoss命名服务的想法,根据上面的报价覆盖Tomcat的JNDI实现,以便我可以在java:comp / env上查找?

仅供参考 – 我的环境Tomcat 5.5.9,Seam 2.0.2sp,嵌入式JBoss(Beta 3),

注意:我的数据库连接正确设置了-ds.xml文件,并且可以按照说明在类路径上访问.

另请注意:我已在嵌入式Jboss论坛和缝用户论坛中发布此问题.

 类似资料: