2 Replies Latest reply on Nov 8, 2010 11:57 AM by 811220

    EJB3.0:JPA :java.lang.IllegalArgumentException

    695201
      Im pretty new to this, so Im trying to post everything you need to understand my problem,try to be more clear, i'm in lack of ideas in this problem, even it sounds like a classic

      /*Bean class*/
      public class BookCatalogBean implements Serializable, BookCatalogInterface {
      @PersistenceContext(unitName="EntityBean")
      // @PersistenceContext

      EntityManager em;
      protected BookBank book;
      protected Collection <BookBank> pmnList;

      public void addBook(String title, String author, double price) {
      // Initialize the form
      if (book == null)
      book = new BookBank(title, author, price);
      em.persist(book);
      }

      public Collection <BookBank>getAllBooks() {
      System.out.println("BookCatalogInterface.java:getAllBooks");
      pmnList=em.createQuery("from BookBank book ").getResultList();
      System.out.println("BookCatalogInterface.java:getAllBooks...111:"+pmnList);
      return pmnList;
      }
      }

      /*and this is another class BookBank.java */

      package entity.library;

      import javax.persistence.Entity;
      import javax.persistence.GeneratedValue;
      import javax.persistence.GenerationType;
      import javax.persistence.Id;
      import javax.persistence.Table;
      import java.util.Collection;
      import javax.persistence.*;
      import java.io.Serializable;

      @Entity
      @Table(name="BookBank")
      public class BookBank implements Serializable {
      long id;
      /*variable declaration*/
      public BookBank() {
      super();
      }

      public BookBank(String title, String author, double price) {
      super();
      this.title = title;
      this.author = author;
      this.price = price;
      }
      @Id
      @GeneratedValue(strategy=GenerationType.AUTO)

      // Getter and setter methods for the defined properties..


      }



      and I am getting error :-
      BookCatalogInterface.java:getAllBooks
      javax.ejb.EJBException: EJB Exception: ; nested exception is:
      java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
      Exception Description: Syntax error parsing the query [from entity.library.ConfPmno conf ], line 1, column 0: unexpected token [from].
      Internal Exception: NoViableAltException(32!=[197:1: document : (root= selectStatement | root= updateStatement | root= deleteStatement );]); nested exception is: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
      Exception Description: Syntax error parsing the query [from entity.library.ConfPmno conf ], line 1, column 0: unexpected token [from].
      Internal Exception: NoViableAltException(32!=[197:1: document : (root= selectStatement | root= updateStatement | root= deleteStatement );])
      java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
      Exception Description: Syntax error parsing the query [from BookBank book ], line 1, column 0: unexpected token [from].
      Internal Exception: NoViableAltException(32!=[197:1: document : (root= selectStatement | root= updateStatement | root= deleteStatement );])
      at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1328)
      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 weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:93)
      at weblogic.deployment.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:91)
      at weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:80)
      at weblogic.deployment.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:26)
      at $Proxy140.createQuery(Unknown Source)
      at entity.library.ConfPmnoBean.getAllBooks(ConfPmnoBean.java:37)
      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 com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
      at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
      at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
      at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
      at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
      at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
      at com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:37)
      at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54)
      at com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:50)
      at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proc

      persistent.xml :-
      <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
      <persistence-unit name="EntityBean" transaction-type="JTA">
      <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
      <jta-data-source>DB_DS</jta-data-source>
      <non-jta-data-source>DB_DS</non-jta-data-source>
      <properties>
      <property name="eclipselink.target-server" value="WebLogic_10"/>
      <property name="eclipselink.logging.level" value="FINEST"/>
      </properties>
      </persistence-unit>
      </persistence>





      I am not able to resolve the issue,getting error while calling getAllBooks method(createQuery line) of BookCatalogBean.java file.
      Any help is much appreciated,Please suggest solution