我有一个这样的无状态本地 Bean:
@Stateless(name="GerencialFacadeBean", mappedName="GerencialFacade")
public class GerencialFacadeBean implements GerencialFacadeBeanLocal {
@Resource(name="jdbc/adq_sistint", mappedName = "jdbc/adq_sistint")
private DataSource dataSource;
.. }
所以,当我使用这个bean时,我得到了以下异常:
Caused by: com.bea.core.repackaged.springframework.beans.factory.BeanCreationException: Dependency injection failure: can't find the bean definition about class 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; owner=com.bea.core.repackaged.springframework.context.support.GenericApplicationContext@5d225fc1: display name [com.bea.core.repackaged.springframework.context.support.GenericApplicationContext@5d225fc1]; startup date [Mon Oct 15 16:30:12 BRT 2012]; parent: com.bea.core.repackaged.springframework.context.support.GenericApplicationContext@885e019
at com.oracle.pitchfork.inject.Jsr250Metadata.applyInjections(Jsr250Metadata.java:241)
at com.oracle.pitchfork.inject.Jsr250Metadata.inject(Jsr250Metadata.java:223)
at com.oracle.pitchfork.inject.Jsr250Metadata.injectAndPostConstruct(Jsr250Metadata.java:253)
at com.oracle.pitchfork.inject.Jsr250MetadataBeanPostProcessor.postProcessAfterInstantiation(Jsr250MetadataBeanPostProcessor.java:40)
at com.bea.core.repackaged.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:957)
at com.bea.core.repackaged.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:470)
... 66 more
Caused by: 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.springframework.context.support.GenericApplicationContext@5d225fc1: display name [com.bea.core.repackaged.springframework.context.support.GenericApplicationContext@5d225fc1]; startup date [Mon Oct 15 16:30:12 BRT 2012]; parent: com.bea.core.repackaged.springframework.context.support.GenericApplicationContext@885e019
at com.oracle.pitchfork.inject.Jsr250Metadata.getUniqueInstanceOfType(Jsr250Metadata.java:304)
at com.oracle.pitchfork.inject.Jsr250Metadata.resolveByType(Jsr250Metadata.java:298)
at com.oracle.pitchfork.inject.Jsr250Metadata.resolve(Jsr250Metadata.java:285)
at com.oracle.pitchfork.inject.Jsr250Metadata.applyInjections(Jsr250Metadata.java:235)
重要的:
我从一个 Web 服务(在同一个 EAR)中使用这个 EJB,比如:
.. class MyWebService.. {
@EJB(name="GerencialFacadeBean", mappedName="GerencialFacade")
private GerencialFacadeBeanLocal gerencialBean;
}
而且,如果我尝试在 Webservice 的类上获取数据源,它会成功运行。
编辑:
另一个考虑因素:使用 REMOTE 接口它可以工作。但我想将它与本地接口一起使用。
我正在使用 Weblogic 10.3.5。我的数据源在其他应用程序(直接通过 JNDI 获取)中创建并运行良好,那么,我得到这个错误是什么?