3 Replies Latest reply on Nov 23, 2015 4:13 AM by gustavonalle

    Why am I getting "Not a mapped entity (don't forget to add @Indexed)" error after reboot

    drathnow

      I'm not entirely sure if this question should be directed at Infinispan or Hibernate. I'll tag it with both and hope fully someone can give me some ideas.  I'm using JBoss EAP 6.2 with Infinispan 6.0.2

       

      My application and stores entities in an Infinispan cache that is persisted to a FileStore.  The entity is actual an extended entity.  The parent entity looks like this:

       

      @Indexed(index = "OutputRequestIndex")

      public class OutgoingRequest implements Serializable {

          private static final long serialVersionUID = 1001L;

        

          @Field

          private String requestId;

          @Field

          private Long eventId;

          @Field

          @FieldBridge(impl = SiteAddressFieldBridge.class)

          private SiteAddress siteAddress;

       

          private Long creationTime;

          private boolean cancelled;

          private int sendAttempts;

          private Long lastSendAttempt;

          private String lastStatusMessage;

          private ControlStatus status;

          private OutgoingRequestType outgoingRequestType;

       

          public OutgoingRequest() {

          }

       

          protected OutgoingRequest(SiteAddress siteAddress, Long eventId, OutgoingRequestType type) {

              this.eventId = eventId;

              this.siteAddress = siteAddress;

              this.outgoingRequestType = type;

              this.creationTime = System.currentTimeMillis();

              this.requestId = UUID.randomUUID().toString();

              this.status = ControlStatus.PENDING;

              this.lastStatusMessage = "<none>";

          }

       

          public boolean hasExpired(Long expirationMinutes) {

              return (System.currentTimeMillis() - creationTime) > TimeUnit.MINUTES.toMillis(expirationMinutes);

          }

       

          public Long getLastSendAttempt() {

              return lastSendAttempt;

          }

        

          public String getLastStatusMessage() {

              return lastStatusMessage;

          }

        

          public Integer getSendAttempts() {

              return sendAttempts;

          }

        

          public ControlStatus getStatus() {

              return status;

          }

       

          public void setStatus(ControlStatus status) {

              this.status = status;

          }

       

          public OutgoingRequestType getType() {

              return outgoingRequestType;

          }

       

          public void cancel() {

              cancelled = true;

          }

       

          public boolean isCancelled() {

              return cancelled;

          }

       

          public String getRequestId() {

              return requestId;

          }


          public Long getCreationTime() {

              return creationTime;

          }

       

          public Long getEventId() {

              return eventId;

          }

       

          public SiteAddress getSiteAddress() {

              return siteAddress;

          }

        

          public void setLastStatusMessage(String lastStatusMessage) {

              this.lastStatusMessage = lastStatusMessage;

          }

      }

       

      And the derived class looks like this:

       

      @Indexed(index="ControlRequestIndex")

      public class ControlRequest extends OutgoingRequest implements Serializable {

          private static final long serialVersionUID = 1001L;

          private Control control;

         

          public ControlRequest(SiteAddress siteAddress, Long eventId, Control control) {

              super(siteAddress, eventId, OutgoingRequestType.CONTROL);

              this.control = control;

          }

         

          public Control getControl() {

              return control;

          }

      }


      For the most part, things work fine.  Control requests arrive at my app via JMS, I create ControlRequest object, squirrel them away in my Infinispan cache, Infinispan stores them in a FileStore and everything works great. I have a cache listener that processes requests when they are stored in the cache. I can restart my app and stored requests are restored to the cache. I generally pull requests from the cache via their requesteId but also use Lucene search to find entities via their siteAddress field:


              SearchManager searchManager = Search.getSearchManager(outgoingRequestCache);

              QueryBuilder queryBuilder = searchManager.buildQueryBuilderForClass(OutgoingRequest.class).get();

             

              Query luceneQuery = queryBuilder

                                      .keyword()

                                      .onField("siteAddress")

                                      .matching(siteAddress)

                                      .createQuery();

             

              Collection<OutgoingRequest> values = outgoingRequestCache.values();

             

              CacheQuery query = searchManager.getQuery(luceneQuery, OutgoingRequest.class);

              List<? extends Object> list = query.list();

              return (Collection<OutgoingRequest>)list;


      Like I say, things seem to work fine.  But lately, I ran into a problem when my application had been running for a couple of weeks and everything stopped working.  The searches would return nothing and my cache listeners were not getting invoked when new entities were inserted into the cache.  I shutdown and restart my application and go a whole mess of the following exceptions:

       

      10:50:27,953 ERROR [org.jboss.as.ejb3.invocation] (10.70.130.146/17) JBAS014134: EJB Invocation failed on component InfinispanOutgoingRequestCache for method public abstract java.util.Collection zedi.pacbridge.app.controls.OutgoingRequestCache.outgoingRequestsForSiteAddress(zedi.pacbridge.utl.SiteAddress): javax.ejb.EJBException: org.hibernate.search.exception.SearchException: Not a mapped entity (don't forget to add @Indexed): class zedi.pacbridge.app.controls.ControlRequest

        at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:189) [jboss-as-ejb3-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

        at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:274) [jboss-as-ejb3-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

        at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:339) [jboss-as-ejb3-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

        at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:238) [jboss-as-ejb3-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

              <--- SNIP --->

        at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_79]

        at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:267) [weld-core-1.1.16.Final-redhat-1.jar:1.1.16.Final-redhat-1]

        at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52) [weld-core-1.1.16.Final-redhat-1.jar:1.1.16.Final-redhat-1]

        at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137) [weld-core-1.1.16.Final-redhat-1.jar:1.1.16.Final-redhat-1]

        at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:263) [weld-core-1.1.16.Final-redhat-1.jar:1.1.16.Final-redhat-1]

        at org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:115) [weld-core-1.1.16.Final-redhat-1.jar:1.1.16.Final-redhat-1]

        at org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:56) [weld-core-1.1.16.Final-redhat-1.jar:1.1.16.Final-redhat-1]

        at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105) [weld-core-1.1.16.Final-redhat-1.jar:1.1.16.Final-redhat-1]

        at zedi.pacbridge.app.cache.OutgoingRequestCache$OutgoingRequestCacheUpdateDelegate$-2135361606$Proxy$_$$_Weld$Proxy$.outgoingRequestsForSiteAddress(OutgoingRequestCache$OutgoingRequestCacheUpdateDelegate$-2135361606$Proxy$_$$_Weld$Proxy$.java) [pacbridge-app-6.0.0.jar:]

        at zedi.pacbridge.app.net.ConnectionManagerHelper$WorkerRunner.run(ConnectionManagerHelper.java:72) [pacbridge-app-6.0.0.jar:]

        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_79]

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_79]

        at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_79]

      Caused by: org.hibernate.search.exception.SearchException: Not a mapped entity (don't forget to add @Indexed): class zedi.pacbridge.app.controls.ControlRequest

        at org.hibernate.search.query.engine.impl.HSQueryImpl.buildSearcher(HSQueryImpl.java:574) [hibernate-search-engine-5.0.1.Final.jar:5.0.1.Final]

        at org.hibernate.search.query.engine.impl.HSQueryImpl.buildSearcher(HSQueryImpl.java:518) [hibernate-search-engine-5.0.1.Final.jar:5.0.1.Final]

        at org.hibernate.search.query.engine.impl.HSQueryImpl.queryEntityInfos(HSQueryImpl.java:252) [hibernate-search-engine-5.0.1.Final.jar:5.0.1.Final]

        at org.infinispan.query.impl.CacheQueryImpl.list(CacheQueryImpl.java:161) [infinispan-query.jar:7.1.1.Final]

        at zedi.pacbridge.app.cache.InfinispanOutgoingRequestCache.outgoingRequestsForSiteAddress(InfinispanOutgoingRequestCache.java:84) [pacbridge-app-6.0.0.jar:]

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_79]

        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_79]

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_79]

        at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_79]

        at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72) [jboss-as-ee-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]

        at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]

        at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:58) [jboss-as-ee-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]

        at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:374) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]

        at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:129) [jboss-as-weld-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

        at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:137) [jboss-as-weld-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

        at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:58) [jboss-as-ee-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]

        at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]

        at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:58) [jboss-as-ee-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]

        at org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43) [jboss-as-ejb3-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]

        at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47) [jboss-as-jpa-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]

        at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:94) [jboss-as-weld-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]

        at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]

        at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]

        at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53) [jboss-as-ee-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]

        at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51) [jboss-as-ejb3-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]

        at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:272) [jboss-as-ejb3-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

        ... 38 more

       

       

      I have a couple of questions:

       

      1. Is it okay to store a derived entity in an Infinispan cache?

      2. The ControlRequest entity clearly has a "@Indexed" annotation, so why the exception "Not a mapped entity" complaining that it's not there?