Error calling Webservice that returns a list (JPA)

Asked

Viewed 125 times

1

Hello, I am unable to return a list of orders by Webservice:

public List<Pedido> getPedido() throws Exception {

    String query = "SELECT p FROM Pedido p";
    TypedQuery<Pedido> typedQuery = entityManager.createQuery(query , Pedido.class);
    return typedQuery.getResultList();          
}

the error shown is as follows::

nov 14, 2015 10:18:12 AM org.apache.openejb.core.transaction.EjbTransactionUtil handleSystemException
SEVERE: EjbTransactionUtil.handleSystemException: null
<openjpa-2.4.0-r422266:1674604 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: null
FailedObject: SELECT p FROM Pedido p [java.lang.String]
    at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:1029)
    at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:928)
    at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1032)
    at org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:280)
    at org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2382)
    at org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:274)
    at org.apache.openjpa.jdbc.kernel.InstanceResultObjectProvider.getResultObject(InstanceResultObjectProvider.java:59)
    at org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java:35)
    at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1250)
    at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:1006)
    at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:862)
    at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:793)
    at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:541)
    at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:274)
    at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:290)
    at dao.PedidoDAO.getPedido(PedidoDAO.java:34)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:192)
    at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:173)
    at org.apache.openejb.monitoring.StatsInterceptor.record(StatsInterceptor.java:181)
    at org.apache.openejb.monitoring.StatsInterceptor.invoke(StatsInterceptor.java:100)
    at sun.reflect.GeneratedMethodAccessor46.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:192)
    at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:173)
    at org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:85)
    at org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:227)
    at org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:194)
    at org.apache.openejb.core.ivm.EjbObjectProxyHandler.synchronizedBusinessMethod(EjbObjectProxyHandler.java:308)
    at org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:303)
    at org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:92)
    at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:322)
    at dao.PedidoDAO$$LocalBeanProxy.getPedido(dao/PedidoDAO.java)
    at webservice.PedidoWebService.getAllPedidos(PedidoWebService.java:31)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.openejb.server.cxf.rs.PojoInvoker.performInvocation(PojoInvoker.java:43)
    at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
    at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:165)
    at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:89)
    at org.apache.openejb.server.cxf.rs.AutoJAXRSInvoker.invoke(AutoJAXRSInvoker.java:68)
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:57)
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:93)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
    at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:240)
    at org.apache.openejb.server.cxf.rs.CxfRsHttpListener.doInvoke(CxfRsHttpListener.java:227)
    at org.apache.tomee.webservices.CXFJAXRSFilter.doFilter(CXFJAXRSFilter.java:94)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
    at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
    at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
    at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
    at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
    at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.setInverseRelation(JDBCStoreManager.java:452)
    at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:412)
    at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:305)
    at org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:112)
    at org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:57)
    at org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:1048)
    at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:1006)
    ... 78 more

My order class is as follows:

@Entity
@NamedQuery(name="Pedido.findAll", query="SELECT p FROM Pedido p")
public class Pedido implements Serializable {
private static final long serialVersionUID = 1L;

@Id
@Column(name="PEDIDO_ID")
@TableGenerator(name="PEDIDO_GENERATOR", table="ID_TABLE", pkColumnName="ID_TABLE_NAME", pkColumnValue="PEDIDO_ID", valueColumnName="ID_TABLE_VALUE")
@GeneratedValue(strategy = GenerationType.TABLE, generator="PEDIDO_GENERATOR")
private long id;
private float valor;

private long senha;

@OneToMany(fetch=FetchType.EAGER, cascade = CascadeType.MERGE)
@JoinTable
 (
      name="PEDIDO_ITEM",
      joinColumns={ @JoinColumn(name="PEDIDO_ID", referencedColumnName="PEDIDO_ID") }
  )
List<ItemPedido> itempedido = new LinkedList<ItemPedido>();
//getters and setters

Itempedido class:

@Entity
@NamedQuery(name="ItemPedido.findAll", query="SELECT u FROM ItemPedido u")
public class ItemPedido implements Serializable {
private static final long serialVersionUID = 1L;

@Id
@Column(name="ITEM_ID")
@TableGenerator(name="ITEM_GENERATOR", table="ID_TABLE", pkColumnName="ID_TABLE_NAME", pkColumnValue="ITEM_ID", valueColumnName="ID_TABLE_VALUE")
@GeneratedValue(strategy = GenerationType.TABLE, generator="ITEM_GENERATOR")
private long id;

@OneToOne(cascade = CascadeType.MERGE)
private Produto produto;
private long quantidade;
//getters and setters
  • Line 34 of PedidoDAO, what’s there? That’s the mistake (at least it was, if it hasn’t changed after creating the question), there’s something null out there.

  • The 34 line is the Pedidodao’s Return typedQuery.getResultList(); line. It’s adding correctly in the database, I just can’t list...

  • If you call Namedquery, what happens?

  • So, with Namedquery it works when there is no Request and Itempedido registered, but when I register the Request and try to return the list again, it returns an error similar to the previous one. Note: the entry in the database is working correctly.`

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.