<div dir="ltr">Hi Alessandro, this kind of question is better suited for the forums [1], since this list if for development related discussions.<div><br></div><div>But since we're here, regarding your question:</div><div><br></div><div>What's probably happening is that since you are creating a cache inside the servlet from the cache manager that is also used by the Infinispan server, </div><div>this cache is internally being created with an encoding scheme suitable to used for remote clients, meaning storage will be POJO but reads/writes will </div><div>be done using byte[].</div><div><br></div><div>In Infinispan 9.1.0 you can choose the encoding to read and write from a particular cache: so in your case, from you servlet, you can specify that you don't want </div><div>any encoding by wrapping your cache with:</div><div><br></div><div>Cache c = cache.getAdvancedCache().withEncoding(IdentityEncoder.class)</div><div><div><br></div><div>[1] <a href="http://infinispan.org/community/" target="_blank">http://infinispan.org/<wbr>community/</a></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 30, 2017 at 6:16 PM, Alessandro Vaccarezza <span dir="ltr"><<a href="mailto:avaccarezza@c2b2.co.uk" target="_blank">avaccarezza@c2b2.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-CA" link="#0563C1" vlink="#954F72">
<div class="m_-8857339091157952886WordSection1">
<p class="MsoNormal">Hi guys,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">we ar facing an issue since quite a long time and can't come up with a solution.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Our simple application is deployed on a wildfly instance and make use of a local infinispan data store (infinispan-9.1.0.Final).<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Wildfly resides on a CentOS 6.8 instance, Java version is 1.8.0_112.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">We implemented a very basic servlet and registered as a listener. Within this servlet we use an org.infinispan.manager.<wbr>EmbeddedCacheManager to retrieve an
<u></u><u></u></p>
<p class="MsoNormal">existing cache and add values to it.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Compatibility mode is on.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">The values added to the cache are instance of a simple Java POJO.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">When we try to retrieve what we just added, within the same servlet, we get a byte array, no way to retrieve the original POJO.<u></u><u></u></p>
<p class="MsoNormal">When we force the cast we get the obvious:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><b>java.lang.ClassCastException: [B cannot be cast to com.my.pojo.SamplePOJO
<u></u><u></u></b></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Servlet: <a href="https://gist.github.com/anonymous/e8752cc8457301c2c70b3255e5c3bbc5" target="_blank">https://gist.github.com/<wbr>anonymous/<wbr>e8752cc8457301c2c70b3255e5c3bb<wbr>c5</a><u></u><u></u></p>
<p class="MsoNormal">POJO: <a href="https://gist.github.com/anonymous/f35900875500a4bd6b4bb3b0cf73a363" target="_blank">https://gist.github.com/<wbr>anonymous/<wbr>f35900875500a4bd6b4bb3b0cf73a3<wbr>63</a><u></u><u></u></p>
<p class="MsoNormal">Infinispan config file: <a href="https://gist.github.com/anonymous/b8482595f6b86ecc5642cceb6a99ad5e" target="_blank">https://gist.github.com/<wbr>anonymous/<wbr>b8482595f6b86ecc5642cceb6a99ad<wbr>5e</a><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Retrieving the cache via Hot Rod client works fine; also, if compatibility mode is turned off everything works fine as well.<u></u><u></u></p>
</div>
</div>
<br>______________________________<wbr>_________________<br>
infinispan-dev mailing list<br>
<a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/infinispan-<wbr>dev</a><br></blockquote></div><br></div>