EJB / JSF java.lang.ClassNotFoundException:来自本地模块加载器的[Module“com.sun.jsf-impl:main”的com.ericsantanna.jobFC.dao.DAOFactoryRemote

时间:2012-11-22 22:57:56

标签: java jsf-2 primefaces dao ejb-3.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点击等操作时,我得到了这个。

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和“Module com.sun.jsf-impl:main”之间的关系......

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

设置:JBoss 7.1,Primefaces 3.4

感谢。

1 个答案:

答案 0 :(得分: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>

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

希望这有帮助