exception loading sessions from persistent storage - java

I have made many changes to the spring petclinic application. At the moment, I am getting the following error message when I launch the application in a new instance of tomcat server using eclipse run as...run on server:
SEVERE: Exception loading sessions from persistent storage
The server and application then subsequently are able to launch successfully, but I would like to fix whatever is causing the error message. Can anyone show me how to get past this error message?
The stack trace does not list any file from the application, so I don't know where to look in the application code to fix the problem. You can look in the petclinic code at github to see the structure of the application, if that helps you see where I should look to find the problem. Here is the stack trace:
INFO EhCacheManagerFactoryBean - Initializing EhCache CacheManager
INFO ContextLoader - Root WebApplicationContext: initialization completed in 4376 ms
Dec 16, 2013 2:51:56 PM org.apache.catalina.session.StandardManager doLoad
SEVERE: IOException while loading persisted sessions: java.io.EOFException
java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2280)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2749)
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:779)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:279)
at org.apache.catalina.util.CustomObjectInputStream.<init>(CustomObjectInputStream.java:58)
at org.apache.catalina.session.StandardManager.doLoad(StandardManager.java:246)
at org.apache.catalina.session.StandardManager.load(StandardManager.java:204)
at org.apache.catalina.session.StandardManager.startInternal(StandardManager.java:491)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5443)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Dec 16, 2013 2:51:56 PM org.apache.catalina.session.StandardManager startInternal
SEVERE: Exception loading sessions from persistent storage
java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2280)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2749)
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:779)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:279)
at org.apache.catalina.util.CustomObjectInputStream.<init>(CustomObjectInputStream.java:58)
at org.apache.catalina.session.StandardManager.doLoad(StandardManager.java:246)
at org.apache.catalina.session.StandardManager.load(StandardManager.java:204)
at org.apache.catalina.session.StandardManager.startInternal(StandardManager.java:491)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5443)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Dec 16, 2013 2:51:56 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'petclinic'

This is to do with Tomcat not being able to load previously serialized web sessions that had been saved on an earlier shutdown. This may be because Tomcat didn't shutdown cleanly and so session objects got corrupted during serialization.
One way to make this error go away would be to disable session persistence across restarts. You can do this by editing the file CATALINA_HOME/conf/context.xml and setting the pathname attribute of the <Manager> to an empty string. This is well documented in the file for Tomcat 7:
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<Manager pathname="" />
You should also delete any old session.ser files from the CATALINA_HOME/work/Catalina/localhost/<appName> folder whilst Tomcat is shutdown.
This may not be acceptable in your case if session persistence across restarts is needed. In which case further debugging of the issue would be necessary.

Delete tomcat "work" folder. Restart tomcat server, hopefully now it'll run without any exception or error!
This can be done by selecting the server within Tomcat and selecting "Clean Tomcat Work Directory"

If you are working with Spring Boot, just add it to the application.properties:
server.servlet.session.persistent=false

Just Clean the Tomcat Work Directory..which is worked well to me.

It is Simply just Because Persist Class was not Serialize Properly just Stop Apache. Remove Project and Clean Project and Server as well.
and Just Redeploy Here its Done. good luck.

I had a similar error with a project in eclipse. I solved it with these steps:
Make a clean to the project
Delete the Tomcat server at the server view of eclipse
Define a new Tomcat server at the server view of eclipse using the wizard
Add the project to the newly defined Tomcat server
After that, running this new Tomcat server all worked perfectly.

-The class should implement Serializable interface with serialVersionUID.
- Do the clean build and restart the server

In Spring boot you #ResponseBody annotation on your #GetMapping endpoint.

Related

Netbeans-Glassfish: Preserve Session Across Redeployment failed

My java web app has session checking. Every time I save, it redeploys. I've already checked the option in netbeans "Preserve Session Across Redeployment" but when i looked the logged. I have this error
Info: Initializing Mojarra 2.1.6 (SNAPSHOT 20111206) for context '/webapp'
Info: Running on PrimeFaces 3.4.2
Severe: PWC2768: IOException while loading persisted sessions: java.io.EOFException
java.io.EOFException
at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2553)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1296)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946) ...
and further down the log
Warning: WEB0517: Unable to restore sessions for web module [/webapp] from previous deployment
java.io.EOFException
at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2553)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1296)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946)
so every time I save java files, I need to login again.
How can I solve this. Thanks

RuntimeException when running Servlet: Tomcat restarting on its own

I am new to servlets and using Tomcat version 7.0.34 (we were instructed to use this version only). My problem is that the Tomcat seems to restart at some point of time, this occurs when I don't interact with the servlet for some time. I see the following:
.
Further when I tried debugging through eclipse I see the following entries in the debug window:
Daemon Thread [http-bio-80-exec-1] (Suspended (exception RuntimeException))
ThreadPoolExecutor(ThreadPoolExecutor).runWorker(ThreadPoolExecutor$Worker) line: not available
ThreadPoolExecutor$Worker.run() line: not available
TaskThread(Thread).run() line: not available
And this in console:
SEVERE: The web application [/csj] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation.
Okt 03, 2016 1:39:39 AM org.apache.catalina.core.StandardContext reload
INFO: Reloading Context with name [/csj] is completed
I want to know the reason why Tomcat is restarting. If I keep clicking the buttons with no delays, then this problem is not seen.
I tried looking here: Tomcat showing this error "This is very likely to create a memory leak". How to resolve this issue? and here: The web application [ROOT] is still processing a request that has yet to finish. [Tomcat] but I am at loss to understand.
It seems this problem is solved in newer version of Tomcat as per this:http://wiki.apache.org/tomcat/MemoryLeakProtection . Nevertheless I would like to understand what is this problem about.
Edit: Using eclipse-mars
Your tomcat is configured for "hot deploy" i.e. if you change code, tomcat will incorporate new code without a server restart. This can be configured on tomcat, or in eclipse. You can go there and disable this as it is actually a headache and consumes more time, and sometimes doesn't work correctly.
Tomcat loads each webapp using a separate classloader. It monitors your files for changes, and if a change happens, it unloads your webapp by destroying the classloader, and loads again using a new class loader. When this is happening, you will see all kinds of logs as you mentioned.
For eclipse configuration, see here
For tomcat configuration, see here
Also, from Tomcat docs, read this
In server.xml, set reloadable="false".
From https://tomcat.apache.org/tomcat-5.5-doc/config/context.html
Set to true if you want Catalina to monitor classes in /WEB-INF/classes/ and /WEB-INF/lib for changes, and automatically reload the web application if a change is detected. This feature is very useful during application development, but it requires significant runtime overhead and is not recommended for use on deployed production applications. That's why the default setting for this attribute is false. You can use the Manager web application, however, to trigger reloads of deployed applications on demand.

Tomcat webapp hanging on Bean Registration

I'm trying to deploy a war file that I put in the webapps directory. The logfile seems to indicate that everything goes OK until this step:
2015-08-10 16:33:25,944 INFO [MBeanExporter.java:412] : Registering beans for JMX exposure on startup
And it just hangs there until the server startup timeout hits. I have no idea what could be causing this or where to look since no error gets thrown.
The hangup was related to some issue other than JMX. See this userlist discussion: https://groups.google.com/forum/#!topic/onebusaway-developers/RDX1n8zVl4U

Hibernate Exception during deploy

I´m using hibernate 4.3.6 in my vaadin project.
Every time I make changes in the sources code, it is expected that the application builds again and the new source code is deployed automatically to Tomcat. In other words, Tomcat should reload its context.
The problem is that during this operation hibernate throws an error:
GRAVE: Exception loading sessions from persistent storage
org.hibernate.HibernateException: registry does not contain entity manager factory: myproject
at org.hibernate.jpa.internal.EntityManagerFactoryRegistry.getNamedEntityManagerFactory
(...)
After that log, i get:
24/09/2014 13:14:43 org.apache.catalina.core.StandardContext reload
INFO: Reloading Context with name [/myproject] is completed
However, I cannot continue using the website, since I receive a message saying that session is lost.
My question is: what is this hibernate exception and how can I solve it?
EDIT:
This error only happens when I store in session a JPA Entity, for example: the logged user
I don´t know any way to get what you want, in Tomcat, except with JRebel. The staff of Vaadin itself uses and recommends. Link with interesting information about Vaadin+JRebel: http://zeroturnaround.com/blog/jrebel-case-study-vaadin-eliminates-redeploys-and-saves-10-of-development-time/
If in the future you decide to use Jetty instead of Tomcat, you can make settings and get dynamic reloading of the application as suggested here: https://blog.oio.de/2012/08/23/dynamic-reloading-of-vaadin-applications-with-maven-and-eclipse /

MyEclipse blue 2013 SR1 crashes on startup when no Internet connection

I have issues with MyEclipse BLUE 2013 SR1 for STRUTS2 when I try to launch it and I have no Internet connection. There are quite a few times when I am traveling and in an area where there is not a free WiFi hotspot around and I am trying to get some work done on a project - but I can't since MyEclipse crashes on start-up and gives me a dialog box pointing to a log file.
A copy of the log-file when this happens follows below:
SEVERE: Dispatcher initialization failed
Unable to load configuration. - http://struts.apache.org/dtds/struts-2.3.dtd:1:2
if internet is working project is working but without internet it is not loading ..Dispatcher initialization failed
Update
my java web project is not loading and showing following error if i disable my int
SEVERE: The markup declarations contained or pointed to by the document type declaration must be well-formed. at (-//Apache Software Foundation//DTD Struts Configuration 2.3//EN:1:2)
org.xml.sax.SAXParseException: The markup declarations contained or pointed to by the document type declaration must be well-formed.
SEVERE: Dispatcher initialization failed
Unable to load configuration. - http://struts.apache.org/dtds/struts-2.3.dtd:1:2
SEVERE: Exception starting filter struts2
Unable to load configuration. - http://struts.apache.org/dtds/struts-2.3.dtd:1:2
Umesh,
Having it crash on startup because there is no Internet connection is certainly unexpected and unusual.
1) By crash, do you mean that the workbench itself refuses to load or do you simply see an error message and can continue to use the IDE?
2) I'm assuming your Struts configuration file had been left open in the workspace when this happens?
We'll specifically try to test this case ourselves and let you know if we need more information. For direct support, do consider posting on the MyEclipse forums as well - http://myeclipseide.com/forums
Best,
Brian.

Categories

Resources