4 Replies Latest reply on Sep 13, 2005 12:45 AM by Andrew Iggleden

    java.lang.NoClassDefFoundError: antlr/RecognitionException

    Andrew Iggleden Newbie

      My bean adds to the DB fine, I can see it in the HSQL DB Manager but whichever way I try to retieve the info it comes up with the following error.

      Exception in thread "main" java.lang.NoClassDefFoundError: antlr/RecognitionException
      at java.lang.Class.getDeclaredFields0(Native Method)
      at java.lang.Class.privateGetDeclaredFields(Unknown Source)
      at java.lang.Class.getDeclaredField(Unknown Source)
      at java.io.ObjectStreamClass.getDeclaredSUID(Unknown Source)
      at java.io.ObjectStreamClass.access$600(Unknown Source)
      at java.io.ObjectStreamClass$2.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.io.ObjectStreamClass.(Unknown Source)
      at java.io.ObjectStreamClass.lookup(Unknown Source)
      at java.io.ObjectStreamClass.initNonProxy(Unknown Source)
      at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
      at java.io.ObjectInputStream.readClassDesc(Unknown Source)
      at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
      at java.io.ObjectInputStream.readObject0(Unknown Source)
      at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
      at java.io.ObjectInputStream.readSerialData(Unknown Source)
      at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
      at java.io.ObjectInputStream.readObject0(Unknown Source)
      at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
      at java.io.ObjectInputStream.readSerialData(Unknown Source)
      at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
      at java.io.ObjectInputStream.readObject0(Unknown Source)
      at java.io.ObjectInputStream.readObject(Unknown Source)
      at org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:72)
      at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:244)
      at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:117)
      at org.jboss.remoting.Client.invoke(Client.java:201)
      at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:41)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
      at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:46)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
      at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:40)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
      at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:41)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
      at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:88)
      at $Proxy0.getCustomer(Unknown Source)
      at client.Client.main(Client.java:34)


      package com.meerkat.jfr.ejb;
      
      import java.util.Collection;
      import java.util.List;
      
      import javax.ejb.Stateful;
      import javax.ejb.Stateless;
      import javax.persistence.EntityManager;
      import javax.persistence.PersistenceContext;
      import javax.transaction.Transaction;
      
      import org.jboss.aspects.Current;
      
      import com.meerkat.jfr.par.CustomerCMP;
      
      @Stateless
      public class CustomerBean implements Customer {
      
       @PersistenceContext(unitName = "cust")
       private EntityManager em;
       @Current Transaction tx;
      
       public CustomerCMP addCustomer(String Name, String Contact)
       {
       CustomerCMP cust = new CustomerCMP(Name, Contact);
       em.persist(cust);
       em.flush();
       return cust;
       }
       public CustomerCMP getCustomer(String Name)
       {
       return (CustomerCMP) em.createQuery("from Customer c where c.Name =:Name")
       .setParameter("Name", Name)
       .getSingleResult();
       }
       public List getCustomers()
       {
       return em.createQuery("from Customer c").getResultList();
       }
      
      }
      

      import javax.persistence.*;
      
      @Entity
      @Table(name = "CUSTOMER")
      public class CustomerCMP implements java.io.Serializable{
      
       private Long id;
       private String name;
       private String contact;
      // private Address address;
      // private List<Store> StoreList;
      
       public CustomerCMP(){}
      
       public CustomerCMP(String Name, String Contact)
       {
      // Debug.print("Create", this);
       this.name = Name;
       this.contact = Contact;
       }
      
       @Id(generate = GeneratorType.AUTO)
       @Column(name = "ID", nullable = false)
       public Long getId() {
       return id;
       }
       public void setId(Long id) {
       this.id = id;
       }
      
       @Column(name="NAME")
       public String getName() {
       return name;
       }
       public void setName(String name) {
       this.name = name;
       }
      
       @Column(name="CONTACT")
       public String getContact() {
       return contact;
       }
       public void setContact(String contact) {
       this.contact = contact;
       }
      }


        • 1. Re: java.lang.NoClassDefFoundError: antlr/RecognitionExcepti
          vlokesh Newbie

          What configuration are you using for your deployment? default or all? The error says that you dont have antlr.jar in your classpath. If you are deploying the ejb app under all configuration then it will not throw that exception. antlr.jar is used to constructing the queries.

          Regards.

          Lokesh.

          • 2. Re: java.lang.NoClassDefFoundError: antlr/RecognitionExcepti
            Andrew Iggleden Newbie

             

            "vlokesh" wrote:
            What configuration are you using for your deployment? default or all? The error says that you dont have antlr.jar in your classpath. If you are deploying the ejb app under all configuration then it will not throw that exception. antlr.jar is used to constructing the queries.

            Regards.

            Lokesh.


            hi,

            i am using all but I included antlr-2.7.5.H3.jar and now I get the following error. If I can write why not read ?

            Exception in thread "main" javax.ejb.EJBException: null; CausedByException is:
            Customer is not mapped. [from Customer c]
            at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:46)
            at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:70)
            at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:134)
            at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
            at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:61)
            at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
            at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:39)
            at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
            at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:63)
            at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
            at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:91)
            at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
            at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:195)
            at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:107)
            at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:69)
            at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:325)
            at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:201)
            at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:259)
            at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:327)
            at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:147)
            org.hibernate.hql.ast.QuerySyntaxException: Customer is not mapped. [from Customer c]
            at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:145)
            at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:86)
            at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:72)
            at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:260)
            at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3019)
            at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2908)
            at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:676)
            at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:532)
            at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:269)
            at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:217)
            at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:211)
            at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:153)
            at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:100)
            at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:459)
            at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:904)
            at org.hibernate.impl.SessionImpl.list(SessionImpl.java:854)
            at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
            at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:41)
            at com.meerkat.jfr.ejb.CustomerBean.getCustomers(CustomerBean.java:38)
            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.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:99)
            at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:32)
            at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
            at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:66)
            at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:134)
            at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
            at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:61)
            at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
            at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:39)
            at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
            at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:63)
            at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
            at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:91)
            at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
            at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:195)
            at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:107)
            at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:69)
            at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:325)
            at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:201)
            at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:259)
            at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:327)
            at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:147)
            Caused by: Customer is not mapped.
            ... 45 more


            • 3. Re: java.lang.NoClassDefFoundError: antlr/RecognitionExcepti
              vlokesh Newbie

              Your Query is wrong....

              Change this

              return (CustomerCMP) em.createQuery("from Customer c where c.Name =:Name").getSingleResult()

              return em.createQuery("from Customer c").getResultList();

              To

              return (CustomerCMP) em.createQuery("from CustomerCMP c where c.Name =:Name").getSingleResult()

              return em.createQuery("from CustomerCMP c").getResultList();

              in both method calls.

              Regards.

              Lokesh.

              • 4. Re: java.lang.NoClassDefFoundError: antlr/RecognitionExcepti
                Andrew Iggleden Newbie

                 

                "vlokesh" wrote:
                Your Query is wrong....

                Change this

                return (CustomerCMP) em.createQuery("from Customer c where c.Name =:Name").getSingleResult()

                return em.createQuery("from Customer c").getResultList();

                To

                return (CustomerCMP) em.createQuery("from CustomerCMP c where c.Name =:Name").getSingleResult()

                return em.createQuery("from CustomerCMP c").getResultList();

                in both method calls.

                Regards.

                Lokesh.


                Hi Lokesh,

                the getCustomers works great. The getCustomer (code see below) now generates the exception below. The server is still running and I can rerun the client with the same results.

                What did I screw up ?

                tia

                exception in thread "main" java.lang.reflect.UndeclaredThrowableException
                at $Proxy0.getCustomer(Unknown Source)
                at client.Client.getOneCust(Client.java:47)
                at client.Client.main(Client.java:31)
                Caused by: java.rmi.ConnectException: Failed to communicate. Problem during marshalling/unmarshalling; nested exception is:
                java.net.SocketTimeoutException: Read timed out

                private static void getOneCust()
                 {
                 System.out.println("Getting");
                 CustomerCMP cust1 = cust.getCustomer("Andrew");
                 System.out.printf("%s %s\r\n", cust1.getName(), cust1.getContact());
                 System.out.println("done");
                 }