Reputation: 10083
I have a Java EE application on stock trading which calls the EJB using a web service. All was working fine until I added an extra field in the database. The app gives the following exception:
WARNING: A system exception occurred during an invocation on EJB StockCommodityEJB method public java.util.Collection ejb.StockCommodityEJB.getAllScrips()
javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean
at com.sun.ejb.containers.BaseContainer.checkExceptionClientTx(BaseContainer.java:5049)
at $Proxy640.getAllScrips(Unknown Source)
at service.StatelessWebService.getAllScrips(StatelessWebService.java:62)
....
...
com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl.process(AbstractTubeImpl.java:116)
at com.sun.enterprise.security.webservices.CommonServerSecurityPipe.processRequest(CommonServerSecurityPipe.java:212)
...
Caused by: Exception [EclipseLink-7092] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Cannot add a query whose types conflict with an existing query. Query To Be Added: [ReadAllQuery(name="UserStock.findAll" referenceClass=UserStock jpql="SELECT u FROM UserStock u")] is named: [UserStock.findAll] with arguments [[]].The existing conflicting query: [ReadAllQuery(name="UserStock.findAll" referenceClass=UserStock jpql="SELECT u FROM UserStock u")] is named: [UserStock.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)
...
com.sun.enterprise.container.common.impl.EntityManagerWrapper.createNamedQuery(EntityManagerWrapper.java:532)
at ejb.StockCommodityEJB.getAllScrips(StockCommodityEJB.java:351)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
...
SEVERE: The log message is null.
javax.ejb.EJBTransactionRolledbackException
at ejb._StockCommodityEJBStateless_Wrapper.getAllScrips(ejb/_StockCommodityEJBStateless_Wrapper.java)
at service.StatelessWebService.getAllScrips(StatelessWebService.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
...
Caused by: javax.transaction.TransactionRolledbackException: CORBA TRANSACTION_ROLLEDBACK 9998 Maybe; nested exception is:
org.omg.CORBA.TRANSACTION_ROLLEDBACK: vmcid: 0x2000 minor code: 1806 completed: Maybe
at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java:277)
at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.wrapException(Util.java:696)
at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:251)
...
Caused by: Exception [EclipseLink-7092] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Cannot add a query whose types conflict with an existing query. Query To Be Added: [ReadAllQuery(name="UserStock.findAll" referenceClass=UserStock jpql="SELECT u FROM UserStock u")] is named: [UserStock.findAll] with arguments [[]].The existing conflicting query: [ReadAllQuery(name="UserStock.findAll" referenceClass=UserStock jpql="SELECT u FROM UserStock u")] is named: [UserStock.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)
...
WARNING: A system exception occurred during an invocation on EJB StatelessWebService method public java.util.Collection service.StatelessWebService.getAllScrips()
javax.ejb.EJBTransactionRolledbackException
at ejb._StockCommodityEJBStateless_Wrapper.getAllScrips(ejb/_StockCommodityEJBStateless_Wrapper.java)
at service.StatelessWebService.getAllScrips(StatelessWebService.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052)
at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124)
at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5366)
at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:619)
...
at $Proxy641.getAllScrips(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
Caused by: Exception [EclipseLink-7092] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Cannot add a query whose types conflict with an existing query. Query To Be Added: [ReadAllQuery(name="UserStock.findAll" referenceClass=UserStock jpql="SELECT u FROM UserStock u")] is named: [UserStock.findAll] with arguments [[]].The existing conflicting query: [ReadAllQuery(name="UserStock.findAll" referenceClass=UserStock jpql="SELECT u FROM UserStock u")] is named: [UserStock.findAll] with arguments: [[]].
at org.eclipse.persistence.exceptions.ValidationException.existingQueryTypeConflict(ValidationException.java:902)
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)
...
SEVERE: Error Rendering View[/AdminTemplate/scripMaster.xhtml]
javax.el.ELException: /AdminTemplate/scripMaster.xhtml @50,61 value="#{manageScrip.scripList}": javax.xml.ws.soap.SOAPFaultException: javax.ejb.EJBTransactionRolledbackException
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:114)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
at javax.faces.component.UIData.getValue(UIData.java:731)
at org.primefaces.component.datatable.DataTable.getValue(DataTable.java:786)
at javax.faces.component.UIData.getDataModel(UIData.java:1798)
at javax.faces.component.UIData.getRowCount(UIData.java:356)
at org.primefaces.component.api.UIData.calculatePage(UIData.java:116)
...
at $Proxy643.getAllScrips(Unknown Source)
at beans.manageScrip.getAllScrips(manageScrip.java:422)
at beans.manageScrip.getScripList(manageScrip.java:180)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:302)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at com.sun.el.parser.AstValue.getValue(AstValue.java:116)
at com.sun.el.parser.AstValue.getValue(AstValue.java:163)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:219)
at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:55)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
... 48 more
WARNING: StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
javax.xml.ws.soap.SOAPFaultException: javax.ejb.EJBTransactionRolledbackException
at com.sun.xml.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:193)
...
i debugged and found that the exception was thrown at getAllScrips method of ejb Following is the managed bean method and web service method:
private java.util.List<service.ScripMaster> getAllScrips() {
service.StatelessWebService port = service.getStatelessWebServicePort();
return port.getAllScrips();
}
public List<ScripMaster> getScripList() {
scripList=new ArrayList<ScripMaster> ();
scripList=getAllScrips();
return scripList;
}
Following is the EJB method:
@Override
public Collection<ScripMaster> getAllScrips() {
Collection<ScripMaster> scripCollection=null;
scripCollection=em.createNamedQuery("ScripMaster.findAll").getResultList();
return scripCollection;
}
scrip.findall
query :
@NamedQuery(name = "ScripMaster.findAll", query = "SELECT s FROM ScripMaster s")
Edited: in entity class ScripMaster.java i added the below code:
@Column(name = "PreviousClose", precision = 22)
private Double previousClose; //new column
@Column(name = "Change", precision = 22)
private Double change; //new column
and their getter setter dats it.
How is this caused and how can I solve it?
Upvotes: 1
Views: 7280
Reputation: 41
I worked around it with using a different name for the query. Starting a named query's name with "find" does seem to cause the trouble.
Upvotes: 1
Reputation: 9935
Currently, which eclipse version do you use? It is a issue of EclipseLink 2.1.2
.
I would like to suggest to use javax.persistence_2.0.4.v201112161009
and eclipselink.jar
version with EclipseLink 2.4.1
. Download EclipseLink 2.4.1
Upvotes: 0
Reputation: 21145
The actual problem is logged well before this problem starts to occur, and may have nothing to do with the query you are executing - it just happens that this is the first EM access in your application and the container is wrapping the EM behind a proxy.
EclipseLink has bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=376995 which is fixed in 2.4 that would result in this error occuring when the deployment stage is in a failed state. Trying to use the factory after the failure would result in it attempting to re-add the JPQL queries, resulting in this error. The patch holds onto the intial error and rethrows it, making it easier to find the initial cause. So you can try using EclipseLink 2.4 nightly build, but the actual cause should be appearing in the logs during the EMF deployment.
What code did you add to the application to support the new field?
Upvotes: 2