当前位置: 技术问答>java相关
求助EJB错误的解决方法,多谢!
来源: 互联网 发布时间:2015-05-13
本文导语: 用jbuilder6开发bmp,下面函数为jbuilder自动生成的代码: public void setEntityContext(EntityContext entityContext) { super.setEntityContext(entityContext); try { javax.naming.Context context = new javax.naming.InitialContext(); ...
用jbuilder6开发bmp,下面函数为jbuilder自动生成的代码:
public void setEntityContext(EntityContext entityContext) {
super.setEntityContext(entityContext);
try {
javax.naming.Context context = new javax.naming.InitialContext();
try {
dataSource = (DataSource) context.lookup("java:comp/env/jdbc/DataSource");
}
catch(Exception e) {
throw new EJBException("Error looking up dataSource: " + e.toString());
}
}
用bmp测试程序执行bmp的create()功能时,出现如下错误信息,请问如何解决?
(错误出现在上面函数的第二个try()内部。)
java.rmi.RemoteException: Error during setXXXContext: ; nested exception is:
javax.ejb.EJBException: Error initializing context:javax.ejb.EJBException: Error looking up dataSource: javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: Unable to resolve DataSource. Resolved: '' Unresolved:'DataSource' ; remaining name '']; Link Remaining Name: 'DataSource'
public void setEntityContext(EntityContext entityContext) {
super.setEntityContext(entityContext);
try {
javax.naming.Context context = new javax.naming.InitialContext();
try {
dataSource = (DataSource) context.lookup("java:comp/env/jdbc/DataSource");
}
catch(Exception e) {
throw new EJBException("Error looking up dataSource: " + e.toString());
}
}
用bmp测试程序执行bmp的create()功能时,出现如下错误信息,请问如何解决?
(错误出现在上面函数的第二个try()内部。)
java.rmi.RemoteException: Error during setXXXContext: ; nested exception is:
javax.ejb.EJBException: Error initializing context:javax.ejb.EJBException: Error looking up dataSource: javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: Unable to resolve DataSource. Resolved: '' Unresolved:'DataSource' ; remaining name '']; Link Remaining Name: 'DataSource'
|
你的那个错误是因为找不到DATASOURCE,你到WL的CONSOLE中,在JDBC
下的Data Sources下建立一个JNDIName叫:DataSource的数据源,然后
把:context.lookup("java:comp/env/jdbc/DataSource");
改为:context.lookup("DataSource");
就可以了
下的Data Sources下建立一个JNDIName叫:DataSource的数据源,然后
把:context.lookup("java:comp/env/jdbc/DataSource");
改为:context.lookup("DataSource");
就可以了