Announcement Announcement Module
Collapse
No announcement yet.
Problem using JPA on Tomcat Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem using JPA on Tomcat

    Hi all,

    I recently read an artcle from Sing Li "Introduction to Spring 2 and JPA" and follow his example step by step. At the end as I try to run my web application on Tomcat I got the following exceptions. These exception come from data access to the database. Since if've I cleared the tables, it's ok. If I fill data into the tables, I got these exceptions.

    Could someone give me a hint?


    *****

    org.springframework.web.util.NestedServletExceptio n: Handler processing failed; nested exception is

    java.lang.IllegalAccessError: class sun.reflect.GeneratedConstructorAccessor11 cannot access its superclass

    sun.reflect.ConstructorAccessorImpl
    org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:897)
    org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:792)
    org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:461)
    org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:416)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:689)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)


    root cause

    java.lang.IllegalAccessError: class sun.reflect.GeneratedConstructorAccessor11 cannot access its superclass

    sun.reflect.ConstructorAccessorImpl
    sun.misc.Unsafe.defineClass(Native Method)
    sun.reflect.ClassDefiner.defineClass(ClassDefiner. java:45)
    sun.reflect.MethodAccessorGenerator$1.run(MethodAc cessorGenerator.java:381)
    java.security.AccessController.doPrivileged(Native Method)
    sun.reflect.MethodAccessorGenerator.generate(Metho dAccessorGenerator.java:377)
    sun.reflect.MethodAccessorGenerator.generateConstr uctor(MethodAccessorGenerator.java:76)
    sun.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstructorAccessorImpl.java:30)
    sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAccessorImpl.java:27)
    java.lang.reflect.Constructor.newInstance(Construc tor.java:494)
    oracle.toplink.essentials.internal.security.Privil egedAccessHelper.invokeConstructor

    (PrivilegedAccessHelper.java:311)


    oracle.toplink.essentials.internal.descriptors.Ins tantiationPolicy.buildNewInstanceUsingDefaultConst ructor

    (InstantiationPolicy.java:152)
    oracle.toplink.essentials.internal.descriptors.Ins tantiationPolicy.buildNewInstance

    (InstantiationPolicy.java:127)
    oracle.toplink.essentials.internal.descriptors.Obj ectBuilder.buildNewInstance(ObjectBuilder.java:340 )
    oracle.toplink.essentials.descriptors.copying.Inst antiationCopyPolicy.buildClone

    (InstantiationCopyPolicy.java:53)
    oracle.toplink.essentials.internal.descriptors.Obj ectBuilder.buildBackupClone(ObjectBuilder.java:313 )
    oracle.toplink.essentials.descriptors.changetracki ng.DeferredChangeDetectionPolicy.buildBackupClone

    (DeferredChangeDetectionPolicy.java:179)
    oracle.toplink.essentials.internal.sessions.UnitOf WorkImpl.populateAndRegisterObject

    (UnitOfWorkImpl.java:2853)
    oracle.toplink.essentials.internal.sessions.UnitOf WorkImpl.cloneAndRegisterObject(UnitOfWorkImpl.jav a:689)
    oracle.toplink.essentials.internal.sessions.UnitOf WorkIdentityMapAccessor.getAndCloneCacheKeyFromPar ent

    (UnitOfWorkIdentityMapAccessor.java:168)
    oracle.toplink.essentials.internal.sessions.UnitOf WorkIdentityMapAccessor.getFromIdentityMap

    (UnitOfWorkIdentityMapAccessor.java:106)
    oracle.toplink.essentials.internal.sessions.Identi tyMapAccessor.getFromIdentityMap

    (IdentityMapAccessor.java:311)
    oracle.toplink.essentials.internal.sessions.UnitOf WorkImpl.registerExistingObject

    (UnitOfWorkImpl.java:3091)
    oracle.toplink.essentials.internal.sessions.UnitOf WorkImpl.registerExistingObject

    (UnitOfWorkImpl.java:3040)
    oracle.toplink.essentials.internal.sessions.UnitOf WorkImpl.registerExistingObject

    (UnitOfWorkImpl.java:3060)
    oracle.toplink.essentials.mappings.ObjectReference Mapping.buildCloneForPartObject

    (ObjectReferenceMapping.java:87)
    oracle.toplink.essentials.internal.indirection.NoI ndirectionPolicy.cloneAttribute

    (NoIndirectionPolicy.java:81)
    oracle.toplink.essentials.mappings.ForeignReferenc eMapping.buildClone(ForeignReferenceMapping.java:1 34)
    oracle.toplink.essentials.internal.descriptors.Obj ectBuilder.populateAttributesForClone

    (ObjectBuilder.java:2175)
    oracle.toplink.essentials.internal.sessions.UnitOf WorkImpl.populateAndRegisterObject

    (UnitOfWorkImpl.java:2852)
    oracle.toplink.essentials.internal.sessions.UnitOf WorkImpl.cloneAndRegisterObject(UnitOfWorkImpl.jav a:689)
    oracle.toplink.essentials.internal.sessions.UnitOf WorkIdentityMapAccessor.getAndCloneCacheKeyFromPar ent

    (UnitOfWorkIdentityMapAccessor.java:168)
    oracle.toplink.essentials.internal.sessions.UnitOf WorkIdentityMapAccessor.getFromIdentityMap

    (UnitOfWorkIdentityMapAccessor.java:106)
    oracle.toplink.essentials.internal.sessions.Identi tyMapAccessor.getFromIdentityMap

    (IdentityMapAccessor.java:311)
    oracle.toplink.essentials.internal.sessions.UnitOf WorkImpl.registerExistingObject

    (UnitOfWorkImpl.java:3091)
    oracle.toplink.essentials.internal.sessions.UnitOf WorkImpl.registerExistingObject

    (UnitOfWorkImpl.java:3040)
    oracle.toplink.essentials.queryframework.ObjectBui ldingQuery.registerIndividualResult

    (ObjectBuildingQuery.java:335)
    oracle.toplink.essentials.internal.descriptors.Obj ectBuilder.buildWorkingCopyCloneNormally

    (ObjectBuilder.java:457)
    oracle.toplink.essentials.internal.descriptors.Obj ectBuilder.buildObjectInUnitOfWork

    (ObjectBuilder.java:422)
    oracle.toplink.essentials.internal.descriptors.Obj ectBuilder.buildObject(ObjectBuilder.java:388)
    oracle.toplink.essentials.queryframework.ReportQue ryResult.processItem(ReportQueryResult.java:221)
    oracle.toplink.essentials.queryframework.ReportQue ryResult.buildResult(ReportQueryResult.java:183)
    oracle.toplink.essentials.queryframework.ReportQue ryResult.<init>(ReportQueryResult.java:99)
    oracle.toplink.essentials.queryframework.ReportQue ry.buildObject(ReportQuery.java:595)
    oracle.toplink.essentials.queryframework.ReportQue ry.buildObjects(ReportQuery.java:644)
    oracle.toplink.essentials.queryframework.ReportQue ry.executeDatabaseQuery(ReportQuery.java:792)
    oracle.toplink.essentials.queryframework.DatabaseQ uery.execute(DatabaseQuery.java:629)
    oracle.toplink.essentials.queryframework.ObjectLev elReadQuery.execute(ObjectLevelReadQuery.java:693)
    oracle.toplink.essentials.queryframework.ObjectLev elReadQuery.executeInUnitOfWork

    (ObjectLevelReadQuery.java:747)
    oracle.toplink.essentials.internal.sessions.UnitOf WorkImpl.internalExecuteQuery(UnitOfWorkImpl.java: 2235)
    oracle.toplink.essentials.internal.sessions.Abstra ctSession.executeQuery(AbstractSession.java:953)
    oracle.toplink.essentials.internal.sessions.Abstra ctSession.executeQuery(AbstractSession.java:925)
    oracle.toplink.essentials.internal.ejb.cmp3.base.E JBQueryImpl.executeReadQuery(EJBQueryImpl.java:362 )
    oracle.toplink.essentials.internal.ejb.cmp3.base.E JBQueryImpl.getResultList(EJBQueryImpl.java:469)
    org.springframework.orm.jpa.JpaTemplate$9.doInJpa( JpaTemplate.java:313)
    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:20)
    org.springframework.web.servlet.mvc.AbstractContro ller.handleRequest(AbstractController.java:153)
    org.springframework.web.servlet.mvc.SimpleControll erHandlerAdapter.handle

    (SimpleControllerHandlerAdapter.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:461)
    org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:416)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:689)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)

  • #2
    It helps browsing the forum first, before posting :
    http://forum.springframework.org/showthread.php?t=30434

    Comment


    • #3
      Originally posted by Andrei Stefan View Post
      It helps browsing the forum first, before posting :
      http://forum.springframework.org/showthread.php?t=30434
      Nice to get your reply. I did read the link you post (see following). But I can't figure it out. Especially I don't know where andhow to set the parameter.


      **********************
      Well, finally got it to work.

      Trick is to use InstrumentationLoadTimeWeaver along with the following parameter:
      -javaagent:<path-to-spring>\dist\weavers\spring-agent.jar

      Many thanks ghofmann for helping me figure it out. I owe you one!

      Paul

      Comment


      • #4
        http://static.springframework.org/sp...a-setup-lcemfb

        Comment


        • #5
          I've tried change the SimpleLoadTimeWeaver to InstrumentationLoadTimeWeaver. But I got the following error as I deploy my war (TestSpringJpa.war) onto Tomcat.

          -------
          05.06.2007 05:43:23 org.apache.commons.modeler.Registry registerComponent
          SCHWERWIEGEND: Null component Catalina:type=JspMonitor,name=jsp,WebModule=//loca
          lhost/TestSpringJpa,J2EEApplication=none,J2EEServer=none

          -------

          Besides, in Pauls message he said he used the parameter "-javaagent:<path-to-spring>\dist\weavers\spring-agent.jar". What does this mean? I use maven and set all the dependend jars with or inside <dependency/>. Since the spring.jar contains the class "InstrumentationLoadTimeWeaver", I haven't used the spring-agent.jar. It should be ok, right?
          Last edited by thomas2004; Jun 4th, 2007, 11:59 PM.

          Comment

          Working...
          X