当前位置: 技术问答>java相关
weblogic6,EJB,LookUp
来源: 互联网 发布时间:2015-04-01
本文导语: 我在EJB中加入如下程序,调用EJB就会失败. dataSource = (DataSource)context.lookup("java:comp/env/jdbc/SchoolUserInfoDataSource"); 我需要怎样修改呢?错误信息如下: java.rmi.RemoteException: EJB Exception: ; nested exception is: javax.ejb.EJBException...
我在EJB中加入如下程序,调用EJB就会失败.
dataSource = (DataSource)context.lookup("java:comp/env/jdbc/SchoolUserInfoDataSource");
我需要怎样修改呢?错误信息如下:
java.rmi.RemoteException: EJB Exception: ; nested exception is:
javax.ejb.EJBException: Error initializing context:javax.ejb.EJBException: Error looking up dataSource or homeInterface: javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: Unable to resolve SchoolUserInfoDataSource. Resolved: '' Unresolved:'SchoolUserInfoDataSource' ; remaining name '']; Link Remaining Name: 'SchoolUserInfoDataSource'
dataSource = (DataSource)context.lookup("java:comp/env/jdbc/SchoolUserInfoDataSource");
我需要怎样修改呢?错误信息如下:
java.rmi.RemoteException: EJB Exception: ; nested exception is:
javax.ejb.EJBException: Error initializing context:javax.ejb.EJBException: Error looking up dataSource or homeInterface: javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: Unable to resolve SchoolUserInfoDataSource. Resolved: '' Unresolved:'SchoolUserInfoDataSource' ; remaining name '']; Link Remaining Name: 'SchoolUserInfoDataSource'
|
假定你在WebLogic里面的DataSource是:SchoolUserInfoDataSource
那么,你可以试一下以下方法:
Context context = new InitialContext();
try {
dataSource = (DataSource) context.lookup("SchoolUserInfoDataSource");
} catch(Exception e) {
throw new EJBException("Error looking up dataSource: " + e.toString());
}
或者你发mail给我,goldish@sina.com,我有获取连接的源代码,这里粘了两次粘不上来
那么,你可以试一下以下方法:
Context context = new InitialContext();
try {
dataSource = (DataSource) context.lookup("SchoolUserInfoDataSource");
} catch(Exception e) {
throw new EJBException("Error looking up dataSource: " + e.toString());
}
或者你发mail给我,goldish@sina.com,我有获取连接的源代码,这里粘了两次粘不上来
|
SchoolUserInfoDataSource应该跟weblogic的pool在xml文件里面配置起来
|
在你的EJB的weblogic_ejb_jar.xml中要加入res-reference内容,如果你用JB6的话这些都是很容易设置的.