Bug - Not A Bug Mafia won't open (explain like I'm an idiot please)

jaeshala

New member
I downloaded Mafia. I downloaded Java, after I was told that I needed a Java to run Mafia. Both of them the latest versions, as far as I can tell. I'm right-clicking "open with>Java" on the Mafia folder, and I just get "a Java exception occurred".


I know zero about coding, but my clannies who use Mafia tell me I shouldn't need to know anything, I should just be able to open it. I don't know what to do from here.
 

Ryo_Sangnoir

Developer
Staff member
First of all, rather than opening the Mafia _folder_, you should run Mafia by opening the Mafia _jar_, which you should put somewhere writable (e.g. in a new folder inside your user directory). Mafia creates lots of folders in various locations when it runs, so it's good to have it in its own folder (on Windows -- other OSes create the folders in fixed locations). I tend to open the jar by double-clicking it.

Which OS are you running? Windows, Mac, some Linux?

Second of all, we're not really supporting Java 21 yet. Lots of people have it work for them, and it may work for you, but you might want to install Java 17 instead, which you can do from Adoptium (which is also the recommended source for Java 21). You can do that at https://adoptium.net/temurin/releases/?version=17
 

jaeshala

New member
I'm on Windows 11.

thank you, downloading the version 17 works, at least for opening it.
I still can't log in though, it "cannot acquire a file lock" for my username. I assume it uses the same username/password that your KoL account does?
 
Where did you put the JAR or mafia folder? is it in a system folder? Also if you go to task manager is there a java process there even with mafia closed?
 

fronobulax

Developer
Staff member
I'm on Windows 11.

thank you, downloading the version 17 works, at least for opening it.
I still can't log in though, it "cannot acquire a file lock" for my username. I assume it uses the same username/password that your KoL account does?

The most common cause is putting the mafia jar file in a directory that the user (as defined by the operating system) cannot write files to. Creating a KoLmafia folder in your Documents directory would be one thing to try. Not recommended but running as an Administrator is another.
 

jaeshala

New member
Where did you put the JAR or mafia folder? is it in a system folder? Also if you go to task manager is there a java process there even with mafia closed?
I put it on my desktop.
The most common cause is putting the mafia jar file in a directory that the user (as defined by the operating system) cannot write files to. Creating a KoLmafia folder in your Documents directory would be one thing to try. Not recommended but running as an Administrator is another.

I sent it to Documents but nothing's changed.
 

fronobulax

Developer
Staff member
Windows 10 is pretty picky about what is allowed to create files on the Desktop.

I created C:\Users\frono\Documents\experiment
The directory is empty.
I copied/moved a KoLmafia jar file there. There is one file.

Code:
 Directory of C:\Users\frono\Documents\experiment

01/19/2024  09:19 AM    <DIR>          .
01/19/2024  09:19 AM    <DIR>          ..
01/19/2024  08:11 AM        27,819,980 KoLmafia-27809.jar
               1 File(s)     27,819,980 bytes
               2 Dir(s)  34,563,923,968 bytes free

I started KoLmafia by double-clicking on it.

I got the login screen and the preferences screen. I exited rather than log in.

The directory contents are now:
Code:
 Directory of C:\Users\frono\Documents\experiment

01/19/2024  09:21 AM    <DIR>          .
01/19/2024  09:21 AM    <DIR>          ..
01/19/2024  09:22 AM    <DIR>          data
01/19/2024  09:21 AM    <DIR>          images
01/19/2024  08:11 AM        27,819,980 KoLmafia-27809.jar
01/19/2024  09:21 AM    <DIR>          relay
01/19/2024  09:21 AM    <DIR>          scripts
01/19/2024  09:21 AM    <DIR>          settings
               1 File(s)     27,819,980 bytes
               7 Dir(s)  34,562,371,584 bytes free

If you try and do the same thing you should have the same directories created.

If you do not have the same directories then creating a directory is part of the problem. usually it is a permissions problem - the operating system User is not allowed to create/write in that directory. In a few cases the operating system thought there was no space on the disk and thus could not create a directory or a file. There are probably other more obscure causes.

Since this is a new install and I didn't log in there is no sessions subdirectory. When I started KoLmafia up and logged in my anti-virus popped up and said I needed to allow KoLmafia to create a file. So an antivirus product may be overly aggressive.

After a normal login the sessions directory looks like
Code:
Directory of C:\Users\frono\Documents\experiment\sessions

01/19/2024  09:33 AM    <DIR>          .
01/19/2024  09:33 AM    <DIR>          ..
01/19/2024  09:33 AM                17 active_session.fronobulax
01/19/2024  09:33 AM                 0 fronobulax_20240119.txt
               2 File(s)             17 bytes
               2 Dir(s)  34,560,077,824 bytes free


The "Could not acquire file lock for " message occurs when the active_session file for the user cannot be created, if it doesn't exist, or if it is being used by something else, if it does exist. if the something else is another existence of KoLmafia then shut them all down and try again. The nuclear option would be to reboot the computer which should have the side effect of shutting down anything that did not exit normally and so was holding the file lock.

Perhaps you could try a similar experiment? If you don't get similar results then that tells us something. If you do get similar results then we may need to focus on how you launch KoLmafia and what it is using for Java.
 

jaeshala

New member
I started KoLmafia by double-clicking on it.

Double clicking just opens it up in Winrar... should I have it saved in a different form? (I don't know how to save it in a different form, that's just how it downloaded).
 

fronobulax

Developer
Staff member
Double clicking just opens it up in Winrar
That is a concern. If the file is truly a jar file then it should have an extension of jar and open with Java.

Right click, Open With, and navigate so it opens with java.exe where ever that is on the system. If it works do it again and this time click the Always use checkbox. Don't take me too literally since I am speaking from memory and Windows 10.
 

jaeshala

New member
Windows 10 is pretty picky about what is allowed to create files on the Desktop.

I created C:\Users\frono\Documents\experiment
The directory is empty.
I copied/moved a KoLmafia jar file there. There is one file.

Code:
 Directory of C:\Users\frono\Documents\experiment

01/19/2024  09:19 AM    <DIR>          .
01/19/2024  09:19 AM    <DIR>          ..
01/19/2024  08:11 AM        27,819,980 KoLmafia-27809.jar
               1 File(s)     27,819,980 bytes
               2 Dir(s)  34,563,923,968 bytes free

I started KoLmafia by double-clicking on it.

I got the login screen and the preferences screen. I exited rather than log in.

The directory contents are now:
Code:
 Directory of C:\Users\frono\Documents\experiment

01/19/2024  09:21 AM    <DIR>          .
01/19/2024  09:21 AM    <DIR>          ..
01/19/2024  09:22 AM    <DIR>          data
01/19/2024  09:21 AM    <DIR>          images
01/19/2024  08:11 AM        27,819,980 KoLmafia-27809.jar
01/19/2024  09:21 AM    <DIR>          relay
01/19/2024  09:21 AM    <DIR>          scripts
01/19/2024  09:21 AM    <DIR>          settings
               1 File(s)     27,819,980 bytes
               7 Dir(s)  34,562,371,584 bytes free

If you try and do the same thing you should have the same directories created.

If you do not have the same directories then creating a directory is part of the problem. usually it is a permissions problem - the operating system User is not allowed to create/write in that directory. In a few cases the operating system thought there was no space on the disk and thus could not create a directory or a file. There are probably other more obscure causes.

Since this is a new install and I didn't log in there is no sessions subdirectory. When I started KoLmafia up and logged in my anti-virus popped up and said I needed to allow KoLmafia to create a file. So an antivirus product may be overly aggressive.

After a normal login the sessions directory looks like
Code:
Directory of C:\Users\frono\Documents\experiment\sessions

01/19/2024  09:33 AM    <DIR>          .
01/19/2024  09:33 AM    <DIR>          ..
01/19/2024  09:33 AM                17 active_session.fronobulax
01/19/2024  09:33 AM                 0 fronobulax_20240119.txt
               2 File(s)             17 bytes
               2 Dir(s)  34,560,077,824 bytes free


The "Could not acquire file lock for " message occurs when the active_session file for the user cannot be created, if it doesn't exist, or if it is being used by something else, if it does exist. if the something else is another existence of KoLmafia then shut them all down and try again. The nuclear option would be to reboot the computer which should have the side effect of shutting down anything that did not exit normally and so was holding the file lock.

Perhaps you could try a similar experiment? If you don't get similar results then that tells us something. If you do get similar results then we may need to focus on how you launch KoLmafia and what it is using for Java.

Okay, that worked. I think. At least, I created new folder on my desktop and put Mafia in the desktop and then I was able to log in. Thank you!
 
Top