Fórum

java.lang.IllegalStateException: Page needs a session and none is available

user1 liferay, modificado 10 Anos atrás.

java.lang.IllegalStateException: Page needs a session and none is available

Junior Member Postagens: 28 Data de Entrada: 17/02/14 Postagens Recentes
Does anyone no how to overcome the below error.

I am storing a session attribute using @sessionAttribute.. it was working fine until i added another portlet that does not have any session info.
NOTE: This occurs only once or twice, when we start the server ,+ if the user is not logged in ..when the value of the model attribute in the session is null.


17:33:11,766 ERROR [RuntimePageImpl-6][IncludeTag:129] Current URL null generates exception: java.lang.IllegalStateException: Page needs a session and none is available
java.lang.IllegalStateException: Page needs a session and none is available
	at org.apache.jasper.runtime.PageContextImpl._initialize(PageContextImpl.java:148)
	at org.apache.jasper.runtime.PageContextImpl.initialize(PageContextImpl.java:125)
	at org.apache.jasper.runtime.JspFactoryImpl.internalGetPageContext(JspFactoryImpl.java:112)
	at org.apache.jasper.runtime.JspFactoryImpl.getPageContext(JspFactoryImpl.java:65)
	at com.liferay.portal.kernel.servlet.JspFactoryWrapper.getPageContext(JspFactoryWrapper.java:63)
	at org.apache.jsp.html.common.themes.portlet_jsp._jspService(portlet_jsp.java:419)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	at com.liferay.portal.servlet.DirectRequestDispatcher.include(DirectRequestDispatcher.java:57)
	at com.liferay.portal.servlet.ClassLoaderRequestDispatcherWrapper.doDispatch(ClassLoaderRequestDispatcherWrapper.java:78)
	at com.liferay.portal.servlet.ClassLoaderRequestDispatcherWrapper.include(ClassLoaderRequestDispatcherWrapper.java:53)
	at com.liferay.taglib.util.IncludeTag.include(IncludeTag.java:295)
	at com.liferay.taglib.util.IncludeTag.doInclude(IncludeTag.java:192)
	at com.liferay.taglib.util.IncludeTag.doEndTag(IncludeTag.java:83)
	at org.apache.jsp.html.portal.render_005fportlet_jsp._jspService(render_005fportlet_jsp.java:1636)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	at com.liferay.portal.servlet.DirectRequestDispatcher.include(DirectRequestDispatcher.java:57)
	at com.liferay.portal.servlet.ClassLoaderRequestDispatcherWrapper.doDispatch(ClassLoaderRequestDispatcherWrapper.java:78)
	at com.liferay.portal.servlet.ClassLoaderRequestDispatcherWrapper.include(ClassLoaderRequestDispatcherWrapper.java:53)
donino pienni, modificado 10 Anos atrás.

RE: java.lang.IllegalStateException: Page needs a session and none is avail

Junior Member Postagens: 81 Data de Entrada: 02/07/11 Postagens Recentes
Hi,

I am also facing the same issue. I have an application which stores session attributes, and this error is logged sometimes. It seems to occur just after a user has logged in, and then access a page containing a portlet storing a session attribute.

Do someone has a workaround for this?

Thanks!
donino pienni, modificado 10 Anos atrás.

RE: java.lang.IllegalStateException: Page needs a session and none is avail

Junior Member Postagens: 81 Data de Entrada: 02/07/11 Postagens Recentes
It seems this happens when the first page accessed by a user is taken from the browser cache, and if this page has a portlet making use of a JSP dispatcher
user1 liferay, modificado 10 Anos atrás.

RE: java.lang.IllegalStateException: Page needs a session and none is avail

Junior Member Postagens: 28 Data de Entrada: 17/02/14 Postagens Recentes
Were you able to find a solution?,

My understanding was that, this error occurred when there were 2 or more portlets with some portlets accessing the session while the others needed none.
donino pienni, modificado 10 Anos atrás.

RE: java.lang.IllegalStateException: Page needs a session and none is avail

Junior Member Postagens: 81 Data de Entrada: 02/07/11 Postagens Recentes
Unfortunately no i have not found a solution.

The error still appears sometimes in logs. I am nearly sure it has something to do with client-side cache of web-browsers, but it is so sporadic i can't find a way to reproduce it systematically. I tried to turn off cookies persistence in portal-ext.properties, it didn't help. What i don't understand is, when it occurs everything works fine the page is displayed properly.
donino pienni, modificado 9 Anos atrás.

RE: java.lang.IllegalStateException: Page needs a session and none is avail

Junior Member Postagens: 81 Data de Entrada: 02/07/11 Postagens Recentes
Hi,

I have something new about this. In my case, setting render-weight property to 0 workarounds the problem (in liferay-portlet.xml of portlets involved). Problem is, 0 value means portlets are rendered in parallel: the behavior and the look of the page display is quite different.

Another option is to set a different render-weight for each portlet, for example:

portlet A => <render-weight>1</render-weight>
portlet B => <render-weight>2</render-weight>

It works, but if a unique portlet is set as "instanceable" and appears multiple times on a page, then render-weight to 0 seems to be the only workaround.

Why does it only occurs sometimes, i am not sure. In my case this issue happens when a server cache has expired or has been cleared, leading both portlet threads in a "synchronized" block for a few seconds. This is why it was so difficult to reproduce.

I hope this might help other people, and may be help Liferay team to investigate.
user1 liferay, modificado 9 Anos atrás.

RE: java.lang.IllegalStateException: Page needs a session and none is avail

Junior Member Postagens: 28 Data de Entrada: 17/02/14 Postagens Recentes
Thanks for your reply Donino
I will try and use this in my project. Will let u know if this works for me.
thumbnail
Ankit Chaudhari, modificado 9 Anos atrás.

RE: java.lang.IllegalStateException: Page needs a session and none is avail

New Member Postagens: 20 Data de Entrada: 06/03/14 Postagens Recentes
I am facing this problem too.

has anyone found a fix for this?
donino pienni, modificado 9 Anos atrás.

RE: java.lang.IllegalStateException: Page needs a session and none is avail

Junior Member Postagens: 81 Data de Entrada: 02/07/11 Postagens Recentes
Ankit Chaudhari:
I am facing this problem too.

has anyone found a fix for this?


Try to add this in your portal-ext.properties:

layout.parallel.render.timeout=30000


Default is 5000ms. With this setup you should never see this error in your logs anymore .
Traolly Xiong, modificado 9 Anos atrás.

RE: java.lang.IllegalStateException: Page needs a session and none is avail

Regular Member Postagens: 195 Data de Entrada: 30/12/11 Postagens Recentes
My only question would be why was this not a problem in 6.1, but seems like it's a problem in 6.2 that this parameter would be needed?

Thanks in advance.
thumbnail
Juan Gonzalez, modificado 9 Anos atrás.

RE: java.lang.IllegalStateException: Page needs a session and none is avail

Liferay Legend Postagens: 3089 Data de Entrada: 28/10/08 Postagens Recentes
Parallel rendering is a new feature in 6.2, implemented as part of LPS-27503
Marta Figueras, modificado 4 Anos atrás.

RE: java.lang.IllegalStateException: Page needs a session and none is avail

Junior Member Postagens: 31 Data de Entrada: 23/03/17 Postagens Recentes
Thank you so much, it was really helpful!
thumbnail
Andreas Lecerof, modificado 9 Anos atrás.

RE: java.lang.IllegalStateException: Page needs a session and none is avail

Junior Member Postagens: 36 Data de Entrada: 14/02/13 Postagens Recentes
We have also encountered the same problem.
The solution we are thinking of is disabling parallel rendering by setting
layout.parallel.render.enable=false
The error "page needs a session" seems to disappear after we have disabled parallel rendering.
Another solution would be to increase the value of layout.parallel.render.timeout
but the problem is how much should it be increased?

Since parallel rendering is only available on Tomcat, see PortletContainerUtil - setupOptionalRenderParameters,
the question is how much (if any?) you will benefit from parallel rendering.

Best regards,
Andreas
thumbnail
Kiran Yalavali, modificado 8 Anos atrás.

RE: java.lang.IllegalStateException: Page needs a session and none is avail

Regular Member Postagens: 175 Data de Entrada: 15/10/14 Postagens Recentes
Hi Andreas,

I added this setting layout.parallel.render.enable=false in portal-ext.properties now page needs a session error is not displaying so my problem is solved.

Thank you Andreas,



Thanks,
kiran.
kavya m, modificado 7 Anos atrás.

RE: java.lang.IllegalStateException: Page needs a session and none is avail

New Member Postagens: 15 Data de Entrada: 08/07/16 Postagens Recentes
hi...
I got same error in log file. After adding layout.parallel.render.enable=false in portal-ext.properties it works, now it is not showing that message. But my problem is it showing other errors. Please help me

05:47:36,175 WARN [RuntimePageImpl-4][BasicResourcePool:678] com.mchange.v2.resourcepool.BasicResourcePool@671e3091 -- an attempt to checkout a resource was interrupted, and the pool is still live: some other thread must have either interrupted the Thread attempting checkout!
java.lang.InterruptedException


05:47:36,693 ERROR [RuntimePageImpl-4][JDBCExceptionReporter:82] An SQLException was provoked by the following failure: java.lang.InterruptedException
05:47:52,843 ERROR [RuntimePageImpl-4][IncludeTag:129] Current URL null generates exception: com.liferay.portal.kernel.exception.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.exception.GenericJDBCException: could not execute query
java.lang.InterruptedException
at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:628)
at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:633)
at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:633)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:526)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutAndMarkConnectionInUse(C3P0PooledConnectionPool.java:755)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:682)
at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:140)
at com.liferay.portal.dao.jdbc.util.DataSourceWrapper.getConnection(DataSourceWrapper.java:39)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:534)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:452)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1700)
at org.hibernate.loader.Loader.doQuery(Loader.java:801)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.doList(Loader.java:2542)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.hql.classic.QueryTranslatorImpl.list(QueryTranslatorImpl.java:940)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1268)