GWT M1, Hibernate, H4gwt Problems

6 views
Skip to first unread message

_panic_

unread,
May 13, 2008, 11:41:40 AM5/13/08
to Google Web Toolkit
Hi all, i write for a problem having with combo described in subject.

My combo is:
1) gwtext-2.0.3
2) hibernate4gwt-1.0.4_GWT_1.5_M1
3) Hibernate and annotations
4) Spring 2.52
5) gwt-sl-0.1.4e
6) gwt-sl-java1.4

I follow all instructions for set-up gwt-sl with h4gwt, and i run my
webapp in hosted mode
browser with no embeeded server, but with another one external,
configured with eclipse.
Please, pay attention all subsequent files;
my web.xml looks like this:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/dataSource.xml
/WEB-INF/domain.xml
</param-value>
</context-param>


<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>

<servlet-mapping>
<servlet-name>dispatch</servlet-name>
<url-pattern>/MyService/*</url-pattern>
</servlet-mapping>


<servlet>
<servlet-name>dispatch</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</
servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

It's very simple: i've splitted spring context into two files.
dataSource.xml is not very important, because it contains only
datasource definition (oracle)
and the sessionfactory.
domain.xml, instead, looks like this:

<bean id = "usersService" class =
"it.unipa.studenti.server.UsersServiceImpl">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>

<bean id="HB4GWTRPCService"
class="org.gwtwidgets.server.spring.hb4gwt.HB4GWTRPCServiceExporter">
<property name="service" ref="usersService" />
<property name="beanManager" ref="hibernateBeanManager" />
</bean>

<bean name = "hibernateBeanManager" 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" /
>


As you can see, i link HB4GWTRPCServiceExporter with the bean
usersService; i read, in fact, that the HB4GWTRPCServiceExporter is
very similar to GWTRpcServiceExporter.
After, my dispatch-servlet.xml looks like this:

<bean id="urlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<map>
<entry key="/UsersService" value-ref="HB4GWTRPCService" />

</map>
</property>
</bean>

About hibernate configuration, i 've a hibernate.cfg.xml that maps the
class Users with
a table users stored in an oracle database.

This is my configuration.
The source code is very very simple: there is a hibernate pojo, stored
in "domain" package (using annotations) like this:
@Entity()
@Table(name="Users")
public class Users implements Serializable
{

private static final long serialVersionUID = -4680774191483580337L;
/*private vars, getters and setters methods;
the types are only String and Long
*/
}

In "client" package i've the UserService interface (and relative
async); the UserService interface is:
public interface UsersService extends RemoteService
{

public static final String SERVICE_URI = "../../MyService/
UsersService";
public List<Users> findAll();
public static class Util {

public static UsersServiceAsync getInstance() {

UsersServiceAsync instance = (UsersServiceAsync)
GWT.create(UsersService.class);
ServiceDefTarget target = (ServiceDefTarget) instance;
target.setServiceEntryPoint(GWT.getModuleBaseURL() + SERVICE_URI);
return instance;
}
}

}


Finally, under "server" package, there is the implementations:
public class UsersServiceImpl implements UsersService
{

private SessionFactory sessionFactory;
private List<Users> users = new ArrayList();

UsersServiceImpl(){}


public List<Users> findAll()
{
Query qry =
this.sessionFactory.openSession().createSQLQuery("SELECT * FROM
Users");
users = (List<Users>)qry.list();
return users;
}


public void setSessionFactory (SessionFactory sessiofactory)
{
this.sessionFactory = sessiofactory;
}

}

My client side code (under "client" package), where is
"MyModule.java",
is:
public void onModuleLoad()
{
GWT.create(Users.class);

/*...*/


public void onSuccess(List<Users> retValue)
{

if(req.getValueAsString()=="")
{

ErrMessage(res,"Request field cannot be blank");
}
else
{
List<Users> dati = retValue;
//String num = Integer.toString(retValue.size());
//res.setValue(num);
}
}

Where i, simply, read the return List and store it in al local
variable.


With this simple code (having tried a lot of changes), actually i've
got ALWAYS same error:
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(Thread.java:595)
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.hb4gwt.HB4GWTRPCServiceExporter.invokeMethodOnService(HB4GWTRPCServiceExporter.java:
47)
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(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:585)
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




I've searhed over and over, but without any solution.
Please help me to resolve this problem.
Regards


noon

unread,
May 14, 2008, 6:16:01 AM5/14/08
to Google Web Toolkit
Hi,

Something looks strange to me : is your code using Java5 or Java1.4
syntax ??? There is a weird mix between version of library (GWT1.5 and
h4gwt are Java5 enabled whereas you use the GWT-SL library for Java
1.4 code) :-/

Bruno
Reply all
Reply to author
Forward
0 new messages