title: Weblogic 10.3 MDB throwing javax.sql.DataSource exception
body: <p>Here are the applications that I'm using:<br></p>
  
  <ol>
  <li>Weblogic 10.3.3</li>
  <li>Websphere MQ 7.0</li>
  <li>Oracle 11g Express Edition (DB)</li>
  </ol>
  
  <p>Here is the current process flow:</p>
  
  <ol>
  <li>A message is read off a Websphere MQ queue by Weblogic and processed by the MDB</li>
  <li>The MDB saves the message to the DB</li>
  <li>The MDB writes the message to another Websphere MQ queue</li>
  </ol>
  
  <p>This is an XA transaction so if anything above fails, the message will be returned to the original queue.</p>
  
  <p>Here is the error when I put a message on the Websphere MQ queue to start the process:</p>
  
  <pre><code>&lt;Jun 29, 2010 11:15:15 PM CDT&gt; &lt;Error&gt; &lt;EJB&gt; &lt;BEA-010080&gt; &lt;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
  &gt;
  &lt;Jun 29, 2010 11:15:15 PM CDT&gt; &lt;Warning&gt; &lt;EJB&gt; &lt;BEA-010065&gt; &lt;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
  </code></pre>
  
  <p>Here is how I'm connecting to my database in my code</p>
  
  <pre><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();
  </code></pre>
  
  <p>I've done the following to troubleshoot so far:</p>
  
  <ol>
  <li>I've checked my datasource to confirm that the jndi name is indeed "datasource/oracle-11g</li>
  <li>I have successfully been able to connect to the database via Test Configuration button during datasource setup</li>
  <li>I've validated that the messages table does exist in the db</li>
  </ol>
  
  <p>Is there anyway to turn up logging so I can see any specific JDBC connections errors to the database?</p>