Bug - Fixed mafia fails on login when it cannot open window in CLI mode

cankergoyle

New member
Upon upgrading this past week, I now find that my cronjob-run CLI-mode buffbot script fails due to
mafia wanting to initiate a logout command prior to a cli_execute("login user") command (weird). The logout command somehow requires a window launch that is unallowed within a cronjob, leading mafia to abort the script instantly. Bug or new "feature"?

Debug report below:

Unexpected error, debug log printed.
class java.lang.ExceptionInInitializerError: null
java.lang.ExceptionInInitializerError
at net.sourceforge.kolmafia.request.LogoutRequest.run(LogoutRequest.java:76)
at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:73)
at net.sourceforge.kolmafia.KoLmafia.logout(KoLmafia.java:3098)
at net.sourceforge.kolmafia.textui.command.LoginCommand.run(LoginCommand.java:48)
at net.sourceforge.kolmafia.KoLmafiaCLI.executeCommand(KoLmafiaCLI.java:538)
at net.sourceforge.kolmafia.KoLmafiaCLI.executeLine(KoLmafiaCLI.java:412)
at net.sourceforge.kolmafia.textui.RuntimeLibrary.cli_execute(RuntimeLibrary.java:1474)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at net.sourceforge.kolmafia.textui.parsetree.LibraryFunction.execute(LibraryFunction.java:119)
at net.sourceforge.kolmafia.textui.parsetree.FunctionCall.execute(FunctionCall.java:166)
at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:451)
at net.sourceforge.kolmafia.textui.parsetree.UserDefinedFunction.execute(UserDefinedFunction.java:129)
at net.sourceforge.kolmafia.textui.Interpreter.executeScope(Interpreter.java:265)
at net.sourceforge.kolmafia.textui.Interpreter.execute(Interpreter.java:198)
at net.sourceforge.kolmafia.textui.Interpreter.execute(Interpreter.java:191)
at net.sourceforge.kolmafia.textui.command.CallScriptCommand.call(CallScriptCommand.java:194)
at net.sourceforge.kolmafia.textui.command.CallScriptCommand.run(CallScriptCommand.java:63)
at net.sourceforge.kolmafia.KoLmafiaCLI.executeCommand(KoLmafiaCLI.java:538)
at net.sourceforge.kolmafia.KoLmafiaCLI.executeLine(KoLmafiaCLI.java:412)
at net.sourceforge.kolmafia.KoLmafia.main(KoLmafia.java:508)
Caused by: java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:173)
at java.awt.Window.<init>(Window.java:437)
at java.awt.Frame.<init>(Frame.java:419)
at java.awt.Frame.<init>(Frame.java:384)
at javax.swing.JFrame.<init>(JFrame.java:174)
at net.sourceforge.kolmafia.swingui.GenericFrame.<init>(GenericFrame.java:125)
at net.sourceforge.kolmafia.swingui.ContactListFrame.<init>(ContactListFrame.java:70)
at net.sourceforge.kolmafia.chat.ChatManager.<clinit>(ChatManager.java:92)
 

Veracity

Developer
Staff member
I assume this is related to Grotfang's bug report that KoLmafia no longer works correctly in headless mode. In fact, looking at your stack trace, I see a HeadlessException right there. Interesting that you failed on login and he got farther...

I'm going to merge the two bug reports and ping holatuwol.

Edit: I unmerged them, since you also have the "logout" issue in here - which is weird. I still think the reports are related.
 
Last edited:

cankergoyle

New member
yes, i think that the CLI logout command (which is part of CLI login for completeness I guess) was changed to unintentionally request a GUI, which breaks the intent of headless mode.
 

Grotfang

Developer
V -- it is the same issue, as far as I'm aware. I just ran mine from my windows machine without a login script to grab a quick debug log to see what was failing. As far as I'm aware, the logout issue has always existed (as does starting chat) which is what I had worked around with the useGUI preference before Hola added the trivia game. Since the trivia game has been added, login itself cannot run without throwing an exception.
 

Veracity

Developer
Staff member
Hola released revision 9011: "9011: Fix inability to startup KoLmafia with -Djava.awt.headless=true".
 
Top