Hi guys:
I am trying to expose a custom model created with service builder via JSON. So I created the model with local-service remote-service attributes set to true.
Then implemented one simple getById method in XXXLocalServiceImpl and called "ant build-service" again to regenerate classes.
When I deployed the war, every thing was OK but when trying to access the getById method via web, the portalClassLoader was not able find the apropiate class. That looks correct, as far as the *-service.jar is in portlet context and not in portal context.
Well, then I
copied moved the XXX-service.jar to portals lib/ext folder to make it be loaded with the portal classLoader.
Well, now the method is invoked, and data is retrieved from DB. We are near!
The method is invoked in method getJSON of class JSONServiceAction
1Object returnObj = method.invoke(classObj, args);
At this point, returnObj is an instance of XXX
Clp.
After that
1if (returnObj != null) {
2 return getReturnValue(returnObj, method.getReturnType());
3 }
is called.
getReturnValue first of all gets the serializer class name
1protected String getSerializerClassName(Object obj) {
2 String serlializerClassName = StringUtil.replace(
3 obj.getClass().getName(),
4 new String[] {".model.impl.", "Impl"},
5 new String[] {".service.http.", "JSONSerializer"});
6
7 return serlializerClassName;
8 }
but this is prepared for implementations of models, not the service classes.
For example, supose we have for instance
my.company.artifact.model.XXXClp.java
If the
getSerializerClassName method is aplied, it will return the class itself.
But if we have the class wich implements the model,
my.company.artifact.model.impl.XXXImpl.javathe
getSerializerClassName method will return
my.company.artifact.impl.XXXImplJSONSerializer.javaFinally, JSONServiceAction will invoke the method toJSONObject of the resultant class, which fails because
my.company.artifact.model.XXXClp.java does not have such method as
my.company.artifact.impl.XXXImplJSONSerializer.java does
What am I doing wrong?
Can anyone spot some light on it?
Regards!!!