Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
Kevin Shah
ERROR : java.lang.StackOverflowError
20 luglio 2012 21.47
Risposta

Kevin Shah

Punteggio: New Member

Messaggi: 7

Data di Iscrizione: 20 luglio 2012

Messaggi recenti

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..???
David H Nebinger
RE: ERROR : java.lang.StackOverflowError
20 luglio 2012 22.08
Risposta

David H Nebinger

Community Moderator

Punteggio: Liferay Legend

Messaggi: 11056

Data di Iscrizione: 1 settembre 2006

Messaggi recenti

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.
Hitoshi Ozawa
RE: ERROR : java.lang.StackOverflowError
20 luglio 2012 22.13
Risposta

Hitoshi Ozawa

Punteggio: Liferay Legend

Messaggi: 7949

Data di Iscrizione: 23 marzo 2010

Messaggi recenti

What David means in shorter sentence is just to write the following in your jsp.

List<Entity> list = EntityLocalServiceUtil.findAll();
Kevin Shah
RE: ERROR : java.lang.StackOverflowError
20 luglio 2012 22.20
Risposta

Kevin Shah

Punteggio: New Member

Messaggi: 7

Data di Iscrizione: 20 luglio 2012

Messaggi recenti

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....
Smilelws2010 lwz
RE: ERROR : java.lang.StackOverflowError
1 marzo 2013 10.56
Risposta

Smilelws2010 lwz

Punteggio: Regular Member

Messaggi: 160

Data di Iscrizione: 16 dicembre 2010

Messaggi recenti

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
David H Nebinger
RE: ERROR : java.lang.StackOverflowError
4 marzo 2013 5.28
Risposta

David H Nebinger

Community Moderator

Punteggio: Liferay Legend

Messaggi: 11056

Data di Iscrizione: 1 settembre 2006

Messaggi recenti

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
RE: ERROR : java.lang.StackOverflowError
4 marzo 2013 6.39
Risposta

Smilelws2010 lwz

Punteggio: Regular Member

Messaggi: 160

Data di Iscrizione: 16 dicembre 2010

Messaggi recenti

Thanks a lot David. That makes sense.

Also I had some errors referencing the function too.

Thanks
Smile
Smilelws2010 lwz
RE: ERROR : java.lang.StackOverflowError
4 marzo 2013 6.52
Risposta

Smilelws2010 lwz

Punteggio: Regular Member

Messaggi: 160

Data di Iscrizione: 16 dicembre 2010

Messaggi recenti

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);
}
}

}