当我在我的代码中尝试以下查找时:
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
任何人都有任何关于如何配置JBoss命名服务的想法,根据上面的报价覆盖Tomcat的JNDI实现,以便我可以在java:comp / env上查找?
仅供参考 – 我的环境Tomcat 5.5.9,Seam 2.0.2sp,嵌入式JBoss(Beta 3),
注意:我的数据库连接正确设置了-ds.xml文件,并且可以按照说明在类路径上访问.
另请注意:我已在嵌入式Jboss论坛和缝用户论坛中发布此问题.
>上面的代码适用于JBoss 4.2.2.GA,这里是使用的JNDI ctx参数:
java.naming.factory.initial的= org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs = org.jboss.naming:org.jnp.interfaces:
org.jboss.naming:org.jnp.interfaces
>上面的代码适用于Tomcat 5.5.x,这里是使用的JNDI ctx参数:
java.naming.factory.initial的= org.apache.naming.java.javaURLContextFactory
java.naming.factory.url.pkgs = org.apache.naming
>上面的代码在Tomcat 5.5.x中使用嵌入式JBoss(Beta 3)失败,并显示以上错误消息.
java.naming.factory.initial的= org.apache.naming.java.javaURLContextFactory
java.naming.factory.url.pkgs = org.apache.naming上面的代码在tomcat 5.5.x中使用JBoss Embedded时出现上述错误失败
任何人都有任何想法我需要做什么配置嵌入式JBoss JNDI配置?