Weblogic 10.3 MDB 抛出 javax.sql.DataSource 异常
以下是我正在使用的应用程序:
- Weblogic 10.3.3
- Websphere MQ 7.0
- Oracle 11g Express Edition (DB)
以下是当前的处理流程:
- Weblogic 从 Websphere MQ 队列中读取消息并由 MDB 进行处理
- MDB 将消息保存到 DB
- MDB 将消息写入另一个 Websphere MQ 队列
这是一个 XA 事务,因此如果上述任何操作失败,消息将返回到原始队列。
以下是我在 Websphere MQ 队列上放置消息以启动该过程时出现的错误:
<Jun 29, 2010 11:15:15 PM CDT> <Error> <EJB> <BEA-010080> <An error occurred whi
le attempting to process a message inside a message-driven bean: com.bea.core.re
packaged.springframework.beans.factory.BeanCreationException: Dependency injecti
on failure: can't find the bean definition about class interface javax.sql.DataS
ource; nested exception is com.bea.core.repackaged.springframework.beans.factory
.NoSuchBeanDefinitionException: No unique bean of type [javax.sql.DataSource] is
defined: No beans of type javax.sql.DataSource; owner=com.bea.core.repackaged.s
pringframework.context.support.GenericApplicationContext@3de84b8: display name [
com.bea.core.repackaged.springframework.context.support.GenericApplicationContex
t@3de84b8]; startup date [Tue Jun 29 23:14:53 CDT 2010]; parent: com.bea.core.re
packaged.springframework.context.support.GenericApplicationContext@3dd694f
Nested exception: com.bea.core.repackaged.springframework.beans.factory.NoSuchBe
anDefinitionException: No unique bean of type [javax.sql.DataSource] is defined:
No beans of type javax.sql.DataSource; owner=com.bea.core.repackaged.springfram
ework.context.support.GenericApplicationContext@3de84b8: display name [com.bea.c
ore.repackaged.springframework.context.support.GenericApplicationContext@3de84b8
]; startup date [Tue Jun 29 23:14:53 CDT 2010]; parent: com.bea.core.repackaged.
springframework.context.support.GenericApplicationContext@3dd694f
Exception is : com.bea.core.repackaged.springframework.beans.factory.BeanCreatio
nException: Dependency injection failure: can't find the bean definition about c
lass interface javax.sql.DataSource; nested exception is com.bea.core.repackaged
.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of
type [javax.sql.DataSource] is defined: No beans of type javax.sql.DataSource; o
wner=com.bea.core.repackaged.springframework.context.support.GenericApplicationC
ontext@3de84b8: display name [com.bea.core.repackaged.springframework.context.su
pport.GenericApplicationContext@3de84b8]; startup date [Tue Jun 29 23:14:53 CDT
2010]; parent: com.bea.core.repackaged.springframework.context.support.GenericAp
plicationContext@3dd694f
at com.bea.core.repackaged.springframework.jee.inject.Jsr250Metadata.app
lyInjections(Jsr250Metadata.java:244)
at com.bea.core.repackaged.springframework.jee.inject.Jsr250Metadata.inj
ect(Jsr250Metadata.java:226)
at com.bea.core.repackaged.springframework.jee.spi.EjbComponentCreatorBr
okerImpl.injection(EjbComponentCreatorBrokerImpl.java:112)
at com.bea.core.repackaged.springframework.jee.spi.EjbComponentCreatorBr
okerImpl.getBean(EjbComponentCreatorBrokerImpl.java:70)
at weblogic.ejb.container.injection.EjbComponentCreatorImpl.getBean(EjbC
omponentCreatorImpl.java:68)
at weblogic.ejb.container.manager.BaseEJBManager.createNewBeanInstance(B
aseEJBManager.java:216)
at weblogic.ejb.container.manager.BaseEJBManager.allocateBean(BaseEJBMan
ager.java:231)
at weblogic.ejb.container.manager.MessageDrivenManager.createBean(Messag
eDrivenManager.java:288)
at weblogic.ejb.container.pool.MessageDrivenPool.createBean(MessageDrive
nPool.java:174)
at weblogic.ejb.container.pool.MessageDrivenPool.getBean(MessageDrivenPo
ol.java:99)
at weblogic.ejb.container.internal.MDListener.execute(MDListener.java:43
4)
at weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDL
istener.java:371)
at weblogic.ejb.container.internal.NewJMSMessagePoller.processOneMessage
(NewJMSMessagePoller.java:248)
at weblogic.ejb.container.internal.NewJMSMessagePoller.run(NewJMSMessage
Poller.java:121)
at weblogic.ejb.container.internal.NewJMSMessagePoller.timerExpired(NewJ
MSMessagePoller.java:208)
at weblogic.timers.internal.TimerImpl.run(TimerImpl.java:273)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTunin
gWorkManagerImpl.java:528)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused by: com.bea.core.repackaged.springframework.beans.factory.NoSuchBeanDefin
itionException: No unique bean of type [javax.sql.DataSource] is defined: No bea
ns of type javax.sql.DataSource; owner=com.bea.core.repackaged.springframework.c
ontext.support.GenericApplicationContext@3de84b8: display name [com.bea.core.rep
ackaged.springframework.context.support.GenericApplicationContext@3de84b8]; star
tup date [Tue Jun 29 23:14:53 CDT 2010]; parent: com.bea.core.repackaged.springf
ramework.context.support.GenericApplicationContext@3dd694f
at com.bea.core.repackaged.springframework.jee.inject.Jsr250Metadata.get
UniqueInstanceOfType(Jsr250Metadata.java:305)
at com.bea.core.repackaged.springframework.jee.inject.Jsr250Metadata.res
olveByType(Jsr250Metadata.java:299)
at com.bea.core.repackaged.springframework.jee.inject.Jsr250Metadata.res
olve(Jsr250Metadata.java:286)
at com.bea.core.repackaged.springframework.jee.inject.Jsr250Metadata.app
lyInjections(Jsr250Metadata.java:238)
at com.bea.core.repackaged.springframework.jee.inject.Jsr250Metadata.inj
ect(Jsr250Metadata.java:227)
at com.bea.core.repackaged.springframework.jee.spi.EjbComponentCreatorBr
okerImpl.injection(EjbComponentCreatorBrokerImpl.java:112)
at com.bea.core.repackaged.springframework.jee.spi.EjbComponentCreatorBr
okerImpl.getBean(EjbComponentCreatorBrokerImpl.java:74)
... 15 more
>
<Jun 29, 2010 11:15:15 PM CDT> <Warning> <EJB> <BEA-010065> <MessageDrivenBean t
hrew an Exception in onMessage(). The exception was:
com.bea.core.repackaged.springframework.beans.factory.BeanCreationException: De
pendency injection failure: can't find the bean definition about class interface
javax.sql.DataSource; nested exception is com.bea.core.repackaged.springframewo
rk.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [javax.sq
l.DataSource] is defined: No beans of type javax.sql.DataSource; owner=com.bea.c
ore.repackaged.springframework.context.support.GenericApplicationContext@3de84b8
: display name [com.bea.core.repackaged.springframework.context.support.GenericA
pplicationContext@3de84b8]; startup date [Tue Jun 29 23:14:53 CDT 2010]; parent:
com.bea.core.repackaged.springframework.context.support.GenericApplicationConte
xt@3dd694f.
com.bea.core.repackaged.springframework.beans.factory.BeanCreationException: Dep
endency injection failure: can't find the bean definition about class interface
javax.sql.DataSource; nested exception is com.bea.core.repackaged.springframewor
k.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [javax.sql
.DataSource] is defined: No beans of type javax.sql.DataSource; owner=com.bea.co
re.repackaged.springframework.context.support.GenericApplicationContext@3de84b8:
display name [com.bea.core.repackaged.springframework.context.support.GenericAp
plicationContext@3de84b8]; startup date [Tue Jun 29 23:14:53 CDT 2010]; parent:
com.bea.core.repackaged.springframework.context.support.GenericApplicationContex
t@3dd694f
at com.bea.core.repackaged.springframework.jee.inject.Jsr250Metadata.app
lyInjections(Jsr250Metadata.java:244)
at com.bea.core.repackaged.springframework.jee.inject.Jsr250Metadata.inj
ect(Jsr250Metadata.java:226)
at com.bea.core.repackaged.springframework.jee.spi.EjbComponentCreatorBr
okerImpl.injection(EjbComponentCreatorBrokerImpl.java:112)
at com.bea.core.repackaged.springframework.jee.spi.EjbComponentCreatorBr
okerImpl.getBean(EjbComponentCreatorBrokerImpl.java:70)
at weblogic.ejb.container.injection.EjbComponentCreatorImpl.getBean(EjbC
omponentCreatorImpl.java:68)
Truncated. see log file for complete stacktrace
以下是我在代码中连接到数据库的方式
// Datasource declaration
@Resource(name = "database", mappedName = "datasource/oracle-11g")
private DataSource database;
...
// Save data to messages table
String sql = "insert into messages(payload) values(?)";
OracleConnection dbConn = (OracleConnection) database.getConnection();
OraclePreparedStatement insertSql = (OraclePreparedStatement)
dbConn.prepareStatement(sql);
insertSql.setStringForClob(1, msgPayload);
insertSql.execute();
到目前为止,我已执行以下操作来进行故障排除:
- 我已检查我的数据源确认 jndi 名称确实是“datasource/oracle-11g
- 我已经在数据源设置期间成功地能够通过“测试配置”按钮连接到数据库
- 我已经验证消息表确实存在于数据库中
无论如何都可以打开日志记录这样我就可以看到与数据库的任何特定 JDBC 连接错误吗?
Here are the applications that I'm using:
- Weblogic 10.3.3
- Websphere MQ 7.0
- Oracle 11g Express Edition (DB)
Here is the current process flow:
- A message is read off a Websphere MQ queue by Weblogic and processed by the MDB
- The MDB saves the message to the DB
- The MDB writes the message to another Websphere MQ queue
This is an XA transaction so if anything above fails, the message will be returned to the original queue.
Here is the error when I put a message on the Websphere MQ queue to start the process:
<Jun 29, 2010 11:15:15 PM CDT> <Error> <EJB> <BEA-010080> <An error occurred whi
le attempting to process a message inside a message-driven bean: com.bea.core.re
packaged.springframework.beans.factory.BeanCreationException: Dependency injecti
on failure: can't find the bean definition about class interface javax.sql.DataS
ource; nested exception is com.bea.core.repackaged.springframework.beans.factory
.NoSuchBeanDefinitionException: No unique bean of type [javax.sql.DataSource] is
defined: No beans of type javax.sql.DataSource; owner=com.bea.core.repackaged.s
pringframework.context.support.GenericApplicationContext@3de84b8: display name [
com.bea.core.repackaged.springframework.context.support.GenericApplicationContex
t@3de84b8]; startup date [Tue Jun 29 23:14:53 CDT 2010]; parent: com.bea.core.re
packaged.springframework.context.support.GenericApplicationContext@3dd694f
Nested exception: com.bea.core.repackaged.springframework.beans.factory.NoSuchBe
anDefinitionException: No unique bean of type [javax.sql.DataSource] is defined:
No beans of type javax.sql.DataSource; owner=com.bea.core.repackaged.springfram
ework.context.support.GenericApplicationContext@3de84b8: display name [com.bea.c
ore.repackaged.springframework.context.support.GenericApplicationContext@3de84b8
]; startup date [Tue Jun 29 23:14:53 CDT 2010]; parent: com.bea.core.repackaged.
springframework.context.support.GenericApplicationContext@3dd694f
Exception is : com.bea.core.repackaged.springframework.beans.factory.BeanCreatio
nException: Dependency injection failure: can't find the bean definition about c
lass interface javax.sql.DataSource; nested exception is com.bea.core.repackaged
.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of
type [javax.sql.DataSource] is defined: No beans of type javax.sql.DataSource; o
wner=com.bea.core.repackaged.springframework.context.support.GenericApplicationC
ontext@3de84b8: display name [com.bea.core.repackaged.springframework.context.su
pport.GenericApplicationContext@3de84b8]; startup date [Tue Jun 29 23:14:53 CDT
2010]; parent: com.bea.core.repackaged.springframework.context.support.GenericAp
plicationContext@3dd694f
at com.bea.core.repackaged.springframework.jee.inject.Jsr250Metadata.app
lyInjections(Jsr250Metadata.java:244)
at com.bea.core.repackaged.springframework.jee.inject.Jsr250Metadata.inj
ect(Jsr250Metadata.java:226)
at com.bea.core.repackaged.springframework.jee.spi.EjbComponentCreatorBr
okerImpl.injection(EjbComponentCreatorBrokerImpl.java:112)
at com.bea.core.repackaged.springframework.jee.spi.EjbComponentCreatorBr
okerImpl.getBean(EjbComponentCreatorBrokerImpl.java:70)
at weblogic.ejb.container.injection.EjbComponentCreatorImpl.getBean(EjbC
omponentCreatorImpl.java:68)
at weblogic.ejb.container.manager.BaseEJBManager.createNewBeanInstance(B
aseEJBManager.java:216)
at weblogic.ejb.container.manager.BaseEJBManager.allocateBean(BaseEJBMan
ager.java:231)
at weblogic.ejb.container.manager.MessageDrivenManager.createBean(Messag
eDrivenManager.java:288)
at weblogic.ejb.container.pool.MessageDrivenPool.createBean(MessageDrive
nPool.java:174)
at weblogic.ejb.container.pool.MessageDrivenPool.getBean(MessageDrivenPo
ol.java:99)
at weblogic.ejb.container.internal.MDListener.execute(MDListener.java:43
4)
at weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDL
istener.java:371)
at weblogic.ejb.container.internal.NewJMSMessagePoller.processOneMessage
(NewJMSMessagePoller.java:248)
at weblogic.ejb.container.internal.NewJMSMessagePoller.run(NewJMSMessage
Poller.java:121)
at weblogic.ejb.container.internal.NewJMSMessagePoller.timerExpired(NewJ
MSMessagePoller.java:208)
at weblogic.timers.internal.TimerImpl.run(TimerImpl.java:273)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTunin
gWorkManagerImpl.java:528)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused by: com.bea.core.repackaged.springframework.beans.factory.NoSuchBeanDefin
itionException: No unique bean of type [javax.sql.DataSource] is defined: No bea
ns of type javax.sql.DataSource; owner=com.bea.core.repackaged.springframework.c
ontext.support.GenericApplicationContext@3de84b8: display name [com.bea.core.rep
ackaged.springframework.context.support.GenericApplicationContext@3de84b8]; star
tup date [Tue Jun 29 23:14:53 CDT 2010]; parent: com.bea.core.repackaged.springf
ramework.context.support.GenericApplicationContext@3dd694f
at com.bea.core.repackaged.springframework.jee.inject.Jsr250Metadata.get
UniqueInstanceOfType(Jsr250Metadata.java:305)
at com.bea.core.repackaged.springframework.jee.inject.Jsr250Metadata.res
olveByType(Jsr250Metadata.java:299)
at com.bea.core.repackaged.springframework.jee.inject.Jsr250Metadata.res
olve(Jsr250Metadata.java:286)
at com.bea.core.repackaged.springframework.jee.inject.Jsr250Metadata.app
lyInjections(Jsr250Metadata.java:238)
at com.bea.core.repackaged.springframework.jee.inject.Jsr250Metadata.inj
ect(Jsr250Metadata.java:227)
at com.bea.core.repackaged.springframework.jee.spi.EjbComponentCreatorBr
okerImpl.injection(EjbComponentCreatorBrokerImpl.java:112)
at com.bea.core.repackaged.springframework.jee.spi.EjbComponentCreatorBr
okerImpl.getBean(EjbComponentCreatorBrokerImpl.java:74)
... 15 more
>
<Jun 29, 2010 11:15:15 PM CDT> <Warning> <EJB> <BEA-010065> <MessageDrivenBean t
hrew an Exception in onMessage(). The exception was:
com.bea.core.repackaged.springframework.beans.factory.BeanCreationException: De
pendency injection failure: can't find the bean definition about class interface
javax.sql.DataSource; nested exception is com.bea.core.repackaged.springframewo
rk.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [javax.sq
l.DataSource] is defined: No beans of type javax.sql.DataSource; owner=com.bea.c
ore.repackaged.springframework.context.support.GenericApplicationContext@3de84b8
: display name [com.bea.core.repackaged.springframework.context.support.GenericA
pplicationContext@3de84b8]; startup date [Tue Jun 29 23:14:53 CDT 2010]; parent:
com.bea.core.repackaged.springframework.context.support.GenericApplicationConte
xt@3dd694f.
com.bea.core.repackaged.springframework.beans.factory.BeanCreationException: Dep
endency injection failure: can't find the bean definition about class interface
javax.sql.DataSource; nested exception is com.bea.core.repackaged.springframewor
k.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [javax.sql
.DataSource] is defined: No beans of type javax.sql.DataSource; owner=com.bea.co
re.repackaged.springframework.context.support.GenericApplicationContext@3de84b8:
display name [com.bea.core.repackaged.springframework.context.support.GenericAp
plicationContext@3de84b8]; startup date [Tue Jun 29 23:14:53 CDT 2010]; parent:
com.bea.core.repackaged.springframework.context.support.GenericApplicationContex
t@3dd694f
at com.bea.core.repackaged.springframework.jee.inject.Jsr250Metadata.app
lyInjections(Jsr250Metadata.java:244)
at com.bea.core.repackaged.springframework.jee.inject.Jsr250Metadata.inj
ect(Jsr250Metadata.java:226)
at com.bea.core.repackaged.springframework.jee.spi.EjbComponentCreatorBr
okerImpl.injection(EjbComponentCreatorBrokerImpl.java:112)
at com.bea.core.repackaged.springframework.jee.spi.EjbComponentCreatorBr
okerImpl.getBean(EjbComponentCreatorBrokerImpl.java:70)
at weblogic.ejb.container.injection.EjbComponentCreatorImpl.getBean(EjbC
omponentCreatorImpl.java:68)
Truncated. see log file for complete stacktrace
Here is how I'm connecting to my database in my code
// Datasource declaration
@Resource(name = "database", mappedName = "datasource/oracle-11g")
private DataSource database;
...
// Save data to messages table
String sql = "insert into messages(payload) values(?)";
OracleConnection dbConn = (OracleConnection) database.getConnection();
OraclePreparedStatement insertSql = (OraclePreparedStatement)
dbConn.prepareStatement(sql);
insertSql.setStringForClob(1, msgPayload);
insertSql.execute();
I've done the following to troubleshoot so far:
- I've checked my datasource to confirm that the jndi name is indeed "datasource/oracle-11g
- I have successfully been able to connect to the database via Test Configuration button during datasource setup
- I've validated that the messages table does exist in the db
Is there anyway to turn up logging so I can see any specific JDBC connections errors to the database?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可能没有为 weblogic 管理控制台中定义的数据源设置目标管理服务器。
如果设置正确,则不应出现此错误。
you probably did not set the target management server for the data source defined in weblogic admin console.
When set properly this error should not appear.
您的配置有问题。以下消息告诉您:
您要么没有数据源,要么没有正确配置。
Your configuration is faulty. Here's the message that tells you so:
You either don't have a DataSource or it's not configured properly.
从发布的跟踪来看,MDB 似乎无法写入数据库,因为
DataSource
注入失败:某处发生冲突。我认为你需要告诉我们更多信息才能得到更准确的答案。
更新:我想知道
@Resource
和DataSource
属性(database
在这种情况下)不会导致问题。因此,不要这样:
您可以尝试一下吗(假设
datasource/oracle-11g
是全局 JNDI 名称):另请参阅:
From the posted trace, it seems the MDB can't write to the database because the
DataSource
fails at being injected:There is a collision somewhere. I think you need to tell us more for a more precise answer.
Update: I wonder if using the same
name
for the@Resource
and theDataSource
property (database
in this case) is not causing the problem.So, instead of:
Could you try this (assuming
datasource/oracle-11g
is the global JNDI name):See also: