The domain type Foo_$$_javassist_45 cannot be sent to the client

241 views
Skip to first unread message

Stefan

unread,
Mar 28, 2011, 5:43:03 PM3/28/11
to Google Web Toolkit
Hi Guys,

I am having an issue using GWT 2.2 RequestFactory and Hibernate 3.6.
My domain model is looks like this:

class Bar {
Long id;
String title;
Foo foo;
}

class Foo {
Long.id;
String title;
}

So, I am trying to populate a CellTable using request factory with
Bar.id, Bar.title, Bar.foo.id. The domain model is constructed from
the database using JPA/Hibernate. The problem I am getting is:

com.google.gwt.requestfactory.server.UnexpectedException: The domain
type Foo_$$_javassist_45 cannot be sent to the client
at
com.google.gwt.requestfactory.server.ServiceLayerDecorator.die(ServiceLayerDecorator.java:
185)
at
com.google.gwt.requestfactory.server.ResolverServiceLayer.resolveClientType(ResolverServiceLayer.java:
91)
at
com.google.gwt.requestfactory.server.ServiceLayerDecorator.resolveClientType(ServiceLayerDecorator.java:
122)
at
com.google.gwt.requestfactory.server.ServiceLayerDecorator.resolveClientType(ServiceLayerDecorator.java:
122)

It appears that Hibernate enhances Foo producing a class is called Foo_
$$_javassist_45. However, the RequestFactory cannot associate the
enhanced class with FooProxy.

Is there a way around it ?

Thanks
Stefan

Lars

unread,
Mar 29, 2011, 11:10:49 AM3/29/11
to Google Web Toolkit
Actually there is. I encontered the same problem with some Guice-
enhanced classes. You can write a custom decorator and override the
appropriate methods.
Here's my implementation - to get you started:

public class GuiceDecorator extends ServiceLayerDecorator {

@Override
public Class<? extends Locator<?, ?>> resolveLocator(Class<?>
domainType) {
if(domainType.getName().contains("Guice"))
return super.resolveLocator(domainType.getSuperclass());
return super.resolveLocator(domainType);
}

@Override
public <T> Class<? extends T> resolveClientType(Class<?> domainClass,
Class<T> clientType, boolean required) {
if(domainClass.getName().contains("Guice"))
return super.resolveClientType(domainClass.getSuperclass(),
clientType, required);
return super.resolveClientType(domainClass, clientType, required);
}

@Override
public <T extends Locator<?, ?>> T createLocator(Class<T> clazz) {
return GuiceConfig.getInjectorReference().getInstance(clazz);

Stefan

unread,
Mar 29, 2011, 5:44:44 PM3/29/11
to Google Web Toolkit
Lars, thanks a bunch. The trick with the ServiceLayerDecorator worked
like a charm :)

For other the benefit of other readers:
- I did not need the resolveLocator() and createLocator() methods. My
entity objects did conform to the RequestFactory specification so I
did not need custom locators.
- To activate my service layer decorator I ended up extending
RequestFactoryServlet. Here is the code:

public class MyRequestFactoryServlet
extends RequestFactoryServlet
{

public FoundryRequestFactoryServlet()
{
super(new DefaultExceptionHandler(), new
MyServiceLayerDecorator());
}

}

Thanks
Stefan

-sowdri-

unread,
Apr 18, 2011, 8:25:22 AM4/18/11
to google-we...@googlegroups.com
It was so helpful, thank you for posting!
Reply all
Reply to author
Forward
0 new messages