[jboss-jira] [JBoss JIRA] (AS7-5161) @Resource injection in producer bean

Thomas Diesler (JIRA) jira-events at lists.jboss.org
Thu Jul 12 04:12:12 EDT 2012


Thomas Diesler created AS7-5161:
-----------------------------------

             Summary: @Resource injection in producer bean
                 Key: AS7-5161
                 URL: https://issues.jboss.org/browse/AS7-5161
             Project: Application Server 7
          Issue Type: Bug
          Components: CDI / Weld
            Reporter: Thomas Diesler
            Assignee: Stuart Douglas


Using a simple producer bean like this

{code}
@ManagedBean
public class SimpleProducerBean {

    @Resource(name = "java:jboss/datasources/ExampleDS")
    DataSource dataSource;

    @Produces
    public String getDriverName() {
        try {
            Connection con = dataSource.getConnection();
            try {
                return con.getMetaData().getDriverName();
            } finally {
                con.close();
            }
        } catch (SQLException ex) {
            return ex.toString();
        }
    }
}
{code}

I get 

{code}
10:09:18,782 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/simple]] (http-/127.0.0.1:8080-1) Marking servlet SimpleBeanServlet as unavailable
10:09:18,783 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/simple].[SimpleBeanServlet]] (http-/127.0.0.1:8080-1) Allocate exception for servlet SimpleBeanServlet: javax.naming.NameNotFoundException: env/java:jboss/datasources/ExampleDS -- service jboss.naming.context.java.module.simple.simple.env.java:jboss.datasources.ExampleDS
	at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:97)
	at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:179)
	at org.jboss.as.naming.InitialContext.lookup(InitialContext.java:129)
	at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:215)
	at javax.naming.InitialContext.lookup(InitialContext.java:392) [rt.jar:1.6.0_33]
	at org.jboss.weld.injection.spi.helpers.AbstractResourceServices.resolveResource(AbstractResourceServices.java:47) [weld-spi-1.1.Final.jar:20110112-1536]
{code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list