-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate Search - String @DocumentId throws exception
PostPosted: Wed Jun 23, 2010 3:34 am 
Newbie

Joined: Sat Apr 19, 2008 7:58 am
Posts: 14
Hi folks,

been trying to find out whats the problem for two days now, but still no progress..

I have the following issue:

I use a class with a String @Id (login) and want to index it with Lucene. However when em.persist(entity) is called I get a rollback exception.

So this is the code:

Account.class

Code:
@Entity
@Indexed(index="account")
public class Account implements Serializable {
   
   private static final long serialVersionUID = 2783056607558816506L;
   
   private String _login;
   private String _password;
   private String _firstName;   
   private String _lastName;
   private String _registrationToken;
   
   private List<Contact> _contact;
   private AccountStatus _status;   
   private Locale   _preferedLocale;
   private Sex      _sex;
   private Date   _birthDay;
      
   private Set<Role> _roles;   
   private List<ProfileContentMeta> _profile_image_list;
   
   public Account() {}
   
   public Account(String p_login, String p_password, String p_firstName, String p_lastName, Sex p_sex, Date p_birthDay, Locale p_preferredLocale) {
      super();
      setLogin(p_login);
      setPassword(p_password);
      setFirstName(p_firstName);
      setLastName(p_lastName);
      setSex(p_sex);
      setBirthDay(p_birthDay);
      setAccountStatus(AccountStatus.RESERVATION);      
      setPreferredLocale(p_preferredLocale);      
   }
      
   @VO @Id
   public String getLogin() {return _login;}
   public void setLogin(String p_login) {_login = p_login;}

...


The manager class:

Code:

public commons.vo.account.Account prepareAccountCreation(String p_login, String p_password, String p_firstName, String p_lastName, Sex p_sex, Date p_birthDay, String p_email, String p_street, String p_city, String p_country, String p_houseNumber, String p_PLZ, Locale p_preferredLocale) {
       if (p_login == null)
          return null;
       else {          
          Account m_acc = _em.find(Account.class, p_login);
          if (m_acc != null)
             return (commons.vo.account.Account) VOBuilder.buildVO(m_acc);
          else {
             m_acc = new Account(p_login, encodeMd5Hex(p_password), p_firstName, p_lastName, p_sex, p_birthDay, p_preferredLocale);
             Contact m_contact = new Contact(m_acc, p_email, p_street, p_city, p_country, p_houseNumber, p_PLZ);
             
             m_acc.setRegistrationToken(TokenFactory.createToken(m_acc.getLogin()));                                       
             m_acc.setContact(m_contact);
             m_acc.setAccountStatus(AccountStatus.RESERVATION);
                          
             _em.persist(m_acc);                       
             log(Severity.FINE, "Account reserved: {0}.", m_acc.getLogin());
             
             _maintenanceManager.scheduleAccountReservationMaintenance(m_acc);                               
             
             return (commons.vo.account.Account) VOBuilder.buildVO(m_acc);
          }
       }
    }



The exception:

Code:
[#|2010-06-22T23:53:55.583+0200|WARNING|glassfishv3.0|javax.enterprise.system.core.transaction.com.sun.jts.jta|_ThreadID=27;_ThreadName=Thread-1;|JTS5054: Unexpected error occurred in after completion
javax.persistence.PersistenceException: java.lang.UnsupportedOperationException
   at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:1071)
   at com.sun.jts.jta.SynchronizationImpl.before_completion(SynchronizationImpl.java:99)
   at com.sun.jts.CosTransactions.RegisteredSyncs.distributeBefore(RegisteredSyncs.java:158)
   at com.sun.jts.CosTransactions.TopCoordinator.beforeCompletion(TopCoordinator.java:2548)
   at com.sun.jts.CosTransactions.CoordinatorTerm.commit(CoordinatorTerm.java:278)
   at com.sun.jts.CosTransactions.TerminatorImpl.commit(TerminatorImpl.java:251)
   at com.sun.jts.CosTransactions.CurrentImpl.commit(CurrentImpl.java:623)
   at com.sun.jts.jta.TransactionManagerImpl.commit(TransactionManagerImpl.java:318)
   at com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate.commitDistributedTransaction(JavaEETransactionManagerJTSDelegate.java:169)
   at com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.commit(JavaEETransactionManagerSimplified.java:843)
   at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:4991)
   at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4756)
   at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1955)
   at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1906)
   at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:208)
   at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:75)
   at $Proxy262.prepareAccountCreation(Unknown Source)
...
Caused by: java.lang.UnsupportedOperationException
   at java.util.AbstractList.add(AbstractList.java:131)
   at java.util.AbstractList.add(AbstractList.java:91)
   at org.hibernate.search.backend.WorkQueue.add(WorkQueue.java:59)
   at org.hibernate.search.backend.impl.BatchedQueueingProcessor.add(BatchedQueueingProcessor.java:128)
   at org.hibernate.search.backend.impl.PostTransactionWorkQueueSynchronization.add(PostTransactionWorkQueueSynchronization.java:62)
   at org.hibernate.search.backend.impl.TransactionalWorker.performWork(TransactionalWorker.java:73)
   at org.hibernate.search.event.FullTextIndexEventListener.processWork(FullTextIndexEventListener.java:178)
   at org.hibernate.search.event.FullTextIndexEventListener.processCollectionEvent(FullTextIndexEventListener.java:225)
   at org.hibernate.search.event.FullTextIndexEventListener.onPostRecreateCollection(FullTextIndexEventListener.java:195)
   at org.hibernate.action.CollectionRecreateAction.postRecreate(CollectionRecreateAction.java:93)
   at org.hibernate.action.CollectionRecreateAction.execute(CollectionRecreateAction.java:66)
   at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:268)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:260)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:183)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:375)
   at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:1057)
   ... 73 more


The following is what I found out:

1. It works on Hibernate Search release I had from last year but is not running on Hibernate Search 3.2
2. If I index/store a class with @Id as integer it works just fine

My classpath looks like this:

Image

Uploaded with ImageShack.us

Thanks a lot! Any ideas/discussions would be appriciated!


Top
 Profile  
 
 Post subject: Re: Hibernate Search - String @DocumentId throws exception
PostPosted: Thu Jun 24, 2010 7:42 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

I quickly changed one of our unit tests to use a String as id and it works fine. So I don't think this alone is the problem. Are you saying that if you change the login property from String to Integer works?

What I don't understand is
Code:
Caused by: java.lang.UnsupportedOperationException
   at java.util.AbstractList.add(AbstractList.java:131)
   at java.util.AbstractList.add(AbstractList.java:91)


org.hibernate.search.backend.WorkQueue uses internally a ArrayList to hold the queue, so I don't understand how add on AbstractList gets called. Looking at the stack trace it seems the error occurs in a glassfish container. Can you reproduce the problem in a unit tests?
I would also check all dependencies including shared lib directories and I would also delete all tmp and work directories. Ahh, and remove the hibernate3.jar. hibernate-core-3.5.1.jar is the latest Core version. It might be that this is the root of your problem.

--Hardy


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

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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.