user3114376
user3114376

Reputation: 61

JSF 2 Injection problem thus application will not deploy to Glassfish server

I am injecting a List<Reception> to a ReceptionService class but all i get is an error and the project won't deploy: The error i get is:

Unsatisfied dependencies for type List<Reception> with qualifiers @Default
  at injection point [BackedAnnotatedField] @Inject com.github.adminfaces.starter.service.ReceptionService.selectedPatients
  at com.github.adminfaces.starter.service.ReceptionService.selectedPatients(ReceptionService.java:0)

I have set bean-discovery-mode="all" to beans.xml already

The PatientList Class where List<Reception> selectedPatients has its getter and setter methods

import com.github.adminfaces.starter.model.Reception;
import com.github.adminfaces.starter.service.ReceptionService;
import org.omnifaces.cdi.ViewScoped;

import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.Serializable;
import java.util.List;
import java.util.Map;

@Named
@ViewScoped
public class PatientListMB implements Serializable {


    @Inject
    ReceptionService receptionService;

    Integer id;

    LazyDataModel<Reception> patients;

    Filter<Reception> filter = new Filter<>(new Reception());

    List<Reception> selectedPatients; //patients selected in checkbox column

    List<Reception> filteredValue;// datatable filteredValue attribute (column filters)

The ReceptionService class where i am injecting List<Reception> selectedPatients

package com.github.adminfaces.starter.service;

import com.github.adminfaces.starter.infra.model.Filter;
import com.github.adminfaces.starter.infra.model.SortOrder;
import com.github.adminfaces.starter.model.Reception;
import com.github.adminfaces.template.exception.BusinessException;

import javax.ejb.Stateless;
import javax.inject.Inject;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import static com.github.adminfaces.template.util.Assert.has;

/**
 * @author rmpestano
 *         Reception Business logic
 */
@Stateless
public class ReceptionService implements Serializable {

    @Inject
    List<Reception> selectedPatients;

Upvotes: 0

Views: 126

Answers (1)

rmpestano
rmpestano

Reputation: 888

I suppose you're using admin-starter as reference project, if you look at the code you'll see there is a producer method in Utils.java which is responsible for creating the list of cars.

Bringing it to your project you just need to create a producer method which returns a list o List or instead of using Injection you can simple remove the @Inject and instantiate the list and add the objects manually.

Upvotes: 1

Related Questions