Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error on Tomcat Embedded startup

I'm working on a Spring Boot (v1.3.3.RELEASE) project. The included Tomcat Embedded version is 8.0.32.

I'm getting this error:

2016-08-01 14:51:23.354 ERROR 6704 --- [ost-startStop-1] o.a.catalina.session.StandardManager     : Exception loading sessions from persistent storage

java.io.EOFException: null
    at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2335)
    ...

I read about the same error on this question: exception loading sessions from persistent storage but I cannot find the solution to my issue.

I tried to apply the solutions suggested in the aswers, but in my case I cannot find the way to "Clean Tomcat Work Directory" or just to make a clean deploy of my application.

How can I solve this? Where can I find work folder for Tomcat Embedded version?

NOTE I'm using Eclipse as IDE

like image 250
davioooh Avatar asked Aug 01 '16 12:08

davioooh


People also ask

Why my Apache Tomcat server is not starting?

Finding cause. Most common issue with Tomcat note starting is that Java is not configured properly, user trying to start Tomcat does not have permissions to do so, or another program is using port 8080 on that server.

What does embedded Tomcat mean?

An embedded Tomcat server consists of a single Java web application along with a full Tomcat server distribution, packaged together and compressed into a single JAR, WAR or ZIP file.

Can we replace embedded Tomcat server in spring boot?

The default Embedded Web Servers in Spring-Boot is Tomcat , but you can easily change it to others.


1 Answers

I finally found the solution to my issue.

Reading the anwer to this question: How to disable Tomact session persistence in Spring Boot via Manager pathname? (suggested by AntJavaDev) I configured this bean:

@Bean
public EmbeddedServletContainerFactory servletContainer() {
    TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
    tomcat.addContextCustomizers(new TomcatContextCustomizer() {

        @Override
        public void customize(Context context) {
            if (context.getManager() instanceof StandardManager) {
                // print local path name
                System.out.println(((StandardManager) context.getManager()).getPathname());
            }
        }
    });
    return tomcat;
}

This way I discovered where cached sessions are stored for Tomcat Embedded (on Windows):

C:\Users\<my-user>\AppData\Local\Temp\<random-id>\servlet-sessions\

I deleted the SESSIONS.ser file in this folder and the error is magically disappeared.

like image 103
davioooh Avatar answered Oct 07 '22 19:10

davioooh