1 Reply Latest reply on Apr 29, 2012 4:24 PM by aneh

    ManyToMany read past end of file

    aneh

      Unusually I cannot find anything on the web refering to this issue so I am at a loss as to a starting point to try and understand what is going on.

       

      I am using 7.1.1.Final, Eclipse Indigo (windows), JBoss Tools 3.3.3

       

      So the situation I have two Entity Beans Activity and Resource there are two ManyToMany associations between Activity and Resource.  Prior to adding these associations the JPA archive deployed and executed as expected so I am sure (mostly) that it is the introduction of these two new associations that is causing the problem.

       

      The Activity class is the owner of both of the associations

       

      @Entity    (name="Activity")
      @Table    (name="Activity", schema="Istana")
      public class JpaActivity
          implements Activity, Serializable
      {

          private        String            m_oid;
         
          private        List<Resource>    m_consumers;
         
          private        List<Resource>    m_producers;

       

          @Column        (name="oid")
          @Id
          @Override
          public         String             getOid()
          {
              return m_oid;
          }
         
          protected    void            setOid(String oid)
          {
              m_oid = oid;
          }


          @ManyToMany    (targetEntity=JpaResource.class,cascade=CascadeType.ALL)
          @JoinTable    (name="activity_consumer_resource"
                      ,joinColumns={@JoinColumn(name="activity_oid",referencedColumnName="oid")}
                      ,inverseJoinColumns={@JoinColumn(name="resource_oid",referencedColumnName="oid")}
                      )
          @Override
          public         List<Resource>     getConsumers()
          {
              return m_consumers;
          }

       

          protected    void            setConsumers(List<Resource> consumers)
          {
              m_consumers = consumers;
          }

       

          @ManyToMany(targetEntity=JpaResource.class,cascade=CascadeType.ALL)
          @JoinTable    (name="activity_producer_resource"
                      ,joinColumns={@JoinColumn(name="activity_oid",referencedColumnName="oid")}
                      ,inverseJoinColumns={@JoinColumn(name="resource_oid",referencedColumnName="oid")}
                      )
          @Override
          public         List<Resource>     getProducers()
          {
              return m_producers;
          }

       

          protected    void            setProducers(List<Resource> producers)
          {
              m_producers = producers;
          }

      }

       

      @Entity    (name="Resource")
      @Table    (name="Resource", schema="Istana")
      abstract
      public class JpaResource
          implements Resource, Serializable
      {

       

          private        String            m_oid;
          
          private        Set<Activity>            m_consumerActivitys;
         
          private        Set<Activity>            m_producerActivitys;
         
          @Column        (name="oid")
           @Id
           @Override
           public         String             getOid()
           {
               return m_oid;
           }
          
           protected    void            setOid(String oid)
           {
               m_oid = oid;
           }

       

          @ManyToMany    (targetEntity=JpaActivity.class,fetch=FetchType.EAGER,mappedBy="consumers")
          @Override
          public         Set<Activity>         getConsumerActivitys()
          {
              return m_consumerActivitys;
          }
         
          protected    void                setConsumerActivitys(Set<Activity> consumerActivitys)
          {
              m_consumerActivitys = consumerActivitys;
          }

       

          @ManyToMany    (targetEntity=JpaActivity.class,fetch=FetchType.EAGER,mappedBy="producers")
          @Override
          public         Set<Activity>         getProducerActivitys()
          {
              return m_producerActivitys;
          }
         
          protected    void                setProducerActivitys(Set<Activity> producerActivitys)
          {
              m_producerActivitys = producerActivitys;
          }
      }

       

       

      When I attempt to execute the following "Select a FROM Activity a" I get the following stack dump

       

      Exception in thread "main" java.lang.reflect.UndeclaredThrowableException
          at $Proxy0.getActivitys(Unknown Source)
          at com.istana.schedule.session.jee.JeeManager.getActivitys(JeeManager.java:54)
          at com.istana.schedule.session.sui.ActivityPanel.init(ActivityPanel.java:45)
          at com.istana.schedule.session.sui.ActivityPanel.<init>(ActivityPanel.java:40)
          at com.istana.schedule.session.sui.Main.createPage(Main.java:34)
          at com.istana.panticon.client.sui.SuiSiteFactory.createSite(SuiSiteFactory.java:28)
          at com.istana.schedule.session.sui.Main.main(Main.java:50)
      Caused by: java.io.EOFException: Read past end of file
          at org.jboss.marshalling.SimpleDataInput.eofOnRead(SimpleDataInput.java:126)
          at org.jboss.marshalling.SimpleDataInput.readUnsignedByteDirect(SimpleDataInput.java:263)
          at org.jboss.marshalling.SimpleDataInput.readUnsignedByte(SimpleDataInput.java:224)
          at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)
          at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1677)
          at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1593)
          at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1557)
          at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1235)
          at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:272)
          at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)
          at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1677)
          at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1593)
          at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1235)
          at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:272)
          at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)
          at org.jboss.marshalling.river.RiverUnmarshaller.doReadCollectionObject(RiverUnmarshaller.java:180)
          at org.jboss.marshalling.river.RiverUnmarshaller.readCollectionData(RiverUnmarshaller.java:771)
          at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:649)
          at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)
          at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:37)
          at org.jboss.ejb.client.remoting.MethodInvocationResponseHandler$MethodInvocationResultProducer.getResult(MethodInvocationResponseHandler.java:107)
          at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:270)
          at org.jboss.ejb.client.TransactionInterceptor.handleInvocationResult(TransactionInterceptor.java:47)
          at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:272)
          at org.jboss.ejb.client.ReceiverInterceptor.handleInvocationResult(ReceiverInterceptor.java:132)
          at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:260)
          at org.jboss.ejb.client.EJBClientInvocationContext.awaitResponse(EJBClientInvocationContext.java:399)
          at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:140)
          at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)
          at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
          ... 7 more
      Caused by: an exception which occurred:
          in field storedSnapshot
          in object of type org.hibernate.collection.internal.PersistentBag
          in field m_consumers
          in object of type com.istana.schedule.feature.jpa.JpaActivity
          in element at index [0] of size [4]

       

      Note I have [4] Activity records in the database and the stack dump occurs when calling and returning the [0] Activity and presumeably the persistence manager is attempting to initialise the m_consumers field in Activity via the setConsumers() method.  The return error is "Caused by: java.io.EOFException: Read past end of file" which I assume refers to the ManyToMany association but I am unsure how this relates and/or how I can instrument the application inorder to discover what is really going on.

       

      Some pointer, hints, or scrying would be muchly appreciated.

        • 1. Re: ManyToMany read past end of file
          aneh

          It turns out I had skipped over the problem by assuming that the only change I had made was the addition of the two ManyToMany annotations.  The real cause was I also added an additional property and the class of the property was not Serializable hence the issue being expressed as an IO issue. Slightly embarassed but glad I have found the problem and hence the solution.