我是第一次使用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单击之类的操作时,就会得到此提示。

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

谢谢。

最佳答案

我实际上也遇到了同样的麻烦。
奇怪地降级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>




区别在于所使用的版本。
我无法解释为什么。

希望这可以帮助

10-02 04:41