1

我是第一次使用 EJB 和 JSF,但我无法解决这个问题:

     20:23:12,457 Grave [javax.enterprise.resource.webcontainer.jsf.application] (http-localhost-127.0.0.1-8081-2) com.ericsantanna.jobFC.dao.DAOFactoryRemote from [Module "com.sun.jsf-impl:main" from local module loader @439db2b2 (roots: C:\jboss-as-7.1.1.Final\modules)]: java.lang.ClassNotFoundException: com.ericsantanna.jobFC.dao.DAOFactoryRemote from [Module "com.sun.jsf-impl:main" from local module loader @439db2b2 (roots: C:\jboss-as-7.1.1.Final\modules)]

当我执行 selectOneMenu 或 commandButton click 之类的操作时,我得到了这个。

DAOFactory.class

@Singleton
@Remote(DAOFactoryRemote.class)
public class DAOFactory implements DAOFactoryRemote {

private static final long serialVersionUID = 6030538139815885895L;

@PersistenceContext
private EntityManager entityManager;

@EJB
private JobDAORemote jobDAORemote;

/**
 * Default constructor. 
 */
public DAOFactory() {
    // TODO Auto-generated constructor stub
}

@Override
public JobDAORemote getJobDAO() {
    JobDAO jobDAO = (JobDAO) jobDAORemote;
    jobDAO.setEntityManager(entityManager);

    return jobDAO;
}

JobDAO.class

@Stateless
@Remote(JobDAORemote.class)
public class JobDAO implements JobDAORemote {

private static final long serialVersionUID = -5483992924812255349L;

private EntityManager entityManager;

/**
 * Default constructor. 
 */
public JobDAO() {
    // TODO Auto-generated constructor stub
}

@Override
public void insert(Job t) {
    entityManager.persist(t);
}

@Override
public Job findById(Class<Job> classe, Long id) {
    return entityManager.getReference(classe, id);
}

@Override
public Job findByName(Class<Job> clazz, String name) {
    return entityManager
            .createQuery("SELECT job FROM " + clazz.getName() + " job WHERE job.nome = :nome"
                , Job.class)
            .setParameter("name", name)
            .getSingleResult();
}
...

TriggerFormBean.class

@ManagedBean
@ViewScoped
@Stateless
public class TriggerFormBean implements Serializable    {

private static final long serialVersionUID = -3293560384606586480L;

@EJB
private DAOFactoryRemote daoFactory;

@EJB
private TriggerManagerRemote triggerManagerRemote;
...

triggerForm.xhtml(有问题的部分)

                            </p:layoutUnit>
                            <p:layoutUnit id="eastConditionPanel" position="center" size="50%">
                                <p:panel header="Conditions to Release"  style="width:97%;height:97%;">
                                    <h:panelGrid columns="2" cellpadding="3">
                                        <h:outputLabel value="Condition Name:" for="conditionName" />
                                        <p:inputText id="conditionName" value="#{triggerFormBean.newCondition.name}" />
                                    </h:panelGrid>

                                    <p:commandButton value="Add Condition" update="conditionsToReleaseList" id="addConditionToRelease"  
                                        actionListener="#{triggerFormBean.addNewCondition}" />

                                    <p:orderList 
                                            id="conditionsToReleaseList" 
                                            value="#{triggerFormBean.trigger.conditionsToRelease}" 
                                            var="condition" 
                                            controlsLocation="none"  
                                            itemLabel="#{condition.name}" 
                                            itemValue="#{condition}" 
                                            iconOnly="true"
                                            style="width:97%;heigth:97%;"/>
                                  </p:panel>
                        </p:layoutUnit>

在 TriggerFormBean.class 中,如果注释 daoFactory 我们得到与 triggerManagerRemote 相同的异常,两者都使用 @EJB 注释。

我不明白我的 DAOFactory 和“模块 com.sun.jsf-impl:main”之间的关系......

当我单击 commandButton 时发生异常,它仅从 inputText 获取文本,设置为 Condition 实例并添加到由 orderList 映射的 ArrayList。

设置:JBoss 7.1,Primefaces 3.4

谢谢。

4

1 回答 1

0

我实际上也有同样的麻烦。奇怪地降级 JBoss 中的模块为我解决了这个问题:

<module xmlns="urn:jboss:module:1.1" name="javax.faces.api">
<dependencies>
    <module name="javax.el.api" export="true"/>
    <module name="javax.servlet.api" export="true"/>
    <module name="javax.servlet.jsp.api" export="true"/>
    <module name="javax.servlet.jstl.api" export="true"/>
    <module name="javax.validation.api" export="true"/>
</dependencies>

<resources>
    <resource-root path="jboss-jsf-api_2.1_spec-2.0.1.Final.jar"/>
    <!-- Insert resources here -->
</resources>

代替 :

<module xmlns="urn:jboss:module:1.1" name="javax.faces.api">
<dependencies>
    <module name="javax.el.api" export="true"/>
    <module name="javax.servlet.api" export="true"/>
    <module name="javax.servlet.jsp.api" export="true"/>
    <module name="javax.servlet.jstl.api" export="true"/>
    <module name="javax.validation.api" export="true"/>
</dependencies>

<resources>
    <resource-root path="jboss-jsf-api_2.1_spec-2.1.21.Final.jar"/>
    <!-- Insert resources here -->
</resources>

不同之处在于使用的版本。我无法解释为什么。

希望这可以帮助

于 2013-06-10T09:15:38.577 回答