ClassLoader problem

Good day,
I ran into a bizare issue with the class loader. The first time I start the app server (Tomcat ) the problem is not there. The second time: boom, the third time the problem is not there, the fourth time: boom and so on. This is consistent.
I get the stack trace:

java.lang.NoClassDefFoundError: Could not initialize class nl.magsoft.admin.test_console.TestConsoleView
    nl.magsoft.admin.test_console.TestConsoleApp.init(TestConsoleApp.java:28)
    com.vaadin.ui.UI.doInit(UI.java:646)
    com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:214)
    com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(UIInitHandler.java:74)
    com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)
    com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1408)
    com.vaadin.server.VaadinServlet.service(VaadinServlet.java:350)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

The class TestConsoleView is in the same package/jar as class TestConsoleApp and when I tried to create an instance in TestConsoleApp like this:

static { new TestConsoleView () } I get null NullPointerException inside TestConsoleView suggesting that the class was loaded fine in the class loader from the startup thread (when called by com.vaadin.server.VaadinSession.readObject(VaadinSession.java:1443))

Has anyone seen and/or solved this problem?

Have not seen this behaviour in the UI.init , but I do get java.lang.ClassNotFoundException: com.vaadin.addon.charts.model.style.Color during session de-serialization using glassfish. For now we have given up on session serialization using Glassfish. I’ll probably move to WildFly once I get some free time on my hands.

I’m not sure if our issue is related to yours except for the fact that you mentioned VaadinSession.readObject

What are you doing in TestConsoleView constructor ??

Nothing special,TestConsoleView exends HorizontalLayout and creates the controls/layouts in the constructor.
TestConsoleApp has:

@Push
@SuppressWarnings("serial")
public class TestConsoleApp extends UI {
    @WebServlet(value = {"/test-console/*"}, asyncSupported = true) @VaadinServletConfiguration(productionMode = true, ui = TestConsoleApp.class, widgetset = "nl.magsoft.vaadin.AppWidgetSet")
    public static class Servlet extends VaadinServlet {
    }
    @Override protected void init(VaadinRequest request) {
            setStyleName(Reindeer.LAYOUT_BLUE);
            setContent(new TestConsoleView());
     }
 }

I had indeed something to de with session deserialisation. I could work around the problem by adding the second line in the Tomcat server.xml

<Context docBase="${catalina.home}/abc" path="" reloadable="false"> [b] <Manager pathname=""/> [/b] </Context> It seems that if the session deserializer loads the TestConsoleView class first, the classloader used by Vaadin has problems with it.