Service Builder generates code with logical errors
Description
Attachments
is duplicated by
Activity

Mathieu HicauberDecember 21, 2011 at 7:13 AM
@Ken @Owen well, I made sure my service jar is only present in the lib/ext directory, but nevermind, still having the NoSuchMethoException (classloader issue i reckon ?) described by Owen. Any clue about that ?

Mathieu HicauberDecember 21, 2011 at 6:59 AM
Stupid me. Adding the jjar in lib/ext make it available to the portlet plugin, that was only a refresh issue.

Mathieu HicauberDecember 21, 2011 at 6:35 AM
Ho and I read your message quickly, didn't noticed you made it work under eclipse - how did you do that ?
Thank you,
Mathieu.

Mathieu HicauberDecember 21, 2011 at 6:04 AM
Hi Alessandra - same as you - did you solve it ?
after putting the service jar in the TOMCAT/lib/ext, of course my portlet plugin consuming the services isn't compiling anymore. How am I supposed to give it the classes needed ?

alendoDecember 6, 2011 at 2:37 AM
I generate my services by using service builder and patched portal-impl and they work in development environment (under Eclipse) (I put my jars under Tomcat/lib/ext directory). They don't work in production environment, where I receive this error:
java.lang.Error: Unresolved compilation problems:
The import it.etc.portlet.newsletter cannot be resolved
The import it.etc.portlet.newsletter cannot be resolved
NewsletterUserLocalServiceUtil cannot be resolved
NewsletterUser cannot be resolved to a type
NewsletterUserLocalServiceUtil cannot be resolved
NewsletterUser cannot be resolved to a type
NewsletterUser cannot be resolved to a type
com.liferay.portlet.journal.action.SendNewsletterAction.<init>(SendNewsletterAction.java:5)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
java.lang.reflect.Constructor.newInstance(Constructor.java:513)
java.lang.Class.newInstance0(Class.java:355)
java.lang.Class.newInstance(Class.java:308)
Do I need to install patched portal-impl.jar also in production environment? I understood that patched portal-impl.jar was necessary only in development environment. Any other idea?
The code generated by the service builder was not working. We get a null pointer exception when calling a service method at the generated façade. The generated code contains logical errors:
The MethodKey member variables in the *ServiceClp-classes are implicitly initialized while making use of the ClassLoaderProxy member variable which is initialized by the constructor. The implicit initializations of the MethodKey members are done before the ClassLoaderProxy member is set by the constructor. Unfortunately during the MethodKey member initialization the ClassLoaderProxy member is being accessed which results in the null pointer. See the corresponding template file for a fix (service_clp.ftl).
After this modification the null pointer was gone but replaced by a ClassNotFoundException. The message of the exception said something like "Class $Proxy271 not found". The problem is located in the generated *ServiceUtil-class. The ClassLoaderProxy instance is created with a deprecated constructor which takes the service façade object and the portlet class loader. Internally the constructor took the class name from the service façade object with getClass().getName(). I supposed that this was the reason for the weird class name "$Proxy271" (probably because it is an implementation class name and the class is a proxy generated by Spring-AOP).
However, to fix this I used the non-deprecated constructor (where the class name can be specified) and set the service façade interface class name. I've attached the fixed template file (service_util.ftl).
Though I wasn't sure if this would work - after this modification everything seemed to work fine.