掲示板

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

10年前 に user1 liferay によって更新されました。

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

Junior Member 投稿: 28 参加年月日: 14/02/17 最新の投稿
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)
10年前 に donino pienni によって更新されました。

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

Junior Member 投稿: 81 参加年月日: 11/07/02 最新の投稿
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!
10年前 に donino pienni によって更新されました。

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

Junior Member 投稿: 81 参加年月日: 11/07/02 最新の投稿
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
10年前 に user1 liferay によって更新されました。

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

Junior Member 投稿: 28 参加年月日: 14/02/17 最新の投稿
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.
10年前 に donino pienni によって更新されました。

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

Junior Member 投稿: 81 参加年月日: 11/07/02 最新の投稿
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.
10年前 に donino pienni によって更新されました。

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

Junior Member 投稿: 81 参加年月日: 11/07/02 最新の投稿
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.
10年前 に user1 liferay によって更新されました。

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

Junior Member 投稿: 28 参加年月日: 14/02/17 最新の投稿
Thanks for your reply Donino
I will try and use this in my project. Will let u know if this works for me.
thumbnail
9年前 に Ankit Chaudhari によって更新されました。

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

New Member 投稿: 20 参加年月日: 14/03/06 最新の投稿
I am facing this problem too.

has anyone found a fix for this?
9年前 に donino pienni によって更新されました。

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

Junior Member 投稿: 81 参加年月日: 11/07/02 最新の投稿
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 .
9年前 に Traolly Xiong によって更新されました。

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

Regular Member 投稿: 195 参加年月日: 11/12/30 最新の投稿
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
9年前 に Juan Gonzalez によって更新されました。

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

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
Parallel rendering is a new feature in 6.2, implemented as part of LPS-27503
4年前 に Marta Figueras によって更新されました。

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

Junior Member 投稿: 31 参加年月日: 17/03/23 最新の投稿
Thank you so much, it was really helpful!
thumbnail
9年前 に Andreas Lecerof によって更新されました。

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

Junior Member 投稿: 36 参加年月日: 13/02/14 最新の投稿
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
8年前 に Kiran Yalavali によって更新されました。

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

Regular Member 投稿: 175 参加年月日: 14/10/15 最新の投稿
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.
7年前 に kavya m によって更新されました。

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

New Member 投稿: 15 参加年月日: 16/07/08 最新の投稿
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)