2 Replies Latest reply on Jul 2, 2012 2:39 AM by Martin Book

    @NotFound with archetype jboss-javaee6-webapp

    Martin Book Newbie

      Hello,

       

      my Code from archetype jboss-javaee6-webapp caused  "javax.persistence.EntityNotFoundException". To prevent this i added @NotFound Annotation to my @ManyToOne Parameter

       

       @ManyToOne(optional=true)
       @JoinColumn(name="ORGEINHEIT", insertable=false,updatable=false)
       @NotFound(action=NotFoundAction.IGNORE)  
       public KUserOrgeinheit getkUserOrgeinheit()
      
      

       

      Because Hiberante.Annotations.jar was missing i added this to my POM

       

       

       <dependency>
       <groupId>org.hibernate</groupId>
       <artifactId>hibernate-annotations</artifactId>
       <version>3.5.6-Final</version>
       </dependency
      
      

       

      Now my project throws exceptions on startup

       

       

      Caused by: javax.persistence.PersistenceException: [PersistenceUnit: primary] Unable to build EntityManagerFactory
       at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
       at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889)
       at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
       at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162)
       at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85)
       at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
       at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
       ... 3 more
      Caused by: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.collection.OneToManyPersister
       at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:248)
       at org.hibernate.persister.internal.PersisterFactoryImpl.createCollectionPersister(PersisterFactoryImpl.java:196)
       at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:375)
       at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737)
       at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84)
       at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)
       ... 9 more
      Caused by: org.hibernate.HibernateException: Unable to parse order-by fragment
       at org.hibernate.sql.ordering.antlr.OrderByFragmentTranslator.render(OrderByFragmentTranslator.java:66)
       at org.hibernate.sql.Template.renderOrderByStringTemplate(Template.java:696)
       at org.hibernate.persister.collection.AbstractCollectionPersister.<init>(AbstractCollectionPersister.java:558)
       at org.hibernate.persister.collection.OneToManyPersister.<init>(OneToManyPersister.java:85)
       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.6.0_26]
       at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) [rt.jar:1.6.0_26]
       at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) [rt.jar:1.6.0_26]
       at java.lang.reflect.Constructor.newInstance(Constructor.java:513) [rt.jar:1.6.0_26]
       at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:226)
       ... 14 more
      Caused by: java.lang.ClassCastException: antlr.CommonToken cannot be cast to antlr.Token
       at antlr.CharScanner.makeToken(CharScanner.java:173)
       at org.hibernate.sql.ordering.antlr.GeneratedOrderByLexer.mIDENT(GeneratedOrderByLexer.java:238)
       at org.hibernate.sql.ordering.antlr.GeneratedOrderByLexer.nextToken(GeneratedOrderByLexer.java:138)
       at antlr.TokenBuffer.fill(TokenBuffer.java:69)
       at antlr.TokenBuffer.LA(TokenBuffer.java:80)
       at antlr.LLkParser.LA(LLkParser.java:52)
       at org.hibernate.sql.ordering.antlr.GeneratedOrderByFragmentParser.expression(GeneratedOrderByFragmentParser.java:504)
       at org.hibernate.sql.ordering.antlr.GeneratedOrderByFragmentParser.sortKey(GeneratedOrderByFragmentParser.java:325)
       at org.hibernate.sql.ordering.antlr.GeneratedOrderByFragmentParser.sortSpecification(GeneratedOrderByFragmentParser.java:241)
       at org.hibernate.sql.ordering.antlr.GeneratedOrderByFragmentParser.orderByFragment(GeneratedOrderByFragmentParser.java:190)
       at org.hibernate.sql.ordering.antlr.OrderByFragmentTranslator.render(OrderByFragmentTranslator.java:60)