Fórumok
Finder in Service Builder
Esteban Lopez, módosítva 13 év-val korábban
Finder in Service Builder
Junior Member Bejegyzések: 26 Csatlakozás dátuma: 2010.11.03. Legújabb bejegyzések
Hi, I've created a service without custom finders but when I try to use the default finders it throws me an exception.
I have use the finder is this way:
BookUtil.findAll()
because the finders aren't in the BookLocalService
Is it the correct way to use the finders?
I have use the finder is this way:
BookUtil.findAll()
because the finders aren't in the BookLocalService
Is it the correct way to use the finders?
jelmer kuperus, módosítva 13 év-val korábban
RE: Finder in Service Builder
Liferay Legend Bejegyzések: 1191 Csatlakozás dátuma: 2010.03.10. Legújabb bejegyzések
You have to call the finders from a transactional service.
Suppose you defined a finder to find a book by its isbn then in the BookLocalServiceImpl class you add a method that calls the BookUtil like this
then regenerate the service.This wil add the method to the interface
Suppose you defined a finder to find a book by its isbn then in the BookLocalServiceImpl class you add a method that calls the BookUtil like this
public class BookLocalServiceImpl extends ... {
public Book findByIsbn(String isbn) throws PortalException, SystemException {
return BookUtil.findByIsbn(isbn);
}
}
then regenerate the service.This wil add the method to the interface
Esteban Lopez, módosítva 13 év-val korábban
RE: Finder in Service Builder
Junior Member Bejegyzések: 26 Csatlakozás dátuma: 2010.11.03. Legújabb bejegyzések
I've tried it but I'm having problems with de class loader proxy. When I used the finder in my view.jsp it throws me the next exception
Stacktrace:
at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
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 org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
at com.liferay.portlet.PortletRequestDispatcherImpl.dispatch(PortletRequestDispatcherImpl.java:315)
at com.liferay.portlet.PortletRequestDispatcherImpl.include(PortletRequestDispatcherImpl.java:104)
... 202 more
Caused by: java.lang.NullPointerException
at com.sample.portlet.library.service.libretoLocalServiceClp.<init>(libretoLocalServiceClp.java:458)
at com.sample.portlet.library.service.libretoLocalServiceUtil.getService(libretoLocalServiceUtil.java:256)
at com.sample.portlet.library.service.libretoLocalServiceUtil.getLibretos(libretoLocalServiceUtil.java:239)
at org.apache.jsp.view_jsp._jspService(view_jsp.java:245)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
... 212 more
09:36:42,179 ERROR [jsp:154] java.lang.NullPointerException
at com.sample.portlet.library.service.libretoLocalServiceClp.<init>(libretoLocalServiceClp.java:458)
at com.sample.portlet.library.service.libretoLocalServiceUtil.getService(libretoLocalServiceUtil.java:256)
at com.sample.portlet.library.service.libretoLocalServiceUtil.getLibretos(libretoLocalServiceUtil.java:239)
Stacktrace:
at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
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 org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
at com.liferay.portlet.PortletRequestDispatcherImpl.dispatch(PortletRequestDispatcherImpl.java:315)
at com.liferay.portlet.PortletRequestDispatcherImpl.include(PortletRequestDispatcherImpl.java:104)
... 202 more
Caused by: java.lang.NullPointerException
at com.sample.portlet.library.service.libretoLocalServiceClp.<init>(libretoLocalServiceClp.java:458)
at com.sample.portlet.library.service.libretoLocalServiceUtil.getService(libretoLocalServiceUtil.java:256)
at com.sample.portlet.library.service.libretoLocalServiceUtil.getLibretos(libretoLocalServiceUtil.java:239)
at org.apache.jsp.view_jsp._jspService(view_jsp.java:245)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
... 212 more
09:36:42,179 ERROR [jsp:154] java.lang.NullPointerException
at com.sample.portlet.library.service.libretoLocalServiceClp.<init>(libretoLocalServiceClp.java:458)
at com.sample.portlet.library.service.libretoLocalServiceUtil.getService(libretoLocalServiceUtil.java:256)
at com.sample.portlet.library.service.libretoLocalServiceUtil.getLibretos(libretoLocalServiceUtil.java:239)
Srikanth Reddy, módosítva 13 év-val korábban
RE: Finder in Service Builder
Junior Member Bejegyzések: 53 Csatlakozás dátuma: 2010.06.18. Legújabb bejegyzések
hi lopez,
first of let me tell how to access u r finder methods,other then u r Primary key field.
Once you have written the finder methods in service.xml
when you build these finder methods are available only to persistence or service layer.
if you try to access them in impl layer directly ,using XXXUtil ,then you get an exception.
To access them in impl layer or action class,you have to first expose thess finder methods to impl layer .to do so you have to use the unimpleneted class given as XXXLocalServiceImpl class.
just open this class and just create any method() with the return type of u r
finderMethod() ;
now inside it use this "return ActionUtil.XXmethod()";
Note : Now u need to build again to expose this method to XXXlocalserviceUtil class.
now u can use it in u r action class.
Rules for accesing
..................
1 - Never call EntryUtil functions directly, but always through a service (EntryLocalServiceImpl.java or EntryServiceImpl.java) even if it's just a facade.
2 - If you have to add method to EntryLocalServiceImpl.java or EntryServiceImpl.java don't forget to regenerate services with service builder.
3 - Regenerate services will enable you to access methods from service layer through the EntryLocalServiceUtil java class. Always use this class to access the service layer.
note:Entry is the name of your entity(Portlet name in service.xml)
first of let me tell how to access u r finder methods,other then u r Primary key field.
Once you have written the finder methods in service.xml
when you build these finder methods are available only to persistence or service layer.
if you try to access them in impl layer directly ,using XXXUtil ,then you get an exception.
To access them in impl layer or action class,you have to first expose thess finder methods to impl layer .to do so you have to use the unimpleneted class given as XXXLocalServiceImpl class.
just open this class and just create any method() with the return type of u r
finderMethod() ;
now inside it use this "return ActionUtil.XXmethod()";
Note : Now u need to build again to expose this method to XXXlocalserviceUtil class.
now u can use it in u r action class.
Rules for accesing
..................
1 - Never call EntryUtil functions directly, but always through a service (EntryLocalServiceImpl.java or EntryServiceImpl.java) even if it's just a facade.
2 - If you have to add method to EntryLocalServiceImpl.java or EntryServiceImpl.java don't forget to regenerate services with service builder.
3 - Regenerate services will enable you to access methods from service layer through the EntryLocalServiceUtil java class. Always use this class to access the service layer.
note:Entry is the name of your entity(Portlet name in service.xml)
jelmer kuperus, módosítva 13 év-val korábban
RE: Finder in Service Builder
Liferay Legend Bejegyzések: 1191 Csatlakozás dátuma: 2010.03.10. Legújabb bejegyzések
Classloader proxies are broken in liferay 6.0.5
See: http://www.liferay.com/community/forums/-/message_boards/message/5968217
relevant jira issues are LPS-12372 LPS-12791 and LPS-12792
See: http://www.liferay.com/community/forums/-/message_boards/message/5968217
relevant jira issues are LPS-12372 LPS-12791 and LPS-12792