Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>Consrtutor Injection</h2> <p>When CDI container instantiate a bean class then it call the bean constructor of CDI bean.</p> <p>CDI looks for the either default bean constructor or annotated with @Inject to get the the instance of bean.</p> <ul> <li>No parameter/default bean constructor will accepted by CDI container if CDI bean doesn't explicitly declare a constructor using @Inject.</li> <li>CDI bean constructor may have any number of parameters and container initialize/inject all those<br> paramters which are injection point for the bean constructor.</li> <li>CDI bean class can only have single constructor annotated with @Inject. If CDI container finds multiple constructor annotated with @Inject then it throws error.</li> </ul> <blockquote> <p>There is one advantage of bean constructor injection it allows the bean to be immutable.</p> </blockquote> <p>The Problem in your case is </p> <p>IncidentContainer bean class does not have any default constructor or a constructor annotated with @Injection.</p> <p>You can set as following</p> <pre><code>public class IncidentContainer extends JPAContainer&lt;Incident&gt; { // @Inject no need to do filed injection here private EntityProviderBean&lt;Incident&gt; provider; @Inject // add this one public IncidentContainer(EntityProviderBean&lt;Incident&gt; provider) { super(Incident.class); this.provider = provider; } @PostConstruct protected void init() { setEntityProvider(provider); } } </code></pre> <p>EntityProviderBean bean class does not have any default constructor or a constructor annotated with @Injection.</p> <p>You can set as following</p> <pre><code>public class EntityProviderBean&lt;T&gt; extends CachingMutableLocalEntityProvider&lt;T&gt; { public EntityProviderBean(Class&lt;T&gt; entityClass) { super(entityClass); setTransactionsHandledByProvider(false); } // add this cdi bean construtor @Inject public EntityProviderBean(Incident incident) { this((Class&lt;T&gt;) incident.getClass()); } protected void runInTransaction(String operation) { super.runInTransaction(operation); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload