[ 
https://issues.apache.org/jira/browse/UIMA-6162?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Richard Eckart de Castilho updated UIMA-6162:
---------------------------------------------
    Description: 
I suspect there could be an issue in `BinaryCasSerDes`.

When deserializing the attached file `admin.ser`, I get this stack trace:
{code:java}
Caused by: java.lang.ClassCastException: class 
org.apache.uima.jcas.tcas.Annotation cannot be cast to class 
org.apache.uima.jcas.cas.Sofa (org.apache.uima.jcas.tcas.Annotation and 
org.apache.uima.jcas.cas.Sofa are in unnamed module of loader 
org.apache.catalina.loader.ParallelWebappClassLoader @4593ff34)at 
org.apache.uima.cas.impl.BinaryCasSerDes.makeSofaFromHeap(BinaryCasSerDes.java:1823)
 ~[uimaj-core-3.1.1.jar:3.1.1]at 
org.apache.uima.cas.impl.BinaryCasSerDes.getSofaFromAnnotBase(BinaryCasSerDes.java:1817)
 ~[uimaj-core-3.1.1.jar:3.1.1]at 
org.apache.uima.cas.impl.BinaryCasSerDes.createFSsFromHeaps(BinaryCasSerDes.java:1701)
 ~[uimaj-core-3.1.1.jar:3.1.1]at 
org.apache.uima.cas.impl.BinaryCasSerDes.reinit(BinaryCasSerDes.java:259) 
~[uimaj-core-3.1.1.jar:3.1.1]at 
org.apache.uima.cas.impl.BinaryCasSerDes.reinit(BinaryCasSerDes.java:328) 
~[uimaj-core-3.1.1.jar:3.1.1]at 
org.apache.uima.cas.impl.Serialization.deserializeCASComplete(Serialization.java:129)
 ~[uimaj-core-3.1.1.jar:3.1.1]{code}
 The code used to read the file before deserializing is as follows:
{code:java}
    public static void readSerializedCas(CAS aCas, File aFile)
        throws IOException
    {
        try (ObjectInputStream is = new ObjectInputStream(new 
FileInputStream(aFile))) {
            CASCompleteSerializer serializer = (CASCompleteSerializer) 
is.readObject();
            deserializeCASComplete(serializer, (CASImpl) aCas);
        }
        catch (ClassNotFoundException e) {
            throw new IOException(e);
        }
    }
{code}
I set a breakpoint to BinaryCasSerDes:1608 which is a for loop iterating over 
the heap. Apparently, the first feature structure that is encountered is an 
annotation type which is NOT the SOFA. Then in line 1700, the deserializer 
tries to resolve the SOFA for this annotation but fails because it has not yet 
been deserialized. Eventually makeSofaFromHeap is called and checks if a SOFA 
needs to be created. It tries to look up the SOFAs ID (1) from 
csds.addr2fs.get(sofaAddr) (BinaryCasSerDes:1821) and generates a new SOFA. 
However, when the SECOND annotation is read and csds.addr2fs.get(sofaAddr) 
(BinaryCasSerDes:1821) is called again and tries to resolve the SOFA from addr 
1, it gets the previously deserialized annotation instead of the SOFA 
annotation that had been created.

As far as I can tell, the SOFA that has been implicitly created is not added to 
the csds.addr2fs map causing the above to fail in the second iteration.

Maybe I am missing something...

  was:
I suspect there could be an issue in `BinaryCasSerDes`.

When deserializing the attached file `admin.ser`, I get this stack trace:
{code:java}
Caused by: java.lang.ClassCastException: class 
org.apache.uima.jcas.tcas.Annotation cannot be cast to class 
org.apache.uima.jcas.cas.Sofa (org.apache.uima.jcas.tcas.Annotation and 
org.apache.uima.jcas.cas.Sofa are in unnamed module of loader 
org.apache.catalina.loader.ParallelWebappClassLoader @4593ff34)at 
org.apache.uima.cas.impl.BinaryCasSerDes.makeSofaFromHeap(BinaryCasSerDes.java:1823)
 ~[uimaj-core-3.1.1.jar:3.1.1]at 
org.apache.uima.cas.impl.BinaryCasSerDes.getSofaFromAnnotBase(BinaryCasSerDes.java:1817)
 ~[uimaj-core-3.1.1.jar:3.1.1]at 
org.apache.uima.cas.impl.BinaryCasSerDes.createFSsFromHeaps(BinaryCasSerDes.java:1701)
 ~[uimaj-core-3.1.1.jar:3.1.1]at 
org.apache.uima.cas.impl.BinaryCasSerDes.reinit(BinaryCasSerDes.java:259) 
~[uimaj-core-3.1.1.jar:3.1.1]at 
org.apache.uima.cas.impl.BinaryCasSerDes.reinit(BinaryCasSerDes.java:328) 
~[uimaj-core-3.1.1.jar:3.1.1]at 
org.apache.uima.cas.impl.Serialization.deserializeCASComplete(Serialization.java:129)
 ~[uimaj-core-3.1.1.jar:3.1.1]{code}
I set a breakpoint to BinaryCasSerDes:1608 which is a for loop iterating over 
the heap. Apparently, the first feature structure that is encountered is an 
annotation type which is NOT the SOFA. Then in line 1700, the deserializer 
tries to resolve the SOFA for this annotation but fails because it has not yet 
been deserialized. Eventually makeSofaFromHeap is called and checks if a SOFA 
needs to be created. It tries to look up the SOFAs ID (1) from 
csds.addr2fs.get(sofaAddr) (BinaryCasSerDes:1821) and generates a new SOFA. 
However, when the SECOND annotation is read and csds.addr2fs.get(sofaAddr) 
(BinaryCasSerDes:1821) is called again and tries to resolve the SOFA from addr 
1, it gets the previously deserialized annotation instead of the SOFA 
annotation that had been created.

 The code used to read the file before deserializing is as follows:
{code:java}
    public static void readSerializedCas(CAS aCas, File aFile)
        throws IOException
    {
        try (ObjectInputStream is = new ObjectInputStream(new 
FileInputStream(aFile))) {
            CASCompleteSerializer serializer = (CASCompleteSerializer) 
is.readObject();
            deserializeCASComplete(serializer, (CASImpl) aCas);
        }
        catch (ClassNotFoundException e) {
            throw new IOException(e);
        }
    }
{code}


> Sofa not found when deserializing CAS
> -------------------------------------
>
>                 Key: UIMA-6162
>                 URL: https://issues.apache.org/jira/browse/UIMA-6162
>             Project: UIMA
>          Issue Type: Bug
>          Components: UIMA
>    Affects Versions: 3.1.1SDK
>            Reporter: Richard Eckart de Castilho
>            Priority: Major
>         Attachments: admin.ser
>
>
> I suspect there could be an issue in `BinaryCasSerDes`.
> When deserializing the attached file `admin.ser`, I get this stack trace:
> {code:java}
> Caused by: java.lang.ClassCastException: class 
> org.apache.uima.jcas.tcas.Annotation cannot be cast to class 
> org.apache.uima.jcas.cas.Sofa (org.apache.uima.jcas.tcas.Annotation and 
> org.apache.uima.jcas.cas.Sofa are in unnamed module of loader 
> org.apache.catalina.loader.ParallelWebappClassLoader @4593ff34)at 
> org.apache.uima.cas.impl.BinaryCasSerDes.makeSofaFromHeap(BinaryCasSerDes.java:1823)
>  ~[uimaj-core-3.1.1.jar:3.1.1]at 
> org.apache.uima.cas.impl.BinaryCasSerDes.getSofaFromAnnotBase(BinaryCasSerDes.java:1817)
>  ~[uimaj-core-3.1.1.jar:3.1.1]at 
> org.apache.uima.cas.impl.BinaryCasSerDes.createFSsFromHeaps(BinaryCasSerDes.java:1701)
>  ~[uimaj-core-3.1.1.jar:3.1.1]at 
> org.apache.uima.cas.impl.BinaryCasSerDes.reinit(BinaryCasSerDes.java:259) 
> ~[uimaj-core-3.1.1.jar:3.1.1]at 
> org.apache.uima.cas.impl.BinaryCasSerDes.reinit(BinaryCasSerDes.java:328) 
> ~[uimaj-core-3.1.1.jar:3.1.1]at 
> org.apache.uima.cas.impl.Serialization.deserializeCASComplete(Serialization.java:129)
>  ~[uimaj-core-3.1.1.jar:3.1.1]{code}
>  The code used to read the file before deserializing is as follows:
> {code:java}
>     public static void readSerializedCas(CAS aCas, File aFile)
>         throws IOException
>     {
>         try (ObjectInputStream is = new ObjectInputStream(new 
> FileInputStream(aFile))) {
>             CASCompleteSerializer serializer = (CASCompleteSerializer) 
> is.readObject();
>             deserializeCASComplete(serializer, (CASImpl) aCas);
>         }
>         catch (ClassNotFoundException e) {
>             throw new IOException(e);
>         }
>     }
> {code}
> I set a breakpoint to BinaryCasSerDes:1608 which is a for loop iterating over 
> the heap. Apparently, the first feature structure that is encountered is an 
> annotation type which is NOT the SOFA. Then in line 1700, the deserializer 
> tries to resolve the SOFA for this annotation but fails because it has not 
> yet been deserialized. Eventually makeSofaFromHeap is called and checks if a 
> SOFA needs to be created. It tries to look up the SOFAs ID (1) from 
> csds.addr2fs.get(sofaAddr) (BinaryCasSerDes:1821) and generates a new SOFA. 
> However, when the SECOND annotation is read and csds.addr2fs.get(sofaAddr) 
> (BinaryCasSerDes:1821) is called again and tries to resolve the SOFA from 
> addr 1, it gets the previously deserialized annotation instead of the SOFA 
> annotation that had been created.
> As far as I can tell, the SOFA that has been implicitly created is not added 
> to the csds.addr2fs map causing the above to fail in the second iteration.
> Maybe I am missing something...



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to