Foros de discusión

DynamicQuery vs ServicBuilder of new table error between different portlets

Ranvijay Singh, modificado hace 12 años.

DynamicQuery vs ServicBuilder of new table error between different portlets

New Member Mensajes: 15 Fecha de incorporación: 3/06/11 Mensajes recientes
I have created a new table(sendreceivegift), by using LR service Builder, in a portlet 'A'
and trying to run a dynamic query from some different portlet 'B', by adding required newly created table's service jar file in the class
path of portlet 'B'. everything runs fine when I'm using SendReceiveGiftLocalServiceUtil's method for fetching data.
But when I'm trying to create a dynamic query and run, it gives me NullPointerException, though i have also uses classloader, i'm using Liferay5.2
This is the code, I'm using in portlet B.

ClassLoader cl = PortalClassLoaderUtil.getClassLoader();
DynamicQuery dqGift = DynamicQueryFactoryUtil.forClass(
SendReceiveGift.class, "gift", cl);

dqGift.add(RestrictionsFactoryUtil.eq("id", new Integer(1)));

try{
List result=SendReceiveGiftLocalServiceUtil.dynamicQuery(dqGift);

_log.info("Size-->"+result.size());
}catch(Exception e){
e.printStackTrace();
}


while , when i made a little change i.e. SendReceiveGift to SendReceiveGiftImpl in portlet 'A' , By checking portlet-hbm.xml file(code snipt is given below) it starts working for portlet 'A'.

<hibernate-mapping default-lazy="false" auto-import="false">
<class name="com.steria.liferay.service.model.impl.SendReceiveGiftImpl" table="SendReceiveGift">
<cache usage="read-write" />
<id name="id" type="java.lang.Integer">
<generator class="increment" />
</id>
Ranvijay Singh, modificado hace 12 años.

RE: DynamicQuery vs ServicBuilder of new table error between different port

New Member Mensajes: 15 Fecha de incorporación: 3/06/11 Mensajes recientes
No Reply...emoticon
thumbnail
Nagendra Kumar Busam, modificado hace 12 años.

RE: DynamicQuery vs ServicBuilder of new table error between different port

Liferay Master Mensajes: 678 Fecha de incorporación: 7/07/09 Mensajes recientes
Please put your *-service.jar for your portlet @ global class path. For tomcat > lib/ext

Check the following link for dynamic query related info

http://liferay-blogging.blogspot.com/2011/03/dynamicquery-api-and-classloaders-in.html
Ranvijay Singh, modificado hace 12 años.

RE: DynamicQuery vs ServicBuilder of new table error between different port

New Member Mensajes: 15 Fecha de incorporación: 3/06/11 Mensajes recientes
Hi Nagendra,

Thanks for reply, i did the changes as you mentioned. and it starts giving other exception(mentioned below). How ever as per link, it suggest that when implementation class is in another portlet, then use class loader. ClassLoader classLoader = (ClassLoader)PortletBeanLocatorUtil.locate(ClpSerializer.SERVLET_CONTEXT_NAME,"portletClassLoader");. But in ClpSerializer(generated through service builder) there is no SERVLET_CONTEXT_NAME variable hence it gives compilation error. I'm using liferay 5.2.x with netbean IDE 6.9.1

Exception:-

12:42:26,731 ERROR [ClassLoaderProxy:148] java.lang.ClassNotFoundException: com.liferay.portal.dao.orm.hibernate.DynamicQueryImpl
java.lang.ClassNotFoundException: com.liferay.portal.dao.orm.hibernate.DynamicQueryImpl
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1386)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1232)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:242)
        at com.liferay.portal.kernel.util.ClassLoaderProxy.invoke(ClassLoaderProxy.java:73)
        at com.steria.liferay.service.service.SendReceiveGiftLocalServiceClp.dynamicQuery(Unknown Source)
        at com.steria.liferay.service.service.SendReceiveGiftLocalServiceUtil.dynamicQuery(Unknown Source)
        at com.steria.portlet.GiftCaptureFormPortlet.receivingForm(GiftCaptureFormPortlet.java:61)
        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:585)
        at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doInvokeMethod(HandlerMethodInvoker.java:421)
        at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:136)
        at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:271)
        at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.doHandle(AnnotationMethodHandlerAdapter.java:259)
        at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.handleRender(AnnotationMethodHandlerAdapter.java:218)
        at org.springframework.web.portlet.DispatcherPortlet.doRenderService(DispatcherPortlet.java:811)
        at org.springframework.web.portlet.FrameworkPortlet.processRequest(FrameworkPortlet.java:483)
        at org.springframework.web.portlet.FrameworkPortlet.doDispatch(FrameworkPortlet.java:453)
        at javax.portlet.GenericPortlet.render(GenericPortlet.java:233)
        at com.sun.portal.portletcontainer.appengine.filter.FilterChainImpl.doFilter(FilterChainImpl.java:126)
        at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:69)
        at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:100)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:679)
        at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:584)
        at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:497)
        at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:616)
        at com.liferay.portlet.InvokerPortletImpl.invokeRender(InvokerPortletImpl.java:698)
        at com.liferay.portlet.InvokerPortletImpl.render(InvokerPortletImpl.java:417)
        at org.apache.jsp.html.portal.render_005fportlet_jsp._jspService(render_005fportlet_jsp.java:1409)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:679)
        at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:584)
        at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:497)
        at com.liferay.portal.util.PortalImpl.renderPortlet(PortalImpl.java:2801)
        at com.liferay.portal.util.PortalUtil.renderPortlet(PortalUtil.java:858)
        at com.liferay.portlet.layoutconfiguration.util.RuntimePortletUtil.processPortlet(RuntimePortletUtil.java:170)
        at com.liferay.portlet.layoutconfiguration.util.RuntimePortletUtil.processPortlet(RuntimePortletUtil.java:90)
        at com.liferay.portlet.layoutconfiguration.util.RuntimePortletUtil.processPortlet(RuntimePortletUtil.java:77)
        at com.liferay.portlet.layoutconfiguration.util.velocity.PortletLogic.processContent(PortletLogic.java:85)
        at com.liferay.portlet.layoutconfiguration.util.velocity.TemplateProcessor.processMax(TemplateProcessor.java:85)
        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:585)
thumbnail
Nagendra Kumar Busam, modificado hace 12 años.

RE: DynamicQuery vs ServicBuilder of new table error between different port

Liferay Master Mensajes: 678 Fecha de incorporación: 7/07/09 Mensajes recientes
You don't have service.xml in Portlet B right?
Ranvijay Singh, modificado hace 12 años.

RE: DynamicQuery vs ServicBuilder of new table error between different port

New Member Mensajes: 15 Fecha de incorporación: 3/06/11 Mensajes recientes
Yes, don't have service.xml in portlet 'B'.
thumbnail
Nagendra Kumar Busam, modificado hace 12 años.

RE: DynamicQuery vs ServicBuilder of new table error between different port

Liferay Master Mensajes: 678 Fecha de incorporación: 7/07/09 Mensajes recientes
since you don't have service.xml in portlet 'B' you won't be having ClpSerializer class in that portlet. Will do some more RnD & get back to you
Ranvijay Singh, modificado hace 12 años.

RE: DynamicQuery vs ServicBuilder of new table error between different port

New Member Mensajes: 15 Fecha de incorporación: 3/06/11 Mensajes recientes
Hi Nagendra,
Just for info, i have checked *-service.jar (copied to global path) file and found ClpSerializer class is there.But this class does not contains SERVLET_CONTEXT_NAME variable which is required for class loader.
ClassLoader classLoader = (ClassLoader)PortletBeanLocatorUtil.locate(ClpSerializer.SERVLET_CONTEXT_NAME,"portletClassLoader");

--Thanks for being active on this thread.

Regards,
Ranvijay
thumbnail
Nagendra Kumar Busam, modificado hace 12 años.

RE: DynamicQuery vs ServicBuilder of new table error between different port

Liferay Master Mensajes: 678 Fecha de incorporación: 7/07/09 Mensajes recientes
In Liferay 5.2 what version exactly are you using.
Ranvijay Singh, modificado hace 12 años.

RE: DynamicQuery vs ServicBuilder of new table error between different port

New Member Mensajes: 15 Fecha de incorporación: 3/06/11 Mensajes recientes
tomcat-5.5.27
thumbnail
Nagendra Kumar Busam, modificado hace 12 años.

RE: DynamicQuery vs ServicBuilder of new table error between different port

Liferay Master Mensajes: 678 Fecha de incorporación: 7/07/09 Mensajes recientes
Liferay version?
Ranvijay Singh, modificado hace 12 años.

RE: DynamicQuery vs ServicBuilder of new table error between different port

New Member Mensajes: 15 Fecha de incorporación: 3/06/11 Mensajes recientes
Hi Nagendra,

Liferay portal bundle which i have downloaded is liferay-portal-5.2.2 .

-Thanks,
Ranvijay
thumbnail
Nagendra Kumar Busam, modificado hace 12 años.

RE: DynamicQuery vs ServicBuilder of new table error between different port

Liferay Master Mensajes: 678 Fecha de incorporación: 7/07/09 Mensajes recientes
Did you give it try on any other latest community editions like 5.2.3,6.0.5, 6.0.6