[JBoss JIRA] (WFLY-8731) Unable to inject EJBs into web resources
by Archimedes Trajano (JIRA)
[ https://issues.jboss.org/browse/WFLY-8731?page=com.atlassian.jira.plugin.... ]
Archimedes Trajano reopened WFLY-8731:
--------------------------------------
Do you have a test that shows an EJB in a separate archive would work with the WebArchive? Since the test you've shown me only use a *single web archive*. and no separate EjbArchive.
Re-opening as the unit test shown does not explicitly prove the scenario I am working with.
> Unable to inject EJBs into web resources
> ----------------------------------------
>
> Key: WFLY-8731
> URL: https://issues.jboss.org/browse/WFLY-8731
> Project: WildFly
> Issue Type: Bug
> Components: CDI / Weld, EJB, Web (Undertow)
> Affects Versions: 10.0.0.Final
> Environment: WildFly 10.0 on Windows 10
> Reporter: Archimedes Trajano
> Assignee: Stuart Douglas
>
> There's an old bug on https://issues.jboss.org/browse/JBAS-8818 that talks about this issue on JBoss, but it still applies on WildFly up until now.
> Their comment was based on just WebListener, but I found it applied to the following as well
> * WebServlet
> * WebService (code first and contract first)
> * JAX-RS paths.
> One other thing to note, converting to @EJB from @Inject created another problem, but I'd rather get @Inject working first.
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
9 years
[JBoss JIRA] (WFLY-8731) Unable to inject EJBs into web resources
by Stuart Douglas (JIRA)
[ https://issues.jboss.org/browse/WFLY-8731?page=com.atlassian.jira.plugin.... ]
Stuart Douglas commented on WFLY-8731:
--------------------------------------
If the object was not an EJB then then test would fail, as @AccessTimeout(0) would have no effect
> Unable to inject EJBs into web resources
> ----------------------------------------
>
> Key: WFLY-8731
> URL: https://issues.jboss.org/browse/WFLY-8731
> Project: WildFly
> Issue Type: Bug
> Components: CDI / Weld, EJB, Web (Undertow)
> Affects Versions: 10.0.0.Final
> Environment: WildFly 10.0 on Windows 10
> Reporter: Archimedes Trajano
> Assignee: Stuart Douglas
>
> There's an old bug on https://issues.jboss.org/browse/JBAS-8818 that talks about this issue on JBoss, but it still applies on WildFly up until now.
> Their comment was based on just WebListener, but I found it applied to the following as well
> * WebServlet
> * WebService (code first and contract first)
> * JAX-RS paths.
> One other thing to note, converting to @EJB from @Inject created another problem, but I'd rather get @Inject working first.
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
9 years
[JBoss JIRA] (WFLY-8731) Unable to inject EJBs into web resources
by Archimedes Trajano (JIRA)
[ https://issues.jboss.org/browse/WFLY-8731?page=com.atlassian.jira.plugin.... ]
Archimedes Trajano commented on WFLY-8731:
------------------------------------------
Also looking at your unit test, can you verify that the SimpleStatefulSessionBean that was injected in https://github.com/wildfly/wildfly/blob/master/testsuite/integration/basi... is actually an EJB and not a "normal class" that just got injected because they are being put in the same class loader.
I see no assertion on the unit test stating that.
In my example with the DAO I explicitly separated the implementation from the interface to force it to have the EJB class running in a separate class loader.
> Unable to inject EJBs into web resources
> ----------------------------------------
>
> Key: WFLY-8731
> URL: https://issues.jboss.org/browse/WFLY-8731
> Project: WildFly
> Issue Type: Bug
> Components: CDI / Weld, EJB, Web (Undertow)
> Affects Versions: 10.0.0.Final
> Environment: WildFly 10.0 on Windows 10
> Reporter: Archimedes Trajano
> Assignee: Stuart Douglas
>
> There's an old bug on https://issues.jboss.org/browse/JBAS-8818 that talks about this issue on JBoss, but it still applies on WildFly up until now.
> Their comment was based on just WebListener, but I found it applied to the following as well
> * WebServlet
> * WebService (code first and contract first)
> * JAX-RS paths.
> One other thing to note, converting to @EJB from @Inject created another problem, but I'd rather get @Inject working first.
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
9 years
[JBoss JIRA] (WFLY-8731) Unable to inject EJBs into web resources
by Archimedes Trajano (JIRA)
[ https://issues.jboss.org/browse/WFLY-8731?page=com.atlassian.jira.plugin.... ]
Archimedes Trajano commented on WFLY-8731:
------------------------------------------
This part "Changed the data source to the default datasource" I think is another bug I had noticed where I couldn't change the resource to a mapped resource correctly. For now I'll accept such a change.
For *Removed the <security-constraint> from web.xml (as no login method was configured) * JASPIC is used as per the spec I am allowed to put in a custom JASPIC provider on the application level which is done here https://github.com/trajano/jee/blob/for-JBAS-8818/jee-web/src/main/java/n...
Since you had removed the security constraint and JASPIC then there will be no credentials going down to the EJB tier.
> Unable to inject EJBs into web resources
> ----------------------------------------
>
> Key: WFLY-8731
> URL: https://issues.jboss.org/browse/WFLY-8731
> Project: WildFly
> Issue Type: Bug
> Components: CDI / Weld, EJB, Web (Undertow)
> Affects Versions: 10.0.0.Final
> Environment: WildFly 10.0 on Windows 10
> Reporter: Archimedes Trajano
> Assignee: Stuart Douglas
>
> There's an old bug on https://issues.jboss.org/browse/JBAS-8818 that talks about this issue on JBoss, but it still applies on WildFly up until now.
> Their comment was based on just WebListener, but I found it applied to the following as well
> * WebServlet
> * WebService (code first and contract first)
> * JAX-RS paths.
> One other thing to note, converting to @EJB from @Inject created another problem, but I'd rather get @Inject working first.
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
9 years
[JBoss JIRA] (WFLY-8731) Unable to inject EJBs into web resources
by Stuart Douglas (JIRA)
[ https://issues.jboss.org/browse/WFLY-8731?page=com.atlassian.jira.plugin.... ]
Stuart Douglas resolved WFLY-8731.
----------------------------------
Resolution: Cannot Reproduce Bug
Closing as, injection happens just fine in the provided reproducer. This is also tested in the test suite, for example org.jboss.as.test.integration.weld.ejb.SessionObjectReferenceTestCase
> Unable to inject EJBs into web resources
> ----------------------------------------
>
> Key: WFLY-8731
> URL: https://issues.jboss.org/browse/WFLY-8731
> Project: WildFly
> Issue Type: Bug
> Components: CDI / Weld, EJB, Web (Undertow)
> Affects Versions: 10.0.0.Final
> Environment: WildFly 10.0 on Windows 10
> Reporter: Archimedes Trajano
> Assignee: Stuart Douglas
>
> There's an old bug on https://issues.jboss.org/browse/JBAS-8818 that talks about this issue on JBoss, but it still applies on WildFly up until now.
> Their comment was based on just WebListener, but I found it applied to the following as well
> * WebServlet
> * WebService (code first and contract first)
> * JAX-RS paths.
> One other thing to note, converting to @EJB from @Inject created another problem, but I'd rather get @Inject working first.
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
9 years
[JBoss JIRA] (WFLY-8731) Unable to inject EJBs into web resources
by Stuart Douglas (JIRA)
[ https://issues.jboss.org/browse/WFLY-8731?page=com.atlassian.jira.plugin.... ]
Stuart Douglas commented on WFLY-8731:
--------------------------------------
So I made the following changes to your reproducer to get it to run:
- Changed the data source to the default datasource
- Changed the persistence.xml to use hbm2ddl to generate the tables
- Removed the @Resource injection from BaseEntityListener
- Removed the <security-constraint> from web.xml (as no login method was configured)
- changed req.getUserPrincipal().getName() to just req.getUserPrincipal() to avoid a NPE
After making all these changes I see the following:
javax.ejb.EJBAccessException: WFLYEJB0364: Invocation on method: public abstract net.trajano.jee.domain.entity.User net.trajano.jee.domain.dao.UserDAO.getByUsername(java.lang.String) of bean: DefaultUserDAO is not allowed
which means that the EJB has been injected, however you need to either add @PermitAll or change the EJB subsystem config to permit all by default.
> Unable to inject EJBs into web resources
> ----------------------------------------
>
> Key: WFLY-8731
> URL: https://issues.jboss.org/browse/WFLY-8731
> Project: WildFly
> Issue Type: Bug
> Components: CDI / Weld, EJB, Web (Undertow)
> Affects Versions: 10.0.0.Final
> Environment: WildFly 10.0 on Windows 10
> Reporter: Archimedes Trajano
> Assignee: Stuart Douglas
>
> There's an old bug on https://issues.jboss.org/browse/JBAS-8818 that talks about this issue on JBoss, but it still applies on WildFly up until now.
> Their comment was based on just WebListener, but I found it applied to the following as well
> * WebServlet
> * WebService (code first and contract first)
> * JAX-RS paths.
> One other thing to note, converting to @EJB from @Inject created another problem, but I'd rather get @Inject working first.
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
9 years
[JBoss JIRA] (WFLY-8731) Unable to inject EJBs into web resources
by Archimedes Trajano (JIRA)
[ https://issues.jboss.org/browse/WFLY-8731?page=com.atlassian.jira.plugin.... ]
Archimedes Trajano commented on WFLY-8731:
------------------------------------------
So it is an EntityListener which I had marked as @ApplicationScoped since there is going to be only one instance of that. Is the claim right now that in order to fix this issue we need to define JPA Entity Listeners as @Stateless EJBs?
> Unable to inject EJBs into web resources
> ----------------------------------------
>
> Key: WFLY-8731
> URL: https://issues.jboss.org/browse/WFLY-8731
> Project: WildFly
> Issue Type: Bug
> Components: CDI / Weld, EJB, Web (Undertow)
> Affects Versions: 10.0.0.Final
> Environment: WildFly 10.0 on Windows 10
> Reporter: Archimedes Trajano
> Assignee: Stuart Douglas
>
> There's an old bug on https://issues.jboss.org/browse/JBAS-8818 that talks about this issue on JBoss, but it still applies on WildFly up until now.
> Their comment was based on just WebListener, but I found it applied to the following as well
> * WebServlet
> * WebService (code first and contract first)
> * JAX-RS paths.
> One other thing to note, converting to @EJB from @Inject created another problem, but I'd rather get @Inject working first.
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
9 years
[JBoss JIRA] (WFLY-8731) Unable to inject EJBs into web resources
by Stuart Douglas (JIRA)
[ https://issues.jboss.org/browse/WFLY-8731?page=com.atlassian.jira.plugin.... ]
Stuart Douglas commented on WFLY-8731:
--------------------------------------
It is in jee-domain-api/src/main/java/net/trajano/jee/domain/entity/BaseEntityListener.java
> Unable to inject EJBs into web resources
> ----------------------------------------
>
> Key: WFLY-8731
> URL: https://issues.jboss.org/browse/WFLY-8731
> Project: WildFly
> Issue Type: Bug
> Components: CDI / Weld, EJB, Web (Undertow)
> Affects Versions: 10.0.0.Final
> Environment: WildFly 10.0 on Windows 10
> Reporter: Archimedes Trajano
> Assignee: Stuart Douglas
>
> There's an old bug on https://issues.jboss.org/browse/JBAS-8818 that talks about this issue on JBoss, but it still applies on WildFly up until now.
> Their comment was based on just WebListener, but I found it applied to the following as well
> * WebServlet
> * WebService (code first and contract first)
> * JAX-RS paths.
> One other thing to note, converting to @EJB from @Inject created another problem, but I'd rather get @Inject working first.
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
9 years
[JBoss JIRA] (WFLY-8731) Unable to inject EJBs into web resources
by Archimedes Trajano (JIRA)
[ https://issues.jboss.org/browse/WFLY-8731?page=com.atlassian.jira.plugin.... ]
Archimedes Trajano commented on WFLY-8731:
------------------------------------------
Ok, and from the stack trace it seems to be an issue with Weld trying to get the EJBContext somewhere. However, no part of the stack trace you have shown me says which component / class that I would've written was involved.
> Unable to inject EJBs into web resources
> ----------------------------------------
>
> Key: WFLY-8731
> URL: https://issues.jboss.org/browse/WFLY-8731
> Project: WildFly
> Issue Type: Bug
> Components: CDI / Weld, EJB, Web (Undertow)
> Affects Versions: 10.0.0.Final
> Environment: WildFly 10.0 on Windows 10
> Reporter: Archimedes Trajano
> Assignee: Stuart Douglas
>
> There's an old bug on https://issues.jboss.org/browse/JBAS-8818 that talks about this issue on JBoss, but it still applies on WildFly up until now.
> Their comment was based on just WebListener, but I found it applied to the following as well
> * WebServlet
> * WebService (code first and contract first)
> * JAX-RS paths.
> One other thing to note, converting to @EJB from @Inject created another problem, but I'd rather get @Inject working first.
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
9 years
[JBoss JIRA] (WFLY-8731) Unable to inject EJBs into web resources
by Stuart Douglas (JIRA)
[ https://issues.jboss.org/browse/WFLY-8731?page=com.atlassian.jira.plugin.... ]
Stuart Douglas commented on WFLY-8731:
--------------------------------------
When I attempt to deploy your reproducer I see:
Caused by: javax.naming.NameNotFoundException: java:comp/EJBContext
at org.jboss.as.naming.InitialContext$DefaultInitialContext.findContext(InitialContext.java:191)
at org.jboss.as.naming.InitialContext$DefaultInitialContext.lookup(InitialContext.java:235)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:193)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:189)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
at org.jboss.as.weld.services.bootstrap.WeldResourceInjectionServices.resolveResource(WeldResourceInjectionServices.java:223)
... 40 more
> Unable to inject EJBs into web resources
> ----------------------------------------
>
> Key: WFLY-8731
> URL: https://issues.jboss.org/browse/WFLY-8731
> Project: WildFly
> Issue Type: Bug
> Components: CDI / Weld, EJB, Web (Undertow)
> Affects Versions: 10.0.0.Final
> Environment: WildFly 10.0 on Windows 10
> Reporter: Archimedes Trajano
> Assignee: Stuart Douglas
>
> There's an old bug on https://issues.jboss.org/browse/JBAS-8818 that talks about this issue on JBoss, but it still applies on WildFly up until now.
> Their comment was based on just WebListener, but I found it applied to the following as well
> * WebServlet
> * WebService (code first and contract first)
> * JAX-RS paths.
> One other thing to note, converting to @EJB from @Inject created another problem, but I'd rather get @Inject working first.
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
9 years