-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 20 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Programmatic mapping not working
PostPosted: Wed Aug 25, 2010 1:04 pm 
Beginner
Beginner

Joined: Tue Oct 07, 2008 7:05 pm
Posts: 27
I'm using this simple mapping:

Code:
mapping.entity(MyEntity.class).indexed().indexName("myentity-index")
      
.property("name", ElementType.FIELD).field().index(Index.TOKENIZED).store(Store.YES);


and I get the error "Error in programmatic mapping. Method finalize is not a property getter"

Oddly enough, when I add a "name" to the field like this:

Code:
mapping.entity(MyEntity.class).indexed().indexName("myentity-index")
   
.property("name", ElementType.FIELD).field().name("my-name").index(Index.TOKENIZED).store(Store.YES);


I get a similar error, with an entirely different field:

"Error in programmatic mapping. Method setId is not a property getter"

I'm not sure what to make of the inconsistent error messages. Note that I've explicitly tried to configure the documentId but I get an error stating there are two documentIds. Presumably, it is using the Hibernate @Id annotation to figure out the documentId.


Top
 Profile  
 
 Post subject: Re: Programmatic mapping not working
PostPosted: Thu Aug 26, 2010 4:48 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Can you post the full mapping together with the full stacktrace? Which version of Search are you using?

--Hardy


Top
 Profile  
 
 Post subject: Re: Programmatic mapping not working
PostPosted: Thu Aug 26, 2010 11:01 am 
Beginner
Beginner

Joined: Tue Oct 07, 2008 7:05 pm
Posts: 27
Sure, the full mapping is in my original post. It's as simple as that. I'm using v3.2.1.Final. I'm also using Seam and attaching the mapping by using the @Factory annotation in a factory class.

Here is the stacktrace:

Code:
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: registryDatabase] Unable to build EntityManagerFactory
   at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:900)
   at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57)
   at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:48)
   at org.jboss.seam.persistence.EntityManagerFactory.createEntityManagerFactory(EntityManagerFactory.java:85)
   at org.jboss.seam.persistence.EntityManagerFactory.startup(EntityManagerFactory.java:50)
   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 org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
   at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
   at org.jboss.seam.Component.callComponentMethod(Component.java:2257)
   at org.jboss.seam.Component.callCreateMethod(Component.java:2172)
   at org.jboss.seam.Component.newInstance(Component.java:2132)
   ... 67 more
Caused by: org.hibernate.HibernateException: could not init listeners
   at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:205)
   at org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:1396)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1385)
   at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:954)
   at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:891)
   ... 80 more
Caused by: org.hibernate.search.SearchException: Error in programmatic mapping. Method finalize is not a property getter
   at org.hibernate.search.impl.MappingModelMetadataProvider$MappingModelAnnotationReader.<init>(MappingModelMetadataProvider.java:272)
   at org.hibernate.search.impl.MappingModelMetadataProvider.getAnnotationReader(MappingModelMetadataProvider.java:119)
   at org.hibernate.annotations.common.reflection.java.JavaReflectionManager.buildAnnotationReader(JavaReflectionManager.java:222)
   at org.hibernate.annotations.common.reflection.java.JavaXAnnotatedElement.getAnnotationReader(JavaXAnnotatedElement.java:52)
   at org.hibernate.annotations.common.reflection.java.JavaXAnnotatedElement.getAnnotations(JavaXAnnotatedElement.java:64)
   at org.hibernate.validator.ClassValidator.createMemberValidator(ClassValidator.java:303)
   at org.hibernate.validator.ClassValidator.initValidator(ClassValidator.java:217)
   at org.hibernate.validator.ClassValidator.<init>(ClassValidator.java:133)
   at org.hibernate.validator.event.ValidateEventListener.initialize(ValidateEventListener.java:91)
   at org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198)
   at org.hibernate.event.EventListeners.processListeners(EventListeners.java:181)
   at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194)
   ... 84 more


Top
 Profile  
 
 Post subject: Re: Programmatic mapping not working
PostPosted: Thu Aug 26, 2010 12:30 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
How does the entity look like?


Top
 Profile  
 
 Post subject: Re: Programmatic mapping not working
PostPosted: Fri Aug 27, 2010 1:24 am 
Beginner
Beginner

Joined: Tue Oct 07, 2008 7:05 pm
Posts: 27
Here's the entity:

Code:
@Entity
@Table(name = "my-entity")
public class MyEntity implements java.io.Serializable {

   private static final long serialVersionUID = -6614950526963809113L;
   private Long id;
   private String name;

   public MyEntity() {
   }

   @Id
   @GeneratedValue(strategy=GenerationType.AUTO)
   public Long getId() {
      return this.id;
   }
   public void setId(Long id) {
      this.id = id;
   }

   @Column(name = "name", nullable = false)
   public String getName() {
      return this.name;
   }
   public void setName(String name) {
      this.name = name;
   }

}



Top
 Profile  
 
 Post subject: Re: Programmatic mapping not working
PostPosted: Fri Aug 27, 2010 5:46 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
I tried the mapping without our test harness and it seems to work. I might be missing something or there is something additional happening in your setup. Could you isolate a testcase? You can either post it here or even better create a Jira issue here

--Hardy


Top
 Profile  
 
 Post subject: Re: Programmatic mapping not working
PostPosted: Fri Aug 27, 2010 11:40 am 
Beginner
Beginner

Joined: Tue Oct 07, 2008 7:05 pm
Posts: 27
Ok, so I decided to step through the code, in particular the last method in the stacktrace:

Code:
org.hibernate.search.impl.MappingModelMetadataProvider$MappingModelAnnotationReader.<init>

What I discovered is that the process goes through *every* entity class, not just the one class I defined in my SearchMapping. I painstakingly stepped through every Class, Method and Field of my entity classes that went through that constructor. Eventually it attempts to map java.io.Serializable (also at one point, it maps java.lang.Object). When it goes through the methods of Serializable, it reaches the "finalize" method and because it doesn't start with "get" or "is" the exception occurs.

Is this expected behavior? Might this have to do with bootstrapping in Seam? Do you have a working example of programmatic mapping through Seam?

-JF


Top
 Profile  
 
 Post subject: Re: Programmatic mapping not working
PostPosted: Sat Aug 28, 2010 4:09 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
I made several of our test classes Serializable as well and could not reproduce the problem. It seems we really need a testcase.

--Hardy


Top
 Profile  
 
 Post subject: Re: Programmatic mapping not working
PostPosted: Sun Aug 29, 2010 12:17 pm 
Beginner
Beginner

Joined: Tue Oct 07, 2008 7:05 pm
Posts: 27
Are you testing this while bootstrapping the EMF through Seam? Otherwise, it seems we are comparing apples and oranges.


Top
 Profile  
 
 Post subject: Re: Programmatic mapping not working
PostPosted: Sun Aug 29, 2010 12:24 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
No, no Seam involved on my side. I basically tried to see whether there is a simple bug in Search, but it seems there is more to it. For this reason it would be great if you could provide a test case.


Top
 Profile  
 
 Post subject: Re: Programmatic mapping not working
PostPosted: Mon Aug 30, 2010 10:40 am 
Beginner
Beginner

Joined: Tue Oct 07, 2008 7:05 pm
Posts: 27
I've created a simple mavenized Seam application that demonstrates the error I'm getting. It seems I can't attach files on this forum. Can I email it to you or post it somewhere else?


Top
 Profile  
 
 Post subject: Re: Programmatic mapping not working
PostPosted: Mon Aug 30, 2010 11:58 am 
Beginner
Beginner

Joined: Tue Oct 07, 2008 7:05 pm
Posts: 27
I've created a JIRA issue and attached the test case.

http://opensource.atlassian.com/project ... SEARCH-591


Top
 Profile  
 
 Post subject: Re: Programmatic mapping not working
PostPosted: Mon Aug 30, 2010 12:06 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
I was just about to tell you to attach it to a Jira issue. Thanks.


Top
 Profile  
 
 Post subject: Re: Programmatic mapping not working
PostPosted: Mon Aug 30, 2010 12:20 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
There seems to be no test class in the project. How to I trigger the error?


Top
 Profile  
 
 Post subject: Re: Programmatic mapping not working
PostPosted: Mon Aug 30, 2010 2:52 pm 
Beginner
Beginner

Joined: Tue Oct 07, 2008 7:05 pm
Posts: 27
Oh right, that would probably be nice to know.

The error is triggered when you start Seam up in a servlet container. That's the only way I know to bootstrap Seam. If you're using Eclipse, have the m2eclipse plugin, then the project will automatically be configured as a Web Project. Then you can add a Server runtime (I'm using Tomcat) and deploy the project to that server. Then it's as simple as starting up the server (in debug mode if you want to debug).

I stepped through the H-Search code by "attaching the source" to the H-Search jar in the Maven Dependencies section.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 20 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.