WELD-001409类型[SeamT​​ransaction]的模糊依赖关系

时间:2015-07-07 23:04:43

标签: ejb cdi seam jboss-eap-6 weld

我有以下例外:

9:12:29,190 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-10) MSC000001: Failed to start service jboss.deployment.unit."SisneGym-ear.ear".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."SisneGym-ear.ear".WeldStartService: Failed to start service
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1936) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_67]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_67]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_67]
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001409 Ambiguous dependencies for type [SeamTransaction] with qualifiers [@DefaultTransaction] at injection point [[field] @Inject @DefaultTransaction private org.jboss.seam.faces.transaction.TransactionPhaseListener.transaction]. Possible dependencies [[Managed Bean [class org.jboss.seam.transaction.HibernateTransaction] with qualifiers [@Any @DefaultTransaction], Managed Bean [class org.jboss.seam.transaction.EntityTransaction] with qualifiers [@Any @DefaultTransaction], Managed Bean [class org.jboss.seam.transaction.DefaultSeamTransaction] with qualifiers [@Any @DefaultTransaction]]]
    at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:318)
    at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:284)
    at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:147)
    at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:167)
    at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:386)
    at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:371)
    at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:379)
    at org.jboss.as.weld.WeldStartService.start(WeldStartService.java:64)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1980) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1913) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
    ... 3 more

19:12:29,228 INFO  [org.jboss.as.server] (Controller Boot Thread) JBAS018559: Implementado "postgresql-9.3-1103.jdbc4.jar" (runtime-name : "postgresql-9.3-1103.jdbc4.jar")
19:12:29,228 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 26) JBAS018559: Implementado "SisneGym-ear.ear" (runtime-name : "SisneGym-ear.ear")
19:12:29,230 INFO  [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Reporte del estatus del servicio
JBAS014777: Servicios que no lograron iniciar:      service jboss.deployment.unit."SisneGym-ear.ear".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."SisneGym-ear.ear".WeldStartService: Failed to start service

我在JBoss EAP 6.3.3.GA上使用EJB 3.1,JPA 2.0 proyect的结构是:

PrincipalProyect (pom) 
    Proyect-Api(jar)
    Proyect-EJB(jar)
    Proyect-Web(war)

1 .-

通用图书馆代码在这里:

@Named
@Dependent
public abstract class GenericDAOImpl<E, ID extends Serializable, F> implements GenericDAO<E, ID, F> {

private final Class<E> persistentClass;

protected EntityManager entityManager;

protected CriteriaBuilder cb;

protected GenericDAOImpl(Class<E> persistentClass) {
    this.persistentClass = persistentClass;
}

public Class<E> getPersistentClass() {
    return persistentClass;
}

public EntityManager getEntityManager() {
    return entityManager;
}

public CriteriaBuilder getCb() {
    return cb;
}

public E save(E entity) {
    entityManager.persist(entity);
    entityManager.flush();

    return entity;
}

public E update(E entity) {
    entityManager.merge(entity);
    entityManager.flush();

    return entity;
}

public void remove(E entity) {
    entityManager.remove(entityManager.merge(entity));
    entityManager.flush();
}

public E findById(ID id) {
    return entityManager.find(persistentClass, id);
}

@SuppressWarnings("unchecked")
public List<E> findAll() {
    return entityManager.createQuery(
            "select e from " + persistentClass.getName() + " e")
            .getResultList();
}

public List<E> findByCriteria(F filter) {       
    if (filter != null) {
        CriteriaQuery<E> criteria = this.getQuery(filter);
        TypedQuery<E> query = entityManager.createQuery(criteria);

        return query.getResultList();
    } else {
        return this.findAll();
    }
}

public List<E> findByCriteriaPagination(F filter, int first, int pageSize) {
    TypedQuery<E> query = null;

    if (filter != null) {
        CriteriaQuery<E> criteria = this.getQuery(filter);
        query = entityManager.createQuery(criteria);            
    } else {
        query = entityManager.createQuery(
            "select e from " + persistentClass.getName() + " e", persistentClass);
    }

    if (pageSize >= 0) {
        query.setMaxResults(pageSize);
    }

    if (first >= 0) {
        query.setFirstResult(first);
    }

    return query.getResultList();
}

public Long count() {
    return (Long) entityManager.createQuery(
            "select count(e) from " + persistentClass.getName() + " e")
            .getSingleResult();
}

public Long countWithFilter(F filter) {
    CriteriaQuery<Long> cq = this.cb.createQuery(Long.class);
    Root<E> root = cq.from(persistentClass);

    GenericQuery query = this.getConditions(filter, cq, root);

    cq.select(this.cb.count(root));

    if (query.getConditions() != null) cq.where(query.getConditions());

    return entityManager.createQuery(cq).getSingleResult();
}

protected abstract <T> GenericQuery getConditions(F filter, CriteriaQuery<T> cq, Root<E> root);

private CriteriaQuery<E> getQuery(F filter) {
    CriteriaQuery<E> cq = this.cb.createQuery(persistentClass);
    Root<E> root = cq.from(persistentClass);
    cq.select(root);

    GenericQuery query = this.getConditions(filter, cq, root);

    if (query.getConditions() != null)
        cq.where(query.getConditions());

    if (query.getOrderBy() != null)
        if (query.getOrderBy().size() > 0)
            cq.orderBy(query.getOrderBy());

    return cq;
}

protected abstract CriteriaQuery<E> createFilter(F filter);
}

2 .-

public interface GenericDAO<E, ID extends Serializable, F> {

public E save(E entity);

public E update(E entity);

public void remove(E entity);

public E findById(ID id);

public List<E> findAll();

public List<E> findByCriteria(F filter);

public List<E> findByCriteriaPagination(F filter, int first, int pageSize);

public Long count();

public Long countWithFilter(F filter);

}  

3 .-

public interface ClienteDAO extends GenericDAO<Cliente, Long, FiltroCliente> {

public Cliente allocateLockerToClient(Cliente client, Casillero locker) throws SisneGymPersistenceException;
public ReservaEvaluacionFisica reservePhysicalEvaluation(ReservaEvaluacionFisica reserve)throws SisneGymPersistenceException;

}

4 .-

@Stateless
public abstract class BaseDAOImpl<E, ID extends Serializable, F> extends  GenericDAOImpl<E, ID, F> {

@PersistenceContext(name = "SisneGym-pu")
private EntityManager em;

protected BaseDAOImpl(Class<E> persistentClass) {
    super(persistentClass);
}

@Produces
public EntityManager getEntityManager() {
    return em;
}

@PostConstruct
void configuration() {
    super.entityManager = this.em;
}
}

5 .-

@Stateless
@DaoServiceType
public class ClienteDAOImpl extends BaseDAOImpl<Cliente, Long, FiltroCliente> implements ClienteDAO {


@Override
public Cliente allocateLockerToClient(Cliente client, Casillero locker)
        throws SisneGymPersistenceException {
    // TODO Auto-generated method stub
    return null;
}

@Override
public ReservaEvaluacionFisica reservePhysicalEvaluation(
        ReservaEvaluacionFisica reserve)
        throws SisneGymPersistenceException {
    // TODO Auto-generated method stub
    return null;
}

public ClienteDAOImpl() {
    super(Cliente.class);
}

@Override
protected <T> GenericQuery getConditions(FiltroCliente filter,
        CriteriaQuery<T> cq, Root<Cliente> root) {
    return null;
}

@Override
protected CriteriaQuery<Cliente> createFilter(FiltroCliente filter) {
    return null;
}
}

6 .-

@Qualifier
@Target({ TYPE, METHOD, PARAMETER, FIELD })
@Retention(RUNTIME)
@Documented
public @interface DaoServiceType {

}

在EJB上注入DAO对象

7.-

@Stateless(name = "evaluacionSessionBean")
@Named(value = "evaluacionService")
public class EvaluacionSessionBeanImpl implements EvaluacionSessionLocal,  EvaluacionSessionRemote {


@Inject   
private Logger log; 

@Inject
@DaoServiceType
ClienteDAO clienteDAO;

public EvaluacionSessionBeanImpl(){
    super();
}

@Override
public void createFichaEvaluacion(FichaEvaluacion fichaEvaluacion) {
    log.info("lalla");
    try {
        clienteDAO.allocateLockerToClient(null, null);
    } catch (SisneGymPersistenceException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    //fichaEvaluacionFisicaDAO.save(fichaEvaluacion);
}

@Override
public void updateFichaEvaluacion(FichaEvaluacion fichaEvaluacion) {

}

....

请知道解决问题? 非常感谢

卡洛斯

1 个答案:

答案 0 :(得分:1)

您应该从项目中删除所有Seam依赖项。 Seam 3在将近3年前停止使用Apache DeltaSpike

Seam中的大多数功能现在都在Deltaspike