Fractal Softworks Forum

Starsector => Mods => Modding => Topic started by: Harmful Mechanic on June 07, 2019, 10:44:12 AM

Title: Bizarre loading error.
Post by: Harmful Mechanic on June 07, 2019, 10:44:12 AM
Crash to desktop on game load; progress bar makes it most of the way and then it pukes.

Posting the error log because it's a real stump-the-chump. Alterations to the ModPlugin itself don't seem to have helped; it's clearly more fundamental than that. I've narrowed it down to something I'm personally doing in this mod; just not sure what.

It seems like I made some sort of basic error that I can't track down. I've looked in CoreLifecyclePluginImpl but nothing jumps out at me. Best guess is faction-related, the game trying to verify something about the faction file it can't.

Any idea what I'm doing wrong? Or at least, where to look?

Spoiler
21981 [Thread-5] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Failed to find script of class [com.fs.starfarer.api.impl.campaign.CoreLifecyclePluginImpl]
java.lang.RuntimeException: Failed to find script of class [com.fs.starfarer.api.impl.campaign.CoreLifecyclePluginImpl]
   at com.fs.starfarer.loading.scripts.ScriptStore.new(Unknown Source)
   at com.fs.starfarer.settings.StarfarerSettings.for(Unknown Source)
   at com.fs.starfarer.launcher.ModManager.getEnabledModPlugins(Unknown Source)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Thread.java:745)
[close]
Title: Re: Bizarre loading error.
Post by: Alex on June 07, 2019, 11:02:39 AM
Just to double-check, you don't have a class named CoreLifecyclePluginImpl in your mod, do you? Also: do you have a "coreLifecyclePlugin" specified in your settings.json? (You generally speaking shouldn't.)

I'd try a clean reinstall of the game. This looks like it's failing to find a core class - and just based on the stack trace, I wouldn't have said it's mod-related - which is super weird.
Title: Re: Bizarre loading error.
Post by: Harmful Mechanic on June 07, 2019, 11:10:52 AM
No, no class by that name. I've tried reinstalling everything but the core game.

It's definitely mod related. The game loads and plays just fine without this mod enabled. What I think is happening is that I'm missing something that the game needs for the mod to pass verifyFactionData() in CoreLifecyclePluginImpl and it's choking.
Title: Re: Bizarre loading error.
Post by: Alex on June 07, 2019, 11:33:05 AM
Hmm - if verifyFactionData() threw an exception, that would be in the log, and this is not it.

At some point on startup, the game gets all the ModPlugins from the enabled mods into a list so that it can call their various methods (such as onGameLoad()) as needed. The first element in this list is the plugin specified in coreLifecyclePlugin in settings.json - the core's version of the ModPlugin, since the core also needs to do things in response to the same kind of events (onGameLoad()), etc.

The part that's failing, according to the exception, is trying to create a new instance of the class specified there, see:

Failed to find script of class [com.fs.starfarer.api.impl.campaign.CoreLifecyclePluginImpl]

The full classname appears to be correct. I'm not sure why this might happen. Some possibilities:
1) The actual class file is missing or corrupted
2) The class does not have a default constructor (it doesn't, but it also doesn't have a non-default one, so that's fine)
3) The default constructor throws an exception (I think the error would be different, and also see: it not having an explicit default constructor anyway, or any initialization code that might fail)

#1 seeming the more likely, that's why I'm recommending a reinstall of the game. It's not getting to the point where it'd try to verify faction data; that would be when you're loading an actual campaign game.

It's definitely mod related. The game loads and plays just fine without this mod enabled.

I'd still try a clean install just to rule issues with the base install out.
Title: Re: Bizarre loading error.
Post by: Harmful Mechanic on June 07, 2019, 11:52:29 AM
I thought that too, but when I have Nexerelin enabled, which *does* extend CoreLifecyclePluginImpl, *that* class (NexCoreLifecyclePlugin) is what crashes. When this new mod is disabled, Starsector works fine, with or without Nexerelin.

At this point, more than replacing the base game, replacing my new mod's files one by one until it works seems more likely to yield results.
Title: Re: Bizarre loading error.
Post by: Alex on June 07, 2019, 12:00:12 PM
May be worth checking if there are other errors/stack traces in the log prior to the crash - could be the sort of thing that gets logged but doesn't crash the game, but sets it up for this to happen later on.
Title: Re: Bizarre loading error.
Post by: Harmful Mechanic on June 07, 2019, 12:09:26 PM
Yup, tried that. A search for ERROR turns up this:

Spoiler
5238 [Thread-5] ERROR com.fs.starfarer.loading.WeaponSpreadsheetLoader  - Weapon spec [target_painter] not found in weapon_data.csv
5866 [Thread-5] ERROR com.fs.starfarer.loading.ShipHullSpreadsheetLoader  - Ship hull spec [module_hightech_decor] not found in ship_data.csv
5866 [Thread-5] ERROR com.fs.starfarer.loading.ShipHullSpreadsheetLoader  - Ship hull spec [flare] not found in ship_data.csv
7074 [Thread-5] INFO  com.fs.starfarer.loading.SpecStore  - Loaded spec with id [Terror_|_constellation]
7078 [Thread-5] INFO  com.fs.starfarer.loading.SpecStore  - Loaded spec with id [Ferror_|_star, planet, moon, nebula, constellation]
14107 [Thread-5] INFO  com.fs.graphics.TextureLoader  - Cleaned buffer for texture graphics/swp/portraits/ibb_terror.png (using cast)
19088 [Thread-5] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Failed to find script of class [exerelin.plugins.NexCoreLifecyclePlugin]
[close]

I wonder if this isn't happening because the only system file I'm adding to the mod uses procgen to assign a constellation a random position out on the fringe.
Title: Re: Bizarre loading error.
Post by: Alex on June 07, 2019, 12:22:11 PM
19088 [Thread-5] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Failed to find script of class [exerelin.plugins.NexCoreLifecyclePlugin]

Is that showing up with Nex disabled? If so: can you try moving Nex to another folder and see if that changes things?
Title: Re: Bizarre loading error.
Post by: Harmful Mechanic on June 07, 2019, 12:31:13 PM
No, with Nex disabled I get the original error - 'Failed to find script of class [com.fs.starfarer.api.impl.campaign.CoreLifecyclePluginImpl]'

And, as I said before, Nex works correctly without this new mod turned on.
Title: Re: Bizarre loading error.
Post by: Alex on June 07, 2019, 12:34:00 PM
Ah, alright, whew.

I still have no idea what's going on, and would (still) in your shoes do a clean reinstall before mucking around with anything. If something is corrupt in the install, who knows how it might manifest? Could just be randomly triggered by something innocuous in your mod. I'm not saying this *is* the problem but it's fairly low-cost to rule out... I mean, it's up to you, obviously - just saying that personally I'd do that as a sanity check because this is so freakin' weird.
Title: Re: Bizarre loading error.
Post by: Harmful Mechanic on June 07, 2019, 12:59:20 PM
Yeah, I just tried it, still getting this error.

I'm officially out of ideas, I keep digging around for requisite content I haven't added and coming up blank. All the scripts I'm using are simple reworks of stuff I already had working, so it's not likely to be those (I've gone over the scripts that seemed like likely culprits with a fine-toothed comb).

I'll let you know if/how I eventually fix it, just so no one has to ask this again.
Title: Re: Bizarre loading error.
Post by: Alex on June 07, 2019, 01:01:09 PM
If you can reproduce this on a clean install with relatively minimal reqs (i.e. graphicslib/lazylib/etc), I can take a quick look if you send me your mod.
Title: Re: Bizarre loading error.
Post by: Harmful Mechanic on June 07, 2019, 01:01:55 PM
Thank you! I realize I've taken enough of your time up with this garbage, but let me package it up and send you a link by PM.
Title: Re: Bizarre loading error.
Post by: Alex on June 07, 2019, 01:04:43 PM
No worries, this'll be... fun. Hopefully it happens in my dev environment, would be considerably more painful if not.
Title: Re: Bizarre loading error.
Post by: Alex on June 07, 2019, 01:28:07 PM
Alright, got this loaded up, with the error and everything, and I see this in the log:

4216 [Thread-7] INFO  com.fs.starfarer.loading.scripts.ScriptClassLoader  - Loading class: data.scripts.MagellanModPlugin
Exception in thread "Thread-7" java.lang.UnsupportedClassVersionError: data/scripts/MagellanModPlugin : Unsupported major.minor version 52.0
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
   at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
   at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
   at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
   at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
   at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(ScriptStore.java:401)
   at java.lang.Thread.run(Thread.java:745)


This shorts out the script loader, so the game crashes the first time it needs to use any other script. Looks like the MagellanModPlugin (and presumably the rest of the jar?) is complied for a newer version of the JRE than the game is running with.
Title: Re: Bizarre loading error.
Post by: Harmful Mechanic on June 07, 2019, 01:32:42 PM
Well, that's embarrassing. But at least now I know what to fix!
Title: Re: Bizarre loading error.
Post by: Alex on June 07, 2019, 01:36:13 PM
Haha, to be fair the actual final error message/stack trace was in no way helpful. I need to remember this as a possible reason for "things are weird"; this has come up before. I wonder: is the error I pasted in your log? Looks like it's not, right? If that error getting logged is a dev-only thing for some reason, that's particularly evil.
Title: Re: Bizarre loading error.
Post by: Harmful Mechanic on June 07, 2019, 01:41:28 PM
It's not in my log at all, that I can see.

I could have sworn I had it set to target JDK 7 - at least this gives me some idea of how to bash at it properly.
Title: Re: Bizarre loading error.
Post by: Alex on June 07, 2019, 01:43:26 PM
Weird...
Title: Re: Bizarre loading error.
Post by: Histidine on June 07, 2019, 06:46:24 PM
Alex, I expect you've already done this, but if you haven't: could UnsupportedClassVersionError in ScriptClassLoader cause a CTD with a message identifying the offending class (and if possible, the mod) and the solution of changing the compile target?
Title: Re: Bizarre loading error.
Post by: Alex on June 07, 2019, 07:15:42 PM
Yeah, let me do that - didn't actually get to it yet, today was a busy day.

Took a quick look - ah, it was catching Exception instead of Throwable, which explains why the script-loading thread croaked silently instead of passing the exception on to the main thread. Fixed it up; now crashes with this message:

9583 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error loading [data.scripts.MagellanModPlugin]

Compiled for the wrong version of Java, change the compile target to Java 7
java.lang.RuntimeException: Error loading [data.scripts.MagellanModPlugin]

Compiled for the wrong version of Java, change the compile target to Java 7
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(ScriptStore.java:409)
   at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.UnsupportedClassVersionError: data/scripts/MagellanModPlugin : Unsupported major.minor version 52.0
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
   at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
   at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
   at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
   at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
   at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(ScriptStore.java:395)
   ... 1 more


Good call, thank you for the reminder.
Title: Re: Bizarre loading error.
Post by: TheEndstoneGolem on February 23, 2020, 05:12:19 AM
Hey guys,

Long time since I've touched Starsector but I'm back!
Just loaded up a modlist and I've found that BRDY, Imperium and Tiandong all throw up a similar error to the one described in this thread!
I've checked them all individually and they all throw up the error by themselves and with or without other mods enabled.
I've done as you suggested Alex, reinstalled the game as well as reinstalling the mods themselves.

Seems to be an issue with the mods themselves :(.
Glad to be back!!
Title: Re: Bizarre loading error.
Post by: Harmful Mechanic on February 23, 2020, 05:22:14 AM
All three of those mods work correctly on my machine. It's something you're doing.

I did fix the original mod I was working on, as well.
Title: Re: Bizarre loading error.
Post by: arice on January 10, 2021, 02:46:14 PM
i am having this load issue now but in reading through the thread i don't know how y'all fixed it. what steps can i take to remedy this error?

never mind i fixed it. i got smooth brain
Title: Re: Bizarre loading error.
Post by: IonDragonX on January 10, 2021, 04:30:58 PM
Just loaded up a modlist and I've found that BRDY, Imperium and Tiandong all throw up a similar error to the one described in this thread!
Seems to be an issue with the mods themselves :(
Blackrock needs all three support Libs
http://fractalsoftworks.com/forum/index.php?topic=4018.0

[0.9.1a] GraphicsLib by Dark.Revenant http://fractalsoftworks.com/forum/index.php?topic=10982.0
[0.9.1a] LazyLib by LazyWizard http://fractalsoftworks.com/forum/index.php?topic=5444.0
[0.9.1a] MagicLib by Tartiflette http://fractalsoftworks.com/forum/index.php?topic=13718.0

You do have those & enabled them, right?
Title: Re: Bizarre loading error.
Post by: SirHartley on January 11, 2021, 09:35:15 AM
could y'all stop necroing a thread from february 2020? thanks.