fusesource / jansi

Jansi is a small java library that allows you to use ANSI escape sequences to format your console output which works even on windows.
http://fusesource.github.io/jansi/
Apache License 2.0
1.11k stars 140 forks source link

TOMCAT JANSI UNDEPLOY PROBLEM #191

Closed tugalsan closed 3 years ago

tugalsan commented 3 years ago

Hello,

I am using your library to color my debug console of TOMCAT using XAMPP v3.2.4

I have an ServletContextListener implementation to add custom code on contextInitialized and contextDestroyed as below

import static org.fusesource.jansi.Ansi.ansi;
import static org.fusesource.jansi.Ansi.Color.*;
import org.fusesource.jansi.AnsiConsole;

   @Override
    public void contextInitialized(ServletContextEvent evt) {
         AnsiConsole.systemInstall();
    }

    @Override
    public void contextDestroyed(ServletContextEvent evt) {
        System.out.print(ansi().fg(WHITE).boldOff());
        AnsiConsole.systemUninstall();
    }

When i upload new war file on TOMCAT, all files are removed except jansi-2.1.0.jar So I have to manually stop tomcat, delete project folder and restart tomcat again.

Am I doing sth wrong? Or the error is on smw else?

PC: XAMPP v3.2.4 & GWT & AdoptJDK 14 hotspot & Windows 10 Pro

gnodet commented 3 years ago

Do you really need to use the AnsiConsole.systemInstall() call ? If running in a web app, tomcat usually does not have any console, as it is started as a service, so you don't need to call systemInstall() at all.

Anyway, the problem is that the JVM most probably has a reference to the class loader and thus still holds a lock. Using a profile might help to see where it comes from.

Another possibility would be to add jansi to the tomcat parent classloader to avoid the problem.