I need to iterate a List<myClass>
in a jsp. This is how I obtain the list:
(when I commented it, the page loaded just fine).
<%
List<myClass> pjList = null;
StringBuffer ejbQuery = new StringBuffer();
EntityManagerFactory emf = Persistence.createEntityManagerFactory("myPersistence");
EntityManager em = emf.createEntityManager();
ejbQuery.append("SELECT e ");
ejbQuery.append("FROM myClass e ");
pjList = em.createQuery(ejbQuery.toString()).getResultList();
for(myClass pj : pjList)
{
%>
<br />
<%= pj.getSomeField()%>
<br />
<%
}
%>
This is the error I get when running it in google appengine. locally it runs fine.
Uncaught exception from servlet
java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
at org.datanucleus.store.appengine.DatastoreFieldManager.fetchStringField(DatastoreFieldManager.java:188)
at org.datanucleus.state.AbstractStateManager.replacingStringField(AbstractStateManager.java:1180)
at ar.edu.kennedy.proveedores.entities.ProEnteEy.jdoReplaceField(ProEnteEy.java)
at ar.edu.kennedy.proveedores.entities.ProPersonaJuridicaEy.jdoReplaceField(ProPersonaJuridicaEy.java)
at ar.edu.kennedy.proveedores.entities.ProEnteEy.jdoReplaceFields(ProEnteEy.java)
at org.datanucleus.state.JDOStateManagerImpl.replaceFields(JDOStateManagerImpl.java:2772)
at org.datanucleus.state.JDOStateManagerImpl.replaceFields(JDOStateManagerImpl.java:2791)
at org.datanucleus.store.appengine.DatastorePersistenceHandler.fetchObject(DatastorePersistenceHandler.java:443)
at org.datanucleus.store.appengine.query.DatastoreQuery.entityToPojo(DatastoreQuery.java:433)
at org.datanucleus.store.appengine.query.DatastoreQuery.entityToPojo(DatastoreQuery.java:391)
at org.datanucleus.store.appengine.query.DatastoreQuery.access$800(DatastoreQuery.java:97)
at org.datanucleus.store.appengine.query.DatastoreQuery$5.apply(DatastoreQuery.java:515)
at org.datanucleus.store.appengine.query.DatastoreQuery$5.apply(DatastoreQuery.java:507)
at org.datanucleus.store.appengine.query.StreamingQueryResult.resolveNext(StreamingQueryResult.java:137)
at org.datanucleus.store.appengine.query.StreamingQueryResult$1.computeNext(StreamingQueryResult.java:163)
at org.datanucleus.store.appengine.query.AbstractIterator.tryToComputeNext(AbstractIterator.java:132)
at org.datanucleus.store.appengine.query.AbstractIterator.hasNext(AbstractIterator.java:127)
at org.datanucleus.store.appengine.query.StreamingQueryResult$AbstractListIterator.hasNext(StreamingQueryResult.java:229)
at org.apache.jsp.busqueda_jsp._jspService(busqueda_jsp.java:138)
If I use a ListIterator and call hasNext() I get the same error. Help me understand what is happening, how to solve this?