[英]javax.naming.NameNotFoundException: env/jdbc/DataSource on JBOSS with SQL Server
The JNDI name in my domain.xml is 我的domain.xml中的JNDI名称是
The Context.lookup has been defined as follows: Context.lookup的定义如下:
dsName = "java:comp/env"; dsName =“ java:comp / env”;
Context ctx = (Context) new javax.naming.InitialContext(); 上下文ctx =(上下文)new javax.naming.InitialContext();
Context envCtx = (Context)ctx.lookup(dsName); 上下文envCtx =(Context)ctx.lookup(dsName);
DataSource ds = (DataSource)envCtx.lookup("jdbc/DataSource"); 数据源ds =(DataSource)envCtx.lookup(“ jdbc / DataSource”);
conn = ds.getConnection(); conn = ds.getConnection();
I'm getting the following exception when connected to SQLserver with the following configuration where as it is working fine with Oracle.The lookup name somehow is not validated properly and connection object is getting null. 当使用以下配置连接到SQLserver时,出现以下异常,因为它可以与Oracle很好地工作。查找名称以某种方式未得到正确验证,并且连接对象为null。
javax.naming.NameNotFoundException: env/jdbc/DataSource javax.naming.NameNotFoundException:env / jdbc / DataSource
ERROR [stderr] (ServerService Thread Pool -- 78) at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:104) org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:104)上的错误[stderr](ServerService线程池-78)
ERROR [stderr] (ServerService Thread Pool -- 78) at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:197) java.lang.NullPointerException org.jboss.as.naming.NamingContext.lookup(NamingContext.java:197)上的错误[stderr](ServerService线程池-78)
Even Tried with something like 甚至尝试过类似的东西
DataSource ds = (DataSource)envCtx.lookup("java:comp/env/jdbc/DataSource"); 数据源ds =(DataSource)envCtx.lookup(“ java:comp / env / jdbc / DataSource”);
Could anyone suggest on this. 任何人都可以对此提出建议。
Thanks 谢谢
Check the logs and/or the JNDI tree in the administration console. 在管理控制台中检查日志和/或JNDI树。
Try these: 试试这些:
"java:DataSource"
"java:jboss/datasources/DataSource"
If not, please paste here the data source config section in the config file (eg standalone.xml) 如果没有,请在此处将配置文件中的“数据源配置”部分粘贴到此处(例如standalone.xml)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.