English 中文(简体)
发生错误: 在 JNDI: java:/ seam1 实体管理工具中找不到实体管理工具
原标题:An Error Occurred: EntityManagerFactory not found in JNDI : java:/seam1EntityManagerFactory

i m new to jboss and i m gettig this error when i try to list the contacts of the database, I m using the following softwares:
jboss-4.2.3.GA
jboss-seam-2.2.2.Final
PostgreSQL 8.4
Eclipse Helios + JBoss Tools
Here s the Stack Strace(only the first error):

Caused by: javax.naming.NameNotFoundException: seam1EntityManagerFactory not bound
    at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
    at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
    at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
    at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManagerFactoryFromJndiOrValueBinding(ManagedPersistenceContext.java:257)
    ... 117 more

contato_ list. xhtml :

<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich" template="layout/template.xhtml">

    <ui:define name="body">

        <h:messages globalOnly="true" styleClass="message" id="globalMessages" />

        <rich:panel>
            <f:facet name="header">Contatos</f:facet>
            <div class="results" id="contatoList">
                <rich:dataTable id="contatoList" var="_contato" value="#{contatos}">
                    <h:column>
                        <f:facet name="header">Id</f:facet>
                        #{_contato.id}
                    </h:column>
                    <h:column>
                        <f:facet name="header">Nome</f:facet>
                        #{_contato.nome}
                    </h:column>
                    <h:column>
                        <f:facet name="header">Email</f:facet>
                        #{_contato.email}
                    </h:column>
                    <h:column>
                        <f:facet name="header">Ação</f:facet>
                        <s:link id="editar" action="#{contatoAction.editarContato}"
                            value="Editar" />
                        <s:link id="remover" action="#{contatoAction.removerContato}"
                            value="Remover" />
                    </h:column>
                </rich:dataTable>
            </div>
        </rich:panel>
        <s:div styleClass="actionButtons">
            <s:button id="novo" action="#{contatoAction.novoContato}" value="Novo contato"/>
        </s:div>
    </ui:define>
</ui:composition>

孔塔托行动.java:

package org.domain.seam1.session;

import java.io.Serializable;
import java.util.List;
import javax.persistence.EntityManager;
import org.domain.seam1.entity.Contato;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Begin;
import org.jboss.seam.annotations.End;
import org.jboss.seam.annotations.Factory;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.datamodel.DataModel;
import org.jboss.seam.annotations.datamodel.DataModelSelection;

@Name("contatoAction")
@Scope(ScopeType.CONVERSATION)
public class ContatoAction implements Serializable{

    private static final long serialVersionUID = 4121233854017478226L;

    @In
    private EntityManager entityManager;

    @SuppressWarnings("unused")
    @DataModel
    private List<Contato> contatos;

    @DataModelSelection
    @Out(required=false)
    private Contato contato;

    @Factory("contatos")
    @SuppressWarnings("unchecked")
    public void listarContatos() {
        //seleciona todos os contatos
        contatos = entityManager.createQuery("select c from Contato c").getResultList();
    }

    @Begin
    public String novoContato() {
        contato = new Contato();

        return "novoContato";
    }

    @Begin
    public String editarContato() {
        //atualiza os dadis do contato para fazer a edição
        entityManager.refresh(contato);

        return "editarContato";
    }

    public String removerContato() {
        //remove o contato
        entityManager.remove(contato);

        return "contatoRemovido";
    }

    @End
    public String salvarContato() {
        //se não tem id é porque deve ser inserido, caso contrário alterado
        if (contato.getId() == null) {
            entityManager.persist(contato);
        } else {
            entityManager.merge(contato);
        }

        return "contatoSalvo";
    }
}

孔塔托. 贾瓦:

package org.domain.seam1.entity;


import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;


@Entity
public class Contato implements Serializable {

    private static final long serialVersionUID = 4121233854017478226L;

    @Id @GeneratedValue
    private Long id;

    @Column(length=50, nullable=false)
    private String nome;

    @Column(length=50, nullable=false)
    private String email;

    public Long getId() {
        return id;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((email == null) ? 0 : email.hashCode());
        result = prime * result + ((nome == null) ? 0 : nome.hashCode());
        return result;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (!(obj instanceof Contato))
            return false;
        Contato other = (Contato) obj;
        if (email == null) {
            if (other.email != null)
                return false;
        } else if (!email.equals(other.email))
            return false;
        if (nome == null) {
            if (other.nome != null)
                return false;
        } else if (!nome.equals(other.nome))
            return false;
        return true;
    }

}
最佳回答

我的错误通过简单地将蚂蚁罐文件从蚂蚁-2.7.6.jar改为蚂蚁-3.1.1jar而得到解决。

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签