我有一个关于股票交易的 Java EE 应用程序,它使用 Web 服务调用 EJB。一切正常,直到我在数据库中添加了一个额外的字段。该应用程序给出以下例外:
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)
...
我调试发现ejb的getAllScrips方法抛出了异常下面是托管bean方法和web服务方法:
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;
}
以下是 EJB 方法:
@Override
public Collection<ScripMaster> getAllScrips() {
Collection<ScripMaster> scripCollection=null;
scripCollection=em.createNamedQuery("ScripMaster.findAll").getResultList();
return scripCollection;
}
scrip.findall
询问 :
@NamedQuery(name = "ScripMaster.findAll", query = "SELECT s FROM ScripMaster s")
编辑: 在实体类 ScripMaster.java 我添加了以下代码:
@Column(name = "PreviousClose", precision = 22)
private Double previousClose; //new column
@Column(name = "Change", precision = 22)
private Double change; //new column
他们的吸气剂二传手将其记录下来。
这是如何引起的,我该如何解决?