Erro de execução do entityManager. como resolver?

7 respostas
W

Olá galera mais uma vez vim em busca da ajuda de vcs.

estou com um problema com a execução de alguns form. Estou usand o netbeans 6.7.1 com mysql 5.0 e estou usando o assistente para gerar os formulários mais sempre que vou fazer a chamada do form ocorre um erro de excessão dizendo:

“Exception in thread “AWT-EventQueue-0” java.lang.IllegalArgumentException: An exception occured while creating a query in EntityManager
at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl.createQuery(EntityManagerImpl.java:209)”. alguem tem idéia do que pode ser?

agradeço desde já.

7 Respostas

Eder_Peixoto

Olá Wanderley,

Cole o pedaço do seu código onde está sendo disparada a exception e também o StackTrace completo.
Pela exception apresentada, você deve estar informando algum argumento inválido ao chamar o método de criação de query.

W

Olá Eder

essa é a parte do codigo do form ?

public FisicoQuimicoView() {
        initComponents();
        if (!Beans.isDesignTime()) {
            entityManager.getTransaction().begin();
        }
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        entityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory("bd_saaePU").createEntityManager();
        query = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery("SELECT f FROM Fisicoquimico f");
        list = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : org.jdesktop.observablecollections.ObservableCollections.observableList(query.getResultList());

e aqui temos uma outra parte da mensagem de erro:

Caused by: Exception [TOPLINK-8034] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.EJBQLException
[color=red]Exception Description: Error compiling the query [SELECT f FROM Fisicoquimico f]. Unknown abstract schema type [Fisicoquimico].[/color]

W

vamos lá pessoal encarecidamente peço a ajuda de vcs pois preciso terminar esse projeto não sei mais o que fazer
abaixo segue toda a sequiencia de erro:

[TopLink Info]: 2010.02.22 10:46:36.062--ServerSession(29530019)--TopLink, version: Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))
[TopLink Info]: 2010.02.22 10:46:36.812--ServerSession(29530019)--file:/C:/aplicativo%20java/testerelatorio/build/classes/-bd_saaePU login successful
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: An exception occured while creating a query in EntityManager
at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl.createQuery(EntityManagerImpl.java:209)
at testerelatorio.com.br.FisicoQuimicoView.initComponents(FisicoQuimicoView.java:46)
at testerelatorio.com.br.FisicoQuimicoView.(FisicoQuimicoView.java:29)
at testerelatorio.com.br.FisicoQuimicoView$1.run(FisicoQuimicoView.java:755)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Caused by: Exception [TOPLINK-8034] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.EJBQLException
Exception Description: Error compiling the query [SELECT fq FROM Fisicoquimico fq]. Unknown abstract schema type [Fisicoquimico].
at oracle.toplink.essentials.exceptions.EJBQLException.unknownAbstractSchemaType(EJBQLException.java:494)
at oracle.toplink.essentials.internal.parsing.ParseTreeContext.classForSchemaName(ParseTreeContext.java:163)
at oracle.toplink.essentials.internal.parsing.SelectNode.getClassOfFirstVariable(SelectNode.java:366)
at oracle.toplink.essentials.internal.parsing.SelectNode.getReferenceClass(SelectNode.java:354)
at oracle.toplink.essentials.internal.parsing.ParseTree.getReferenceClass(ParseTree.java:463)
at oracle.toplink.essentials.internal.parsing.ParseTree.adjustReferenceClassForQuery(ParseTree.java:103)
at oracle.toplink.essentials.internal.parsing.EJBQLParseTree.populateReadQueryInternal(EJBQLParseTree.java:127)
at oracle.toplink.essentials.internal.parsing.EJBQLParseTree.populateQuery(EJBQLParseTree.java:108)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:219)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:189)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:153)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.(EJBQueryImpl.java:114)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.(EJBQueryImpl.java:99)
at oracle.toplink.essentials.internal.ejb.cmp3.EJBQueryImpl.(EJBQueryImpl.java:86)
at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl.createQuery(EntityManagerImpl.java:204)
... 11 more
CONSTRUÍDO COM SUCESSO (tempo total: 8 segundos)

e abaixo a parte do código onde apresenta o problema:
public class FisicoQuimicoView extends JPanel {
    
    public FisicoQuimicoView() {
        initComponents();
        if (!Beans.isDesignTime()) {
            entityManager.getTransaction().begin();
        }
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        entityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory("bd_saaePU").createEntityManager();
        query = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery("SELECT fq FROM Fisicoquimico fq");
        list = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : org.jdesktop.observablecollections.ObservableCollections.observableList(query.getResultList());
        masterScrollPane = new javax.swing.JScrollPane();

conto com vcs para me ajudar a resolver o problema

Eder_Peixoto

A classe Fisicoquimico existe? Se existe: não seria FisicoQuimico?

Eder_Peixoto

Problema semelhante: http://www.guj.com.br/posts/list/144038.java#776610

Eder_Peixoto

Código-fonte onde é disparada a Exception: ParseTreeContext (linhas 161 a 179).

/** 
             * INTERNAL
             * Answer the class associated with the provided schema name
             */
            public Class classForSchemaName(String schemaName,
                    GenerationContext context) {
                ClassDescriptor descriptor = context.getSession()
                        .getDescriptorForAlias(schemaName);
                if (descriptor == null) {

                    // >>> Aqui está sendo disparada a exception <<<
                    throw EJBQLException.unknownAbstractSchemaType(
                            getQueryInfo(), schemaName);

                }
                Class theClass = descriptor.getJavaClass();
                if (theClass == null) {
                    throw EJBQLException.resolutionClassNotFoundException(
                            getQueryInfo(), schemaName);
                }
                return theClass;
            }
Eder_Peixoto

O ClassDescriptor é criado nessa classe: Project (linhas 833 a 843).

Como a variável aliasDescriptors deve estar nula, então retorna nulo.

/**
             * PUBLIC:
             * Return the descriptor for the alias.
             */
            public ClassDescriptor getClassDescriptorForAlias(String alias) {
                ClassDescriptor d = null;
                if (aliasDescriptors != null) {
                    d = (ClassDescriptor) aliasDescriptors.get(alias);
                }
                return d;
            }
Criado 18 de fevereiro de 2010
Ultima resposta 22 de fev. de 2010
Respostas 7
Participantes 2