Fórumok

ERROR : java.lang.StackOverflowError

Kevin Shah, módosítva 11 év-val korábban

ERROR : java.lang.StackOverflowError

New Member Bejegyzések: 7 Csatlakozás dátuma: 2012.07.20. Legújabb bejegyzések
Hello,

This is my EntityLocalServiceImpl code :
public List<Entity> findAll() throws SystemException
{
List<Entity> list = null;
list = EntityLocalServiceUtil.findAll();
return list;
}

This is my JSP code :
EntityLocalServiceImpl impl = new EntityLocalServiceImpl();
List<Entity> list = impl.findAll();

Now when I open my jsp it shows me below ERROR :

04:32:54,332 ERROR [PortletRequestDispatcherImpl:108] org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.StackOverflowError
org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.StackOverflowError
at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:113)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:70)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:593)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:530)
at com.liferay.portlet.PortletRequestDispatcherImpl.dispatch(PortletRequestDispatcherImpl.java:316)
at com.liferay.portlet.PortletRequestDispatcherImpl.include(PortletRequestDispatcherImpl.java:105)
at com.liferay.util.bridges.mvc.MVCPortlet.include(MVCPortlet.java:366)
at com.liferay.util.bridges.mvc.MVCPortlet.include(MVCPortlet.java:382)
at com.liferay.util.bridges.mvc.MVCPortlet.doDispatch(MVCPortlet.java:315)
at javax.portlet.GenericPortlet.render(GenericPortlet.java:233)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100)
at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:64)
at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:93)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:70)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:593)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:530)
at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:637)
at com.liferay.portlet.InvokerPortletImpl.invokeRender(InvokerPortletImpl.java:722)
at com.liferay.portlet.InvokerPortletImpl.render(InvokerPortletImpl.java:426)
at org.apache.jsp.html.portal.render_005fportlet_jsp._jspService(render_005fportlet_jsp.java:1215)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)



Is there any solution for this error..???
thumbnail
David H Nebinger, módosítva 11 év-val korábban

RE: ERROR : java.lang.StackOverflowError

Liferay Legend Bejegyzések: 14918 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
Of course you get a stack overflow... You have EntityLocalServiceImpl.findAll() calling EntityLocalServiceUtil.findAll(), but EntityLocalServiceUtil.findAll() will actually end up calling EntityLocalServiceImpl.findAll(), and you've created a nasty loop.

The EntityLocalServiceImpl can use the entityPersistence member variable to do the retrieve.

The JSP would use EntityLocalServiceUtil to call the method.
Kevin Shah, módosítva 11 év-val korábban

RE: ERROR : java.lang.StackOverflowError

New Member Bejegyzések: 7 Csatlakozás dátuma: 2012.07.20. Legújabb bejegyzések
Hello David, Hello Hitoshi,

Thank you very much.
Yes you are absolutely right.

I found my problem...

I am very much appreciating efforts of this forum.

Thank you again....
thumbnail
Hitoshi Ozawa, módosítva 11 év-val korábban

RE: ERROR : java.lang.StackOverflowError

Liferay Legend Bejegyzések: 7942 Csatlakozás dátuma: 2010.03.24. Legújabb bejegyzések
What David means in shorter sentence is just to write the following in your jsp.

List<Entity> list = EntityLocalServiceUtil.findAll();
Smilelws2010 lwz, módosítva 11 év-val korábban

RE: ERROR : java.lang.StackOverflowError

Regular Member Bejegyzések: 160 Csatlakozás dátuma: 2010.12.16. Legújabb bejegyzések
HI David, Hitoshi,

I have a similar question, I have the following method in my entityServiceimpl class

public void updateEmailVerification(String validationCode) throws SystemException, PortalException {
ServiceContext serviceContext = new ServiceContext();
List<EmailSubscription> emails = new ArrayList<EmailSubscription>();
emails = EmailSubscriptionLocalServiceUtil.findByValidationCode(validationCode);
System.out.println("Inside Update verification method." +serviceContext);
if (emails != null) {
for (EmailSubscription sub: emails) {
long subscriptionID = sub.getSubscriptionId();
String userEmail = sub.getUserEmail();
String subscriptionCategory = sub.getSubscriptionCategory();
String activeStatus ="ACTIVE";
EmailSubscriptionLocalServiceUtil.updateSubscription(subscriptionID, userEmail, subscriptionCategory, activeStatus, validationCode, serviceContext);
}
}

}

When I try to hit the method through URL it is giving me the exception {"exception":"java.lang.StackOverflowError"}. Other service methods can be invoked fine. I am wondering is that because the way I have set ServiceContext?

Need assistance.

Thanks
Smile
thumbnail
David H Nebinger, módosítva 11 év-val korábban

RE: ERROR : java.lang.StackOverflowError

Liferay Legend Bejegyzések: 14918 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
I guess this method is within the XxxLocalServiceImpl class? If so, you should not be using the EmailSubscriptionLocalServiceUtil class directly as you'll have access via internal members to get to those implementations...

Rule of thumb is the XxxLocalServiceUtil classes are only used by external methods, not by your internal methods.
Smilelws2010 lwz, módosítva 11 év-val korábban

RE: ERROR : java.lang.StackOverflowError

Regular Member Bejegyzések: 160 Csatlakozás dátuma: 2010.12.16. Legújabb bejegyzések
Thanks a lot David. That makes sense.

Also I had some errors referencing the function too.

Thanks
Smile
Smilelws2010 lwz, módosítva 11 év-val korábban

RE: ERROR : java.lang.StackOverflowError

Regular Member Bejegyzések: 160 Csatlakozás dátuma: 2010.12.16. Legújabb bejegyzések
David,

I am planning to have the below method in my XxxServiceImpl class (I have remote-service=true in service.xml). Basically I want to directlry hit this URL from outside the portlet, by clicking a link say in an email. It will only have some id as a parameter to the method.

I want to update the database record whenever the method is hit for a particular code/id. To update I need servicecontext instance. I am just doing ]ServiceContext serviceContext = new ServiceContext() without any request objet attached. There is no actionRequest etc associated when the method is called, as it is being called from a link outside the portlet. When I try the below, it is not updating the record, basically I am trying to change the status of 'activeSatus' from inactive to active when the method is being called with a particular verification code Could you help?

Thanks
Smile


public void updateEmailVerification(String validationCode) throws SystemException, PortalException {
ServiceContext serviceContext = new ServiceContext();
List<EmailSubscription> emails = new ArrayList<EmailSubscription>();
emails = EmailSubscriptionLocalServiceUtil.findByValidationCode(validationCode);
System.out.println("Inside Update verification method." +serviceContext);
if (emails != null) {
for (EmailSubscription sub: emails) {
long subscriptionID = sub.getSubscriptionId();
String userEmail = sub.getUserEmail();
String subscriptionCategory = sub.getSubscriptionCategory();
String activeStatus ="ACTIVE";
EmailSubscriptionLocalServiceUtil.updateSubscription(subscriptionID, userEmail, subscriptionCategory, activeStatus, validationCode, serviceContext);
}
}

}