Community
Participate
Working Groups
Build Identifier: EclipseLink 2.3.0 In NetBeans: Create a Java EE 6 project, enable CDI and JSF Use jdbc/sample database and generate JPA entities for any table Add the named queries as: @NamedQueries({ @NamedQuery(name = "Sezzion.findAll", query = "SELECT s FROM Sezzion s"), @NamedQuery(name = "Sezzion.findAllTracks", query = "SELECT DISTINCT s.TRACK FROM Sezzion s"), The names should be "findAll" and other name should be "findAllXXX". Create an EJB and inject EntityManager: @PersistenceContext EntityManager em; Invoke any of the query in an EJB Use this EJB in an .XHTML page and view the page in a browser to see the error below: Exception Description: Cannot add a query whose types conflict with an existing query. Query To Be Added: [ReadAllQuery(name="Sezzion.findAll" referenceClass=Sezzion jpql="SELECT s FROM Sezzion s")] is named: [Sezzion.findAll] with arguments [[]].The existing conflicting query: [ReadAllQuery(name="Sezzion.findAll" referenceClass=Sezzion jpql="SELECT s FROM Sezzion s")] is named: [Sezzion.findAll] with arguments: [[]]. at org.eclipse.persistence.exceptions.ValidationException.existingQueryTypeConflict(ValidationException.java:902) at org.eclipse.persistence.internal.sessions.AbstractSession.addQuery(AbstractSession.java:422) at org.eclipse.persistence.internal.sessions.AbstractSession.addQuery(AbstractSession.java:395) at org.eclipse.persistence.internal.sessions.AbstractSession.processJPAQueries(AbstractSession.java:2148) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:442) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:673) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:631) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:284) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:290) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:275) at com.sun.enterprise.container.common.impl.EntityManagerWrapper._getDelegate(EntityManagerWrapper.java:208) if "Sezzion.findAllTracks" query is removed then everything works as expected. Reproducible: Always Steps to Reproduce: In NetBeans: Create a Java EE 6 project, enable CDI and JSF Use jdbc/sample database and generate JPA entities for any table Add the named queries as: @NamedQueries({ @NamedQuery(name = "Sezzion.findAll", query = "SELECT s FROM Sezzion s"), @NamedQuery(name = "Sezzion.findAllTracks", query = "SELECT DISTINCT s.TRACK FROM Sezzion s"), The names should be "findAll" and other name should be "findAllXXX". Create an EJB and inject EntityManager: @PersistenceContext EntityManager em; Invoke any of the query in an EJB Use this EJB in an .XHTML page and view the page in a browser to see the error below: Exception Description: Cannot add a query whose types conflict with an existing query. Query To Be Added: [ReadAllQuery(name="Sezzion.findAll" referenceClass=Sezzion jpql="SELECT s FROM Sezzion s")] is named: [Sezzion.findAll] with arguments [[]].The existing conflicting query: [ReadAllQuery(name="Sezzion.findAll" referenceClass=Sezzion jpql="SELECT s FROM Sezzion s")] is named: [Sezzion.findAll] with arguments: [[]]. at org.eclipse.persistence.exceptions.ValidationException.existingQueryTypeConflict(ValidationException.java:902) at org.eclipse.persistence.internal.sessions.AbstractSession.addQuery(AbstractSession.java:422) at org.eclipse.persistence.internal.sessions.AbstractSession.addQuery(AbstractSession.java:395) at org.eclipse.persistence.internal.sessions.AbstractSession.processJPAQueries(AbstractSession.java:2148) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:442) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:673) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:631) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:284) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:290) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:275) at com.sun.enterprise.container.common.impl.EntityManagerWrapper._getDelegate(EntityManagerWrapper.java:208) if "Sezzion.findAllTracks" query is removed then everything works as expected.
Filed as a GlassFish bug at: http://java.net/jira/browse/GLASSFISH-17283 Occurs in GlassFish 3.1.1
Through discussion it appears this issue is the one described here: http://old.nabble.com/Decrypting-error-message-td32222029.html Basically, if there is an incorrectly defined JPQL Named query, we log an exception, but continue with our deployment and this results in an error the 2nd time the factory is deployed. The question is whether we should completely fail in this case, or contine to log the exception and ensure the other queries work. I favour the latter. Setting target and priority. See the following page for the meanings of these fields: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines Community: Please vote for this bug if it is important to you. Votes are one of the main criteria we use to determine which bugs to fix next.
This looks like a duplicate of bug 376995 - "Invalid named JPQL Query causes invalid session to stick around, throw confusing exceptions". Any exception during query processing would have been thrown and prevented deployment leaving the internal session object in an incomplete state. Getting the entityManager after a failed deployment would cause redeployment, resulting in the exception seen here. *** This bug has been marked as a duplicate of bug 376995 ***
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink