liferay ext访问portlet底层数据库6.0.6bug官方解决方案
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.
Hi,
can you please explain how I should use thiese .ftl file to avoid the
problem? I get NullPointerException when trying to call a method of my
xxxLocalServiceUtil in another plug-in.
Pretty much the same as your issue, except I don't receive Class $Proxy271 not found (yet!).
Thanks for the help!
Hi Puj,
you have two options for this:
1. If you have the portal sources then copy the attached template files in directory (replacing the old ones
):
<location of the portal source>/portal/portal-impl/src/com/liferay/portal/tools/servicebuilder/dependencies
Then build the portal-impl.jar
2. If you don't have the portal sources locate the portal-impl.jar in your portal installation (what your Liferay-SDK is configured to - see app.server.dir property in your build.properties file). You will find it in the portal web-app in WEB-INF/lib. E.g. for Tomcat-bundle in <tomcat>/webapps/ROOT/WEB-INF/lib. Then unpack the jar to some temp location. Replace the templates which are located in classes/com/liferay/portal/tools/servicebuilder/dependencies. Repack the portal-impl.jar.
Finally replace the portal-impl.jar in the portal web-app WEB-INF/lib directory.
Then it should work (for me it did
).
HTH
Regards,
Frank.
I ran into the exact same situation NPE (which I narrowed it down to the "Implicit MethodKey member initialization in the *serviceclp.java generated by Service Builder) followed by the $Proxy271 not found exception. Modifying the template files (as suggested above) solved the problem.
Regards,
Seshendra
Hi David,
Has your issue been resolved by the files in the attachment?
Otherwise, please provide additional information based on the
information found in our JIRA reporting wiki (http://www.liferay.com/community/wiki/-/wiki/1071674/JIRA/maximized
) Thanks!
Hallo Kristoffer,
yes, the supplied files fix the issue in the concrete case (the files came from us as an aid to fixing the bug).
Regards,
David
Hello David,
It's good to hear that your issue has been resolved. I will close
this ticket as fixed then. Thank you for reporting the issue.
I have the same problem, but the fix does not work for me
I'm on LR 6.0.5 GA (rev 60396)
Im using the portal source files, so I replaced the 2 files you provided.
Then I recompiled the portal, I generated my service and deployed it,
and then I started the portal, but I still have the same issue :
16:34:14,095 ERROR [jsp:154]
java.lang.NullPointerException
at blabla.model.service.LDAPEtudiantLocalServiceClp.<init>(LDAPEtudiantLocalServiceClp.java:398)
at blabla.model.service.LDAPEtudiantLocalServiceUtil.getService(LDAPEtudiantLocalServiceUtil.java:244)
at blabla.model.service.LDAPEtudiantLocalServiceUtil.getLDAPEtudiant(LDAPEtudiantLocalServiceUtil.java:170)
Did I try to fix it in the right way ?
David Wainwright added a comment - 08/Feb/11 7:57 AMThis Issue is not fixed, the files that we supplied fix the *concrete * case. As soon as you regenerate, the problem is back again.
julien added a comment - 08/Feb/11 8:21 AMWhat do you mean by *concrete * case ?
julien added a comment - 08/Feb/11 8:31 AMNevermind, finally it's working very well
Thx for the fix !
Is this issue related to LPS-14035
?
yes it is
Alessandra Donnini added a comment - 19/Jul/11 1:13 AMI'm using 6.0.6 and I have the same problem and the fix doesn't work. I substituted the files in portal source, I built portal-impl.jar and I deployed it in ROOT/WEB-INF/lib. What it means as soon as I regenerate the problem is back againg? Regenerate what? The portlet plugin that provides services (using service builder) or the plugin that uses services?
Alex Chew added a comment - 21/Aug/11 8:30 AMThe problem still exists on 6.0.6. After I replaced attached .tpl files I got below errors.
15:16:54,687 ERROR [BasePersistenceImpl:182]
Caught unexpected exception java.lang.NullPointerException
com.liferay.portal.kernel.exception.SystemException: java.lang.NullPointerException
at com.liferay.portal.service.persistence.impl.BasePersistenceImpl.processException(BasePersistenceImpl.java:189)
at com.etravel.hotel.service.persistence.HotelPersistenceImpl.findAll(HotelPersistenceImpl.java:449)
at com.etravel.hotel.service.persistence.HotelPersistenceImpl.findAll(HotelPersistenceImpl.java:385)
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:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:80)
at com.liferay.portal.dao.shard.ShardAdvice.invokePersistence(ShardAdvice.java:205)
at sun.reflect.GeneratedMethodAccessor296.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:65)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy357.findAll(Unknown Source)
at com.etravel.hotel.service.base.HotelLocalServiceBaseImpl.getHotels(HotelLocalServiceBaseImpl.java:212)
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:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at
com.liferay.portal.dao.jdbc.aop.DynamicDataSourceTransactionInterceptor.invoke(DynamicDataSourceTransactionInterceptor.java:44)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:58)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:58)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:58)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy355.getHotels(Unknown Source)
at com.etravel.hotel.service.impl.HotelServiceImpl.getMyHotels(HotelServiceImpl.java:58)
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:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at
com.liferay.portal.dao.jdbc.aop.DynamicDataSourceTransactionInterceptor.invoke(DynamicDataSourceTransactionInterceptor.java:44)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:58)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:58)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:58)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy356.getMyHotels(Unknown Source)
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:597)
at com.liferay.portal.kernel.util.MethodHandler.invoke(MethodHandler.java:81)
at com.liferay.portal.kernel.util.ClassLoaderProxy.invoke(ClassLoaderProxy.java:67)
at com.etravel.hotel.service.HotelServiceClp.getMyHotels(HotelServiceClp.java:40)
at com.etravel.hotel.service.HotelServiceUtil.getMyHotels(HotelServiceUtil.java:40)
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:597)
at com.liferay.portal.action.JSONServiceAction.getJSON(JSONServiceAction.java:120)
at com.liferay.portal.struts.JSONAction.execute(JSONAction.java:49)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at com.liferay.portal.struts.PortalRequestProcessor.process(PortalRequestProcessor.java:152)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at com.liferay.portal.servlet.MainServlet.callParentService(MainServlet.java:508)
at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:485)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:126)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:126)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
at com.liferay.portal.servlet.filters.strip.StripFilter.processFilter(StripFilter.java:261)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
at com.liferay.portal.servlet.filters.themepreview.ThemePreviewFilter.processFilter(ThemePreviewFilter.java:88)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
at com.liferay.portal.servlet.filters.gzip.GZipFilter.processFilter(GZipFilter.java:126)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
at com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:182)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
at com.liferay.portal.servlet.filters.sso.ntlm.NtlmPostFilter.processFilter(NtlmPostFilter.java:81)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
at com.liferay.portal.sharepoint.SharepointFilter.processFilter(SharepointFilter.java:179)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.processFilter(VirtualHostFilter.java:239)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:126)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:126)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
at com.liferay.portal.servlet.filters.threadlocal.ThreadLocalFilter.processFilter(ThreadLocalFilter.java:35)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
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:191)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:465)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
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:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NullPointerException
at org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge.nextTimestamp(RegionFactoryCacheProviderBridge.java:93)
at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:650)
at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:659)
at org.springframework.orm.hibernate3.SessionFactoryUtils.doGetSession(SessionFactoryUtils.java:318)
at org.springframework.orm.hibernate3.SessionFactoryUtils.doGetSession(SessionFactoryUtils.java:256)
at org.springframework.orm.hibernate3.SpringSessionContext.currentSession(SpringSessionContext.java:60)
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:698)
at com.liferay.portal.dao.orm.hibernate.SessionFactoryImpl.openSession(SessionFactoryImpl.java:59)
at com.liferay.portal.service.persistence.impl.BasePersistenceImpl.openSession(BasePersistenceImpl.java:177)
at com.etravel.hotel.service.persistence.HotelPersistenceImpl.findAll(HotelPersistenceImpl.java:433)
... 152 more
After attach .tpl files run service builder again.
Owen James added a comment - 24/Nov/11 7:40 AMHello,
I'm using LR 6.0.6 CE.
I'm encountering into the issue described by David.
Context : I have two portlets. One creating services and another consuming them.
Error : Exactly what you describe in your post.
Well, I’ve apply the solution by packaging the portal-impl.jar with the new versions of service_util.ftl and service_clp.ftl. I’ve now access to the share services in the second portlet. However, a new issue has come. Anytime I want to save an entity in the first portlet (an operation that worked before), I got an NoSuchMethodException. But, the method exist, and with the right signature. Here is an excerpt of the log exception :
java.lang.NoSuchMethodException: com.alti.cnp.service.SinistreLocalServiceUtil.updateSinistre(com.alti.cnp.model.Sinistre)
at java.lang.Class.getMethod(Class.java:1605)
at com.liferay.portal.kernel.util.MethodCache._get(MethodCache.java:107)
Any help would be greatly appreciate.
Thanks
Ken Barron added a comment - 24/Nov/11 12:31 PMYour NoSuchMethodException should disappear if you make sure that your service builder jar file is either:
1. under your lib/ext directory (talking Tomcat here - anyway your
appserver shared lib directory), AND removed from your WEB-INF/lib
directory of your service builder webapp.
OR 2. under the WEB-INF/lib directory of all of your web apps (including the portlet web app)
I haven't tried the second method but the first one definitely worked
for me. Got this info from another Liferay forum or blog post but I
can't remember where to give you the link.