1

我有一个关于股票交易的 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

他们的吸气剂二传手将其记录下来。

这是如何引起的,我该如何解决?

4

3 回答 3

2

实际问题在此问题开始发生之前就已记录在案,并且可能与您正在执行的查询无关 - 只是碰巧这是您的应用程序中的第一个 EM 访问,并且容器将 EM 包装在代理后面。

EclipseLink 有错误https://bugs.eclipse.org/bugs/show_bug.cgi?id=376995已在 2.4 中修复,这将导致在部署阶段处于失败状态时发生此错误。在失败后尝试使用工厂将导致它尝试重新添加 JPQL 查询,从而导致此错误。该补丁会保留初始错误并重新抛出它,从而更容易找到初始原因。因此,您可以尝试使用 EclipseLink 2.4 nightly build,但实际原因应该出现在 EMF 部署期间的日志中。

您在应用程序中添加了哪些代码来支持新领域?

于 2012-05-22T16:14:06.603 回答
1

我为查询使用了不同的名称来解决它。以“find”开头的命名查询名称似乎确实会引起麻烦。

于 2012-09-13T08:44:09.580 回答
0

目前,您使用哪个 Eclipse 版本?这是一个问题EclipseLink 2.1.2

我想建议使用javax.persistence_2.0.4.v201112161009eclipselink.jar版本EclipseLink 2.4.1下载 EclipseLink 2.4.1

于 2013-02-22T04:53:30.860 回答