Announcement Announcement Module
Collapse
No announcement yet.
Spring + JPA Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring + JPA

    Hi,
    I got a Exception when i use Spring + JPA + Tomcat 5.5.
    I'm using Introduction to Spring 2 and JPA tutorial from IBM (http://www.ibm.com/developerworks/ed...pring2-i.html).

    org.springframework.web.util.NestedServletExceptio n: Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageE xception: An exception occured while creating a query in EntityManager; nested exception is java.lang.IllegalArgumentException: An exception occured while creating a query in EntityManager
    org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:472)
    org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:415)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:690)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:803)


    root cause

    org.springframework.dao.InvalidDataAccessApiUsageE xception: An exception occured while creating a query in EntityManager; nested exception is java.lang.IllegalArgumentException: An exception occured while creating a query in EntityManager
    org.springframework.orm.jpa.EntityManagerFactoryUt ils.convertJpaAccessExceptionIfPossible(EntityMana gerFactoryUtils.java:229)
    org.springframework.orm.jpa.DefaultJpaDialect.tran slateExceptionIfPossible(DefaultJpaDialect.java:11 3)
    org.springframework.dao.support.DataAccessUtils.tr anslateIfNecessary(DataAccessUtils.java:212)
    org.springframework.orm.jpa.JpaAccessor.translateI fNecessary(JpaAccessor.java:152)
    org.springframework.orm.jpa.JpaTemplate.execute(Jp aTemplate.java:196)
    org.springframework.orm.jpa.JpaTemplate.executeFin d(JpaTemplate.java:158)
    org.springframework.orm.jpa.JpaTemplate.find(JpaTe mplate.java:305)
    org.springframework.orm.jpa.JpaTemplate.find(JpaTe mplate.java:301)
    com.ibm.dw.spring2.EmployeeDAO.findAll(EmployeeDAO .java:13)
    com.ibm.dw.spring2.web.MainController.handleReques tInternal(MainController.java:26)
    org.springframework.web.servlet.mvc.AbstractContro ller.handleRequest(AbstractController.java:153)
    org.springframework.web.servlet.mvc.SimpleControll erHandlerAdapter.handle(SimpleControllerHandlerAda pter.java:48)
    org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:857)
    org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:792)
    org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:460)
    org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:415)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:690)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:803)


    root cause

    java.lang.IllegalArgumentException: An exception occured while creating a query in EntityManager
    oracle.toplink.essentials.internal.ejb.cmp3.Entity ManagerImpl.createQuery(EntityManagerImpl.java:209 )
    sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:585)
    org.springframework.orm.jpa.ExtendedEntityManagerC reator$ExtendedEntityManagerInvocationHandler.invo ke(ExtendedEntityManagerCreator.java:340)
    $Proxy5.createQuery(Unknown Source)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:585)
    org.springframework.orm.jpa.JpaTemplate$CloseSuppr essingInvocationHandler.invoke(JpaTemplate.java:40 0)
    $Proxy6.createQuery(Unknown Source)
    org.springframework.orm.jpa.JpaTemplate$9.doInJpa( JpaTemplate.java:307)
    org.springframework.orm.jpa.JpaTemplate.execute(Jp aTemplate.java:191)
    org.springframework.orm.jpa.JpaTemplate.executeFin d(JpaTemplate.java:158)
    org.springframework.orm.jpa.JpaTemplate.find(JpaTe mplate.java:305)
    org.springframework.orm.jpa.JpaTemplate.find(JpaTe mplate.java:301)
    com.ibm.dw.spring2.EmployeeDAO.findAll(EmployeeDAO .java:13)
    com.ibm.dw.spring2.web.MainController.handleReques tInternal(MainController.java:26)
    org.springframework.web.servlet.mvc.AbstractContro ller.handleRequest(AbstractController.java:153)
    org.springframework.web.servlet.mvc.SimpleControll erHandlerAdapter.handle(SimpleControllerHandlerAda pter.java:48)
    org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:857)
    org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:792)
    org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:460)
    org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:415)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:690)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:803)


    root cause

    Exception [TOPLINK-8034] (Oracle TopLink Essentials - 2.0 (Build b49-beta3 (05/31/2007))): oracle.toplink.essentials.exceptions.EJBQLExceptio n
    Exception Description: Error compiling the query [select e from Employee e]. Unknown abstract schema type [Employee].
    oracle.toplink.essentials.exceptions.EJBQLExceptio n.unknownAbstractSchemaType(EJBQLException.java:49 4)
    oracle.toplink.essentials.internal.parsing.ParseTr eeContext.classForSchemaName(ParseTreeContext.java :163)
    oracle.toplink.essentials.internal.parsing.SelectN ode.getClassOfFirstVariable(SelectNode.java:366)
    oracle.toplink.essentials.internal.parsing.SelectN ode.getReferenceClass(SelectNode.java:354)
    oracle.toplink.essentials.internal.parsing.ParseTr ee.getReferenceClass(ParseTree.java:463)
    oracle.toplink.essentials.internal.parsing.ParseTr ee.adjustReferenceClassForQuery(ParseTree.java:103 )
    oracle.toplink.essentials.internal.parsing.EJBQLPa rseTree.populateReadQueryInternal(EJBQLParseTree.j ava:127)
    oracle.toplink.essentials.internal.parsing.EJBQLPa rseTree.populateQuery(EJBQLParseTree.java:108)
    oracle.toplink.essentials.internal.ejb.cmp3.base.E JBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.j ava:219)
    oracle.toplink.essentials.internal.ejb.cmp3.base.E JBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.j ava:189)
    oracle.toplink.essentials.internal.ejb.cmp3.base.E JBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.j ava:153)
    oracle.toplink.essentials.internal.ejb.cmp3.base.E JBQueryImpl.<init>(EJBQueryImpl.java:114)
    oracle.toplink.essentials.internal.ejb.cmp3.base.E JBQueryImpl.<init>(EJBQueryImpl.java:99)
    oracle.toplink.essentials.internal.ejb.cmp3.EJBQue ryImpl.<init>(EJBQueryImpl.java:86)
    oracle.toplink.essentials.internal.ejb.cmp3.Entity ManagerImpl.createQuery(EntityManagerImpl.java:204 )
    sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:585)
    org.springframework.orm.jpa.ExtendedEntityManagerC reator$ExtendedEntityManagerInvocationHandler.invo ke(ExtendedEntityManagerCreator.java:340)
    $Proxy5.createQuery(Unknown Source)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:585)
    org.springframework.orm.jpa.JpaTemplate$CloseSuppr essingInvocationHandler.invoke(JpaTemplate.java:40 0)
    $Proxy6.createQuery(Unknown Source)
    org.springframework.orm.jpa.JpaTemplate$9.doInJpa( JpaTemplate.java:307)
    org.springframework.orm.jpa.JpaTemplate.execute(Jp aTemplate.java:191)
    org.springframework.orm.jpa.JpaTemplate.executeFin d(JpaTemplate.java:158)
    org.springframework.orm.jpa.JpaTemplate.find(JpaTe mplate.java:305)
    org.springframework.orm.jpa.JpaTemplate.find(JpaTe mplate.java:301)
    com.ibm.dw.spring2.EmployeeDAO.findAll(EmployeeDAO .java:13)
    com.ibm.dw.spring2.web.MainController.handleReques tInternal(MainController.java:26)
    org.springframework.web.servlet.mvc.AbstractContro ller.handleRequest(AbstractController.java:153)
    org.springframework.web.servlet.mvc.SimpleControll erHandlerAdapter.handle(SimpleControllerHandlerAda pter.java:48)
    org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:857)
    org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:792)
    org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:460)
    org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:415)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:690)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:803)


    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.23 logs.


    --------------------------------------------------------------------------------

    Apache Tomcat/5.5.23


    Any Idea?

    Thank you.

  • #2
    Code:
    Error compiling the query [select e from Employee e]. Unknown abstract schema type [Employee].
    suggests that Employee doesn't exist. Is there an issue with the database? Can you perform that exact select statement in an interactive tool?

    Also, in the future, could you wrap your stacktraces in code tags? Makes it easier to read.

    Comment


    • #3
      This seems to talk about a similar/same problem.
      http://forum.springframework.org/showthread.php?t=32671
      Last edited by karldmoore; Aug 30th, 2007, 05:35 AM.

      Comment


      • #4
        Bill,
        I have a Employee table in my db and I do select statement and it works fine.

        Thank you.

        Comment


        • #5
          Karldmoore,
          Thank your for post. I solve the problem when I change apache-tomcat-5.5.23 to apache-tomcat-5.5.17, like tutorial said but I got JSTL exception because jstl.jar and standard.jar founded in spring-framework-2.0-rc2-with-dependencies\lib are broken, so i updated them for version 1.1.2.

          Bye.

          Comment

          Working...
          X