I've beenthe proof but ... nothing.
I've made needed changes in order to return a List, but i received
always
"Type '[Ljava.lang.Object;' was not included in the set of types which
can be serialized by this SerializationPolicy or its Class object
could not be loaded. For security purposes, this type will not be
serialized.".
My scenario:
1) GWT 1.5 MILESTONE 1
2) GWT SERVER LIBRARY
3) GWT-EXT (not important)
3) SPRING 2.52
4) Hibernate (as spring - dependency)
5) Hibernate annotation
6) Hibernate4gwt
I run the app in hosted-mode, but in a external tomcat server (it's
very helpful in debug).
In my web-xml i splitted my conf, and the relevant file are follows:
1) Contents of applicationContextDataSource.xml:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property
name="driverClassName"><value>oracle.jdbc.driver.OracleDriver</value></
property>
<property name="url"><value>jdbc:oracle:thin:@localhost:1521:MYSID</
value></property>
<property name="username" value="myuser" />
<property name="password" value="mypass" />
<property name="initialSize" value="5" />
<property name="maxActive" value="10" />
</bean>
<bean id = "hibernateTemplate" class =
"org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id = "sessionFactory" class =
"org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref = "dataSource" />
<property name="configLocation">
<value>/WEB-INF/hibernate.cfg.xml</value>
</property>
<property name="configurationClass">
<value>org.hibernate.cfg.AnnotationConfiguration</value>
</property>
<property name = "hibernateProperties">
<props>
<prop
key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
</props>
</property>
</bean>
2) Contents of applicationContextDomain.xml:
<bean id="anagraficheService" class =
"com.mycompany.students.AnagraficheServiceImpl">
<property name="sessionFactory">
<ref bean = "sessionFactory" />
</property>
<property name="hibernateManager">
<ref bean="hibernateBeanManager" />
</property>
</bean>
<bean id="hibernateBeanManager"
class="net.sf.hibernate4gwt.core.HibernateBeanManager">
<property name="pojoStore" ref="pojoStore" />
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="pojoStore"
class="net.sf.hibernate4gwt.core.store.stateless.StatelessPojoStore" /
>
3) My hibernate.cfg.xml looks like this:
<hibernate-configuration>
<session-factory>
<mapping class="com.mycompany.students.domain.Anagrafiche"/>
</session-factory>
</hibernate-configuration>
Next, my hibernate pojo class Anagrafiche (located in domain package)
extends LazyGwtPojo.
In the client package, i've AnagraficheService interface thats look
like this:
public interface AnagraficheService extends RemoteService {
public static final String SERVICE_URI = "../../MyService/
AnagraficheService";
//public String findByCodiceFiscale(String codicefiscale);
List <Anagrafiche> findAllByCodIstatRes(String codistatres);
public static class Util {
public static AnagraficheServiceAsync getInstance() {
AnagraficheServiceAsync instance = (AnagraficheServiceAsync)
GWT.create(AnagraficheService.class);
ServiceDefTarget target = (ServiceDefTarget) instance;
target.setServiceEntryPoint(GWT.getModuleBaseURL() + SERVICE_URI);
return instance;
}
}
}
I've vrited a simple method findAllByCodIstatRes thats return a list
of type <Anagrafiche> (hib. pojo);
In the implementation, under server package, i've:
public class AnagraficheServiceImpl extends HibernateRemoteService
implements AnagraficheService
/*
...
*/
public List<Anagrafiche> findAllByCodIstatRes(String codistatres)
{
Query qry =
this.sessionFactory.openSession().createSQLQuery("SELECT * FROM
Anagrafiche WHERE COD_ISTAT_RES='" + codistatres + "'");
return qry.list();
}
where private local variable sessionFactory is injected at
configuration level by spring servlet, when tomcat runs; in fact
within
AnagraficheServiceImpl i've implemented a method called
setSessionFactory where spring (via IoC) sets the local variable at
startup.
I believe that follow all needed steps published under "getting
started" link at hibernate4gwt site, but i got always same error.
My full stack trace:
GRAVE: Exception while dispatching incoming RPC call
java.lang.RuntimeException:
com.google.gwt.user.client.rpc.SerializationException:
java.lang.reflect.InvocationTargetException
at
org.gwtwidgets.server.spring.GWTRPCServiceExporter.handleExporterProcessingException(GWTRPCServiceExporter.java:
368)
at
org.gwtwidgets.server.spring.GWTRPCServiceExporter.processCall(GWTRPCServiceExporter.java:
337)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:
85)
at
org.gwtwidgets.server.spring.GWTRPCServiceExporter.handleRequest(GWTRPCServiceExporter.java:
386)
at
org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:
49)
at
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:
874)
at
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:
808)
at
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:
523)
at
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:
463)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:
290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:
233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:
175)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:
128)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:
102)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:
109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
286)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:
844)
at org.apache.coyote.http11.Http11Protocol
$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:
447)
at java.lang.Thread.run(Unknown Source)
Caused by: com.google.gwt.user.client.rpc.SerializationException:
java.lang.reflect.InvocationTargetException
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeWithCustomSerializer(ServerSerializationStreamWriter.java:
660)
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeImpl(ServerSerializationStreamWriter.java:
624)
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:
558)
at
com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:
82)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter
$ValueWriter$8.write(ServerSerializationStreamWriter.java:89)
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:
473)
at com.google.gwt.user.server.rpc.RPC.encodeResponse(RPC.java:573)
at
com.google.gwt.user.server.rpc.RPC.encodeResponseForSuccess(RPC.java:
441)
at
org.gwtwidgets.server.spring.GWTRPCServiceExporter.invokeMethodOnService(GWTRPCServiceExporter.java:
158)
at
org.gwtwidgets.server.spring.GWTRPCServiceExporter.processCall(GWTRPCServiceExporter.java:
316)
... 21 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeWithCustomSerializer(ServerSerializationStreamWriter.java:
645)
... 30 more
Caused by: com.google.gwt.user.client.rpc.SerializationException: Type
'[Ljava.lang.Object;' was not included in the set of types which can
be serialized by this SerializationPolicy or its Class object could
not be loaded. For security purposes, this type will not be
serialized.
at
com.google.gwt.user.server.rpc.impl.StandardSerializationPolicy.validateSerialize(StandardSerializationPolicy.java:
83)
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:
556)
at
com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:
82)
at
com.google.gwt.user.client.rpc.core.java.util.ArrayList_CustomFieldSerializer.serialize(ArrayList_CustomFieldSerializer.java:
43)
... 35 more
Please help me!!!
Best regards
On 7 Mag, 10:40, EugeneS <
Eugene.Sa...@gmail.com> wrote:
> Hello.
> In your example you should return a String object (on server side).
> You should use a List object (on server side and on client side) if
> you want to work with lists.
> You said that you use hibernate4gwt. So you can simplify you work:
> look athttp://
hibernate4gwt.sourceforge.net/getting_started.html