[ 
https://issues.apache.org/jira/browse/TOMEE-4715?focusedWorklogId=1044449&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1044449
 ]

ASF GitHub Bot logged work on TOMEE-4715:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 28/Sep/26 18:40
            Start Date: 28/Sep/26 18:40
    Worklog Time Spent: 10m 
      Work Description: rzo1 merged PR #2959:
URL: https://github.com/apache/tomee/pull/2959




Issue Time Tracking
-------------------

    Worklog Id:     (was: 1044449)
    Time Spent: 0.5h  (was: 20m)

> TomEE embedded application runner does not inject @Resource into the 
> @Application descriptor
> --------------------------------------------------------------------------------------------
>
>                 Key: TOMEE-4715
>                 URL: https://issues.apache.org/jira/browse/TOMEE-4715
>             Project: TomEE
>          Issue Type: Bug
>            Reporter: Richard Zowalla
>            Priority: Major
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> Fields annotated with {{@Resource}} in the {{@Application}} descriptor class 
> are not injected if the application is started via 
> {{TomEEEmbeddedApplicationRunner}} \({{@RunWithTomEEEmbedded}}, 
> {{TomEEEmbeddedSingleRunner}}\).
> {code:java}
> @Application
> @Classes\(cdi = true, context = "app"\)
> public class TheApp {{code}
> @Resource
> private DataSource dataSource; // stays null
> @Configuration
> public Properties config() {
>     final Properties p = new Properties();
>     p.put("db", "new://Resource?type=DataSource");
>     p.put("db.JdbcDriver", "org.hsqldb.jdbcDriver");
>     p.put("db.JdbcUrl", "jdbc:hsqldb:mem:test");
>     return p;
> }
> {code}
> }
> {code}
> h3. Cause
> {{TomEEEmbeddedApplicationRunner#composerInject\(...\)}} only uses 
> {{OWBInjector}} and handles the runner specific annotations 
> \({{@RandomPort}}, {{@Application}}, {{@LifecycleTask}}, {{@Args}}\). Jakarta 
> EE resource injection is not processed for the descriptor or test instance.
> h3. Expected behaviour
> The same descriptor works with {{ApplicationComposer}} 
> \({{@RunWithApplicationComposer}}\), where {{@Resource}} is injected. As 
> TOMEE\-4707 removes the embedded HTTP server, tests using 
> {{@EnableServices\("jaxrs"\)}} need to move to TomEE embedded, so both 
> runners should behave the same here.
> h3. Workaround
> Look up the resource via the container JNDI context:
> {code:java}
> SystemInstance.get\(\).getComponent\(ContainerSystem.class\).getJNDIContext\(\).lookup\("openejb/Resource/db"\);
> {code}
> Seen with 11.0.0\-SNAPSHOT.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to