Thursday, February 24, 2011

Pb returning custom type on RPC call with Gilead

my config is GWT 2.1 and Gilead 1.3.2.1839, hibernate3.jar

my project is named oppv.

my LoginService.java -- (package com.oppv.client.remote)

public interface LoginService extends RemoteService{

public String getNameUser(String value);

public Iuser getUser(String value);

}


my LoginServiceAsynch.java -- (package com.oppv.client.remote)


public interface LoginServiceAsync{

public void getNameUser(String value, AsyncCallback<String>
callback);

public void getUser(String value, AsyncCallback<Iuser> callback);
}

my oppv.java -- (package com.oppc.client)


LoginService.getNameUser(login.getValue(), getNameCallBack);

and callback :

private AsyncCallback<String> getNameCallBack = new
AsyncCallback<String>() {

public void onFailure(Throwable caught) {
GWT.log(caught.getMessage(), caught);
}
public void onSuccess(String UserName) {
if (!UserName.isEmpty()) {
System.out.println("My Result getName is : " + UserName);
}
else {
System.out.println("No UserName found.");
}
}
};


LoginService.getUser(login.getValue(), getUserCallBack);

and callback :

private AsyncCallback<Iuser> getUserCallBack = new
AsyncCallback<Iuser>() {

public void onFailure(Throwable caught) {
GWT.log(caught.getMessage(), caught);
}
public void onSuccess(Iuser user) {
if (user != null) {
System.out.println("My result getUser is : " + user.getName());
}
else {
System.out.println("No UserName found.");
}
}
};


my LoginServiceImpl.java -- (package com.oppv.server)

/**
* Constructor
*/

public LoginServiceImpl() {
HibernateUtil gileadHibernateUtil = new HibernateUtil();

gileadHibernateUtil.setSessionFactory(HibernateContext.getSessionFactory());

PersistentBeanManager persistentBeanManager = new
PersistentBeanManager();
persistentBeanManager.setPersistenceUtil(gileadHibernateUtil);
persistentBeanManager.setProxyStore(new StatelessProxyStore());
setBeanManager(persistentBeanManager);
}


@Override
public Iuser getNameUser(String value) {
Session session = null;
Transaction transaction = null;
try {
session = HibernateContext.getSessionFactory().openSession();
transaction = session.beginTransaction();
Iuser iuser = (Iuser)
session.createCriteria(Iuser.class).add(Restrictions.eq("email",
value))
.uniqueResult();
return iuser.getName();
}
catch (RuntimeException e) {
transaction.rollback();
throw e;
}
finally {
session.close();
}
}


@Override
public Iuser getUser(String value) {
Session session = null;
Transaction transaction = null;
try {
session = HibernateContext.getSessionFactory().openSession();
transaction = session.beginTransaction();
Iuser iuser = (Iuser)
session.createCriteria(Iuser.class).add(Restrictions.eq("email",
value))
.uniqueResult();
return iuser;
}
catch (RuntimeException e) {
transaction.rollback();
throw e;
}
finally {
session.close();
}
}


My HibernateContext.java --

package com.oppv.server;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;


/**
* Hibernate context utility class
* @author bruno.marchesson
*
*/
public class HibernateContext
{


//----
// Constants
//----
/**
* The stateful configuration file
*/
private static final String CONFIGURATION_FILE =
"hibernate.cfg.xml";


//----
// Attributes
//----
/**
* Log channel
*/
private static Log _log = LogFactory.getLog(HibernateContext.class);

/**
* The current session factory
*/
private static SessionFactory _sessionFactory;

//-------------------------------------------------------------------------
//
// Public interface
//
//-------------------------------------------------------------------------
/**
* @return the created session factory
*/
public static SessionFactory getSessionFactory()
{
if (_sessionFactory == null)
{
try
{

// Create the SessionFactory from hibernate.cfg.xml
_sessionFactory = new
Configuration().configure(CONFIGURATION_FILE).buildSessionFactory();
}
catch (Throwable ex)
{
// Make sure you log the exception, as it might be swallowed
_log.error("Initial SessionFactory creation failed.", ex);
throw new ExceptionInInitializerError(ex);
}
}
return _sessionFactory;
}
}

my Iuser.java -- (in com.oppv.domain) --

/**
* Iuser generated by hbm2java
*/

public class Iuser extends LightEntity implements Serializable {

private String email;
private Integer id;
private String name;

public Iuser() {
}


public Iuser(String Name, String email) {
this.email = email;
this.name = name;
}

public Integer getId() {
return this.id;
}

public void setId(Integer id) {
this.id = id;
}


public String getEmail() {
return this.email;
}
public void setEmail(String email) {
this.email = email;
}
public String getName() {
return this.name;
}

public void setName(String name) {
this.name = name;
}

.. Other fields for sure but not interresting

}

In my hibernate.cfg.xml i have this line : <mapping resource="/com/
oppv/domain/Iuser.hbm.xml"/>

In my oppv.gwt.xml i have these one :

<inherits name='net.sf.gilead.Gilead4Gwt'/>
<!-- Specify the paths for translatable code -->
<source path='client'/>
<source path='domain'/>

And my Trace is here : (It works for UserName and Not for Iuser... )

[WARN] Server class 'com.google.gwt.junit.server.JUnitHostImpl' could
not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/D:/eclipse/plugins/
com.google.gwt.eclipse.sdkbundle.2.1.1_2.1.1.v201012170127/gwt-2.1.1/
gwt-user.jar' to the web app classpath for this session
For additional info see: file:/D:/eclipse/plugins/
com.google.gwt.eclipse.sdkbundle.2.1.1_2.1.1.v201012170127/gwt-2.1.1/
doc/helpInfo/webAppClassPath.html
Reload completed successfully
[WARN] Server class 'net.sf.beanlib.hibernate.HibernateBeanReplicator'
could not be found in the web app, but was found on the system
classpath
[WARN] Adding classpath entry 'file:/D:/workspace/gilead-1.3.2.1839/
gilead-core/lib/beanlib-hibernate-5.0.2beta.jar' to the web app
classpath for this session
For additional info see: file:/D:/eclipse/plugins/
com.google.gwt.eclipse.sdkbundle.2.1.1_2.1.1.v201012170127/gwt-2.1.1/
doc/helpInfo/webAppClassPath.html
[WARN] Server class 'net.sf.beanlib.spi.BeanPopulatorBaseSpi' could
not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/D:/workspace/gilead-1.3.2.1839/
gilead-core/lib/beanlib-5.0.2beta.jar' to the web app classpath for
this session
For additional info see: file:/D:/eclipse/plugins/
com.google.gwt.eclipse.sdkbundle.2.1.1_2.1.1.v201012170127/gwt-2.1.1/
doc/helpInfo/webAppClassPath.html
[WARN] Server class 'org.apache.commons.collections.SequencedHashMap'
could not be found in the web app, but was found on the system
classpath
[WARN] Adding classpath entry 'file:/D:/eclipse/plugins/
com.google.gwt.eclipse.sdkbundle.2.1.1_2.1.1.v201012170127/gwt-2.1.1/
gwt-dev.jar' to the web app classpath for this session
For additional info see: file:/D:/eclipse/plugins/
com.google.gwt.eclipse.sdkbundle.2.1.1_2.1.1.v201012170127/gwt-2.1.1/
doc/helpInfo/webAppClassPath.html
[WARN] Server class 'net.sf.gilead.pojo.java5.legacy.LightEntity'
could not be found in the web app, but was found on the system
classpath
[WARN] Adding classpath entry 'file:/D:/workspace/gilead-1.3.2.1839/
gilead-core/bin/' to the web app classpath for this session
For additional info see: file:/D:/eclipse/plugins/
com.google.gwt.eclipse.sdkbundle.2.1.1_2.1.1.v201012170127/gwt-2.1.1/
doc/helpInfo/webAppClassPath.html
GWT20
GWT20
Hibernate: select this_.id as id0_0_, this_.name as name0_0_,
this_.surname as surname0_0_, this_.email as email0_0_, this_.password
as password0_0_, this_.sex as sex0_0_, this_.birthday as birthday0_0_,
this_.join_date as join8_0_0_, this_.registration_confirmation as
registra9_0_0_, this_.presentation as present10_0_0_,
this_.registration_confirmed as registr11_0_0_, this_.sessionCookie as
session12_0_0_, this_.connection_attempt as connection13_0_0_ from
oppv.iuser this_ where this_.email=?
Hibernate: select this_.id as id0_0_, this_.name as name0_0_,
this_.surname as surname0_0_, this_.email as email0_0_, this_.password
as password0_0_, this_.sex as sex0_0_, this_.birthday as birthday0_0_,
this_.join_date as join8_0_0_, this_.registration_confirmation as
registra9_0_0_, this_.presentation as present10_0_0_,
this_.registration_confirmed as registr11_0_0_, this_.sessionCookie as
session12_0_0_, this_.connection_attempt as connection13_0_0_ from
oppv.iuser this_ where this_.email=?
[WARN] Exception while dispatching incoming RPC call
java.lang.NoClassDefFoundError: net/sf/beanlib/spi/
DetailedBeanPopulatable
at net.sf.gilead.core.LazyKiller.clone(LazyKiller.java:233)
at net.sf.gilead.core.LazyKiller.detach(LazyKiller.java:191)
at
net.sf.gilead.core.PersistentBeanManager.clonePojo(PersistentBeanManager.java:
374)
at
net.sf.gilead.core.PersistentBeanManager.clone(PersistentBeanManager.java:
248)
at
net.sf.gilead.gwt.GileadRPCHelper.parseReturnValue(GileadRPCHelper.java:
126)
at
net.sf.gilead.gwt.PersistentRemoteService.processCall(PersistentRemoteService.java:
153)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:
243)
at
com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:
62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:
487)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:
362)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:
216)
at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:
181)
at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:
729)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:
405)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
152)
at
org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:
49)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:
505)
at org.mortbay.jetty.HttpConnection
$RequestHandler.content(HttpConnection.java:843)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:
395)
at org.mortbay.thread.QueuedThreadPool
$PoolThread.run(QueuedThreadPool.java:488)
Caused by: java.lang.ClassNotFoundException:
net.sf.beanlib.spi.DetailedBeanPopulatable
at java.lang.ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at
org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:
352)
at
org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:
337)
... 27 more
[ERROR] 500 - POST /com.oppv.Oppv/login (127.0.0.1) 57 bytes
Request headers
Host: 127.0.0.1:8888
Connection: keep-alive
Referer: http://127.0.0.1:8888/Oppv.html?gwt.codesvr=127.0.0.1:9997
Accept: */*
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US)
AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.98 Safari/534.13
Accept-Encoding: gzip,deflate,sdch
Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Cookie: JSESSIONID=cbgdlogu6oau
Content-Length: 177
Origin: http://127.0.0.1:8888
X-GWT-Module-Base: http://127.0.0.1:8888/com.oppv.Oppv/
Content-Type: text/x-gwt-rpc; charset=UTF-8
X-GWT-Permutation: HostedMode
Response headers
Content-Type: text/plain
My Result getName is : sebastien

Thanks for you if you have any idea for a miss config or else....

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment