0

在 bean 中,我尝试使用此方法列出所有文章

public List<Article> listerLesArticles() {
    javax.persistence.Query req = manager.createQuery("select * from Article");
    return req.getResultList();
}

当我调用该方法时来自客户

public void lister() {
    List<Article> arr = epicerie.listerLesArticles();
    System.out.println(" ");
    Iterator<Article> iterator =  arr.iterator();
    while (iterator.hasNext()) {
        Article unArticle=iterator.next();
        System.out.println(unArticle.getCode());
    }
    System.exit(0);
}

但我明白了Exception

Exception in thread "main" java.lang.reflect.UndeclaredThrowableException
    at $Proxy2.listerLesArticles(Unknown Source)
    at ecpicerie.EpicerieClient.lister(EpicerieClient.java:80)
    at ecpicerie.EpicerieClient.main(EpicerieClient.java:122)
Caused by: java.lang.ClassNotFoundException: org.hibernate.hql.ast.QuerySyntaxException
    at org.jboss.remoting.serialization.ClassLoaderUtility.loadClass(ClassLoaderUtility.java:103)
    at org.jboss.remoting.loading.RemotingClassLoader.loadClass(RemotingClassLoader.java:86)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:334)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at org.jboss.remoting.loading.ObjectInputStreamWithClassLoader.resolveClass(ObjectInputStreamWithClassLoader.java:176)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1592)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1513)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1749)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1346)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1963)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1887)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1770)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1346)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1963)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1887)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1770)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1346)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1963)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1887)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1770)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1346)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:368)
    at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObjectVersion2_2(JavaSerializationManager.java:238)
    at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObject(JavaSerializationManager.java:138)
    at org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:123)
    at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.versionedRead(MicroSocketClientInvoker.java:1215)
    at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.transport(MicroSocketClientInvoker.java:845)
    at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:160)
    at org.jboss.remoting.Client.invoke(Client.java:1708)
    at org.jboss.remoting.Client.invoke(Client.java:612)
    at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:60)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
    at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
    at org.jboss.ejb3.security.client.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:65)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
    at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:74)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
    at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:62)
    at $Proxy3.invoke(Unknown Source)
    at org.jboss.ejb3.proxy.handler.ProxyInvocationHandlerBase.invoke(ProxyInvocationHandlerBase.java:261)
    at org.jboss.ejb3.proxy.handler.session.SessionSpecProxyInvocationHandlerBase.invoke(SessionSpecProxyInvocationHandlerBase.java:101)
    at $Proxy2.listerLesArticles(Unknown Source)
    at ecpicerie.EpicerieClient.lister(EpicerieClient.java:80)
    at ecpicerie.EpicerieClient.main(EpicerieClient.java:122)
    at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:72)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
    at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
    at org.jboss.ejb3.security.client.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:65)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
    at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:74)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
    at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:62)
    at $Proxy3.invoke(Unknown Source)
    at org.jboss.ejb3.proxy.handler.ProxyInvocationHandlerBase.invoke(ProxyInvocationHandlerBase.java:261)
    at org.jboss.ejb3.proxy.handler.session.SessionSpecProxyInvocationHandlerBase.invoke(SessionSpecProxyInvocationHandlerBase.java:101)
    ... 3 more

在这条线上

List<Article> arr=epicerie.listerLesArticles();

我该如何解决这个问题?

4

2 回答 2

1

你有两个基本问题:

  • 您的 JPQL 查询错误
  • 您的客户端没有所有必需的客户端库

请参阅查询的另一个答案,但要意识到通过修复查询,您只解决了一半的问题。服务器的文档应该告诉您需要复制哪些库(对于 JBoss,它基本上是整个 /client 库)。

于 2012-05-09T08:30:53.437 回答
0

尝试将您的 HQL 查询设置为:“来自文章”。造成这种情况的根本原因似乎是您遇到了 HQL 语法异常,但由于它没有 JPA 的 jar,因此无法将其序列化到您的客户端应用程序。

编辑:正如 Achille 的评论,“从文章 e 中选择 e”也可以。

于 2012-05-08T19:57:07.687 回答