java bean中连接Weblogic DataSource失败!虚心学习,焦急等待!·

rzg 2003-10-25 09:45:26
我在Weblogic7种配置Connection pool,然后添加TxDataSource,
DataSource的JNDI名称为:“petstore”.然后在一个bean中用
自定义函数获得连接。

我的代码如下:

public Connection getConnection()throws Exception {
System.out.println("Connecting to database...");
Context ctx = null;
DataSource ds = null;
try
{
ctx = new InitialContext(System.getProperties());
ds = (DataSource)ctx.lookup("petstore");
return ds.getConnection();
}
catch(Exception e)
{
System.err.println("Couldn't connect to datasource.");
e.printStackTrace();
throw new Exception(e.toString());
}
}
当调用客户端时,错误提示:
setEntityContext() called!
Connecting to database...
Couldn't connect to datasource.
javax.naming.NameNotFoundException: Unable to resolve 'petstore' Resolved: '' Un
resolved:'petstore' ; remaining name 'petstore'
at weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:17
4)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke
....
...全文
72 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
alienbat 2003-10-25
  • 打赏
  • 举报
回复
不会吧?
请运行程序前先运行你配置好的那个server。
orant 2003-10-25
  • 打赏
  • 举报
回复
错误的原因是:client不能找到EJB的jndi name.
解决方法:检查EJB JAR file的部署 .
具体步骤:(To check the deployment, start WebLogic console, find the EJB module name from Deployments ->EJB,
click on the EJB Module name, then click Deploy from the right-side window. If the JAR file is deployed properly, you will see a deployment status as true in the WebLogic console.
Also click on Monitoring tab, and click the corresponding links to see if your EJB is running.)这用英文写出来的,比较清楚

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧