[jboss-jira] [JBoss JIRA] (AS7-5161) @Resource injection in producer bean
Thomas Diesler (JIRA)
jira-events at lists.jboss.org
Thu Jul 12 04:21:12 EDT 2012
[ https://issues.jboss.org/browse/AS7-5161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12705603#comment-12705603 ]
Thomas Diesler edited comment on AS7-5161 at 7/12/12 4:19 AM:
--------------------------------------------------------------
See https://github.com/tdiesler/jboss-as/tree/as5161
I might want to add that the producer in the test case could also be some other ManagedBean that gets injected into SimpleManagedBean.
was (Author: thomas.diesler):
See https://github.com/tdiesler/jboss-as/tree/as5161
> @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