-
1. Re: @Inject CDI Wildfly 10 with interfaces doesn`t seem to work like it used to in previous versions of JBoss AS7
tremes Aug 4, 2016 1:39 AM (in response to amostech)Hi Arthur,
Well this is really weird. Is that Unsatisfied dependencies really for EntityManager injection point? How do you produce the bean for EntityManager? I don't think changing types of Stateless session bean could cause this failure. Do you have beans.xml file in your app deployment?
-
2. Re: @Inject CDI Wildfly 10 with interfaces doesn`t seem to work like it used to in previous versions of JBoss AS7
amostech Aug 4, 2016 9:51 AM (in response to tremes)Hi Tomas.
Is that Unsatisfied dependencies really for EntityManager injection point?
Nope. The Unsatisfied Dependencies exception is for when I try to @Inject the FriendRequestDaoImpl which is @Stateless.
/**
* JAX-RS Example
* <p/>
* This class produces a RESTful service to read/write the contents of the members table.
*/
@Path("/friends")
@RequestScoped
public class FriendRequestServiceRS {
@Inject
private Logger log;
@Inject
private Validator validator;
@Inject
private FriendRequestDaoImpl friendRequestDaoImpl;
How do you produce the bean for EntityManager?
I dont produce the EntityManager at all. And the exception seems to be related to CDI doesn`t knowing how to instantiate the beans only when it implements the GenericDao interface. This is what is awkward for me. If I don't implement the interface the beans are injected just fine.
And about the presence of beans.xml, yes indeed, I do have it and it is currently like this:
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" bean-discovery-mode="all">
</beans>
-
3. Re: @Inject CDI Wildfly 10 with interfaces doesn`t seem to work like it used to in previous versions of JBoss AS7
tremes Aug 5, 2016 1:57 AM (in response to amostech)1 of 1 people found this helpfulOk so it seems it behaves according to CDI specification. The point is that your FriendRequestDaoImpl implements (in the problematic case) Local interface and therefore in CDI it has only the type of the interface (and all of its superinterfaces). You can check Contexts and Dependency Injection for the Java EE platform. I think when you inject FriendRequestDao it should work.
-
4. Re: @Inject CDI Wildfly 10 with interfaces doesn`t seem to work like it used to in previous versions of JBoss AS7
amostech Dec 2, 2016 1:07 PM (in response to amostech)That is correct! I forgot to come back here and report that this suggestion was correct and it does behave accordingly.
Thank you @Tomas!
-
5. Re: @Inject CDI Wildfly 10 with interfaces doesn`t seem to work like it used to in previous versions of JBoss AS7
gprade Feb 10, 2017 1:38 AM (in response to amostech)I have been struggling with the same issue as reported by you. Could you please point me to the exact solution that you implemented to resolve this issue?
-
6. Re: @Inject CDI Wildfly 10 with interfaces doesn`t seem to work like it used to in previous versions of JBoss AS7
tremes Feb 10, 2017 1:48 AM (in response to gprade)I think it's quite obvious from the above discussion. If you are using EJBs without any bean defining annotation then you will need to use the interface of given EJB (if it has some) as a type for your injection.
-
7. Re: @Inject CDI Wildfly 10 with interfaces doesn`t seem to work like it used to in previous versions of JBoss AS7
gprade Feb 14, 2017 4:58 AM (in response to tremes)I am using CDI injector rather than EJB. Any query to the server of the following implementation class gives the below error.
ApplicationScoped
public class TestImpl implements ITest
{@Inject
private ITestDAO dao;public TestImpl setTestDAO(ITestDAO dao)
{ this.dao = dao; return this; }
@Inject
private TestDescription testDescription;public TestImpl setTestDescription(TestDescription testDescription)
{ this.testDescription = testDescription; return this; }
}
Error Logs:
2017-02-09 13:11:22,256 ERROR [io.undertow.request] (default task-128) UT005023: Exception handling request to( My EndPoint): org.jboss.resteasy.spi.UnhandledException: java.lang.NullPointerException
Caused by: java.lang.NullPointerException
at ServiceRegistryImpl.lookup(ServiceRegistryImpl.java:142)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:139)
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:295)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:249)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:236)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:395)
... 35 more -
8. Re: @Inject CDI Wildfly 10 with interfaces doesn`t seem to work like it used to in previous versions of JBoss AS7
tremes Feb 14, 2017 7:30 AM (in response to gprade)And what is ITestDAO in your case? Anyway this stacktrace doesn't seem to be related. What is "My Endpoint" and does it have any injection points? Some reproducer might be helpful.
-
9. Re: @Inject CDI Wildfly 10 with interfaces doesn`t seem to work like it used to in previous versions of JBoss AS7
gprade Feb 15, 2017 7:21 AM (in response to tremes)My Problem is "CDI injection with wildfly 10 is not working. It was working with jboss 7.I migrated from jboss to wildfly. It gives Null Object. Do i need to change any configuration or any new dependency needs to be added ?"
bean.xml:
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"><!-- Enable ServiceDescriptionDecorator for use with non-JTA datasource -->
<!-- <decorators> -->
<!-- <class>com.xxx.im.jce.serviceregistry.transaction.ServiceDescriptionDecorator</class> -->
<!-- </decorators> -->
<!-- Enable TransactionRequiredInterceptor for use with JTA datasource -->
<interceptors><class>com.xxx.im.jce.serviceregistry.transaction.TransactionRequiredInterceptor</class>
</interceptors>
</beans>
The class uses CDI injection is as below:
@ApplicationScoped
public class ServiceRegistryImpl implements IServiceRegistry
{
private static Logger log = LoggerFactory.getLogger(ServiceRegistryImpl.class);
private static ExceptionMessageContext msgCtx = new ExceptionMessageContext(JceConstants.MESSAGE_CATALOG);
private IServiceDescriptionDAO dao;
@Inject
public ServiceRegistryImpl setServiceDescriptionDAO(IServiceDescriptionDAO dao)
{
this.dao = dao;
return this;
}
private ServiceDescription serviceDescription;
@Inject
public ServiceRegistryImpl setServiceDescription(com.hp.im.jce.serviceregistry.ws.ServiceRegistryDescription serviceDescription)
{
this.serviceDescription = serviceDescription;
return this;
}
@Override
public ServiceDescription getDescription() throws BaseException
{
return serviceDescription;
}
My understanding is that method injector here need to fill the data. it is not happening and values are always null.
Do i need to change any specific configuration for wildfly 10?