Ubuntu/Java issues

neffoff

New member
Yes, it's that dreaded "Exception in thread "main" java.lang.ExceptionInInitializerError
" error again, and I can't properly fix it after reading around the KoLmafia and Ubuntu forums.

To summarise, I'm using Ubuntu 10.10. For months I used OpenJDK with mafia with only minor, easily ignored glitches. Recently mafia crashed on me, and hasn't run properly since (incidentally, the crash was after using a buff from the new April Shower). If I run mafia from the terminal (java -jar /home/desktop/bin/KoLmafia-9225.jar), the error output is:

Code:
Exception in thread "main" java.lang.ExceptionInInitializerError
	at net.sourceforge.kolmafia.AdventureResult.normalizeEffectName(AdventureResult.java:228)
	at net.sourceforge.kolmafia.AdventureResult.<init>(AdventureResult.java:164)
	at net.sourceforge.kolmafia.AdventureResult.<init>(AdventureResult.java:154)
	at net.sourceforge.kolmafia.AdventureResult.<init>(AdventureResult.java:144)
	at net.sourceforge.kolmafia.objectpool.EffectPool.get(EffectPool.java:98)
	at net.sourceforge.kolmafia.persistence.ItemDatabase.<clinit>(ItemDatabase.java:94)
	at net.sourceforge.kolmafia.AdventureResult.<init>(AdventureResult.java:211)
	at net.sourceforge.kolmafia.objectpool.ItemPool.get(ItemPool.java:1249)
	at net.sourceforge.kolmafia.RequestEditorKit.<clinit>(RequestEditorKit.java:2004)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:169)
	at net.sourceforge.kolmafia.KoLmafia.class$(KoLmafia.java:152)
	at net.sourceforge.kolmafia.KoLmafia.<clinit>(KoLmafia.java:152)
Caused by: java.lang.NumberFormatException: For input string: "802"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
	at java.lang.Integer.parseInt(Integer.java:449)
	at java.lang.Integer.valueOf(Integer.java:554)
	at net.sourceforge.kolmafia.persistence.EffectDatabase.reset(EffectDatabase.java:99)
	at net.sourceforge.kolmafia.persistence.EffectDatabase.<clinit>(EffectDatabase.java:84)
	... 13 more
Could not find the main class: net.sourceforge.kolmafia.KoLmafia. Program will exit.

I've already tried installing the latest Sun Java. I then fiddled with update-java-alternatives, still no success. I've uninstalled OpenJDK, then also uninstalled Sun java, then reinstalled SunJava on it's own - still no luck. I tried using the shell to invoke sun java directly - no joy.

Interestingly, if I use sudo to invoke mafia (sudo java -jar /home/desktop/bin/KoLmafia-9225.jar), then mafia will run with some major problems, the most pertinent of which is that the preferences window can't be opened, with the error output:

Code:
class java.lang.reflect.InvocationTargetException: null
java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at net.sourceforge.kolmafia.CreateFrameRunnable.runConstruction(CreateFrameRunnable.java:256)
	at net.sourceforge.kolmafia.CreateFrameRunnable.createFrame(CreateFrameRunnable.java:161)
	at net.sourceforge.kolmafia.CreateFrameRunnable.run(CreateFrameRunnable.java:132)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642)
	at java.awt.EventQueue.access$000(EventQueue.java:85)
	at java.awt.EventQueue$1.run(EventQueue.java:603)
	at java.awt.EventQueue$1.run(EventQueue.java:601)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:612)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at net.sourceforge.foxtrot.pumps.ConditionalEventPump.pumpEvents(ConditionalEventPump.java:99)
	at net.sourceforge.foxtrot.AbstractSyncWorker.post(AbstractSyncWorker.java:106)
	at net.sourceforge.foxtrot.AbstractSyncWorker.post(AbstractSyncWorker.java:132)
	at net.sourceforge.foxtrot.ConcurrentWorker.post(ConcurrentWorker.java:113)
	at net.sourceforge.kolmafia.KoLmafiaGUI.constructFrame(KoLmafiaGUI.java:302)
	at net.sourceforge.kolmafia.KoLmafiaGUI.constructFrame(KoLmafiaGUI.java:275)
	at net.sourceforge.kolmafia.swingui.menu.DisplayFrameMenuItem.run(DisplayFrameMenuItem.java:86)
	at net.sourceforge.kolmafia.swingui.menu.ThreadedMenuItem$ThreadedMenuItemListener.actionPerformed(ThreadedMenuItem.java:71)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
	at javax.swing.AbstractButton.doClick(AbstractButton.java:357)
	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:809)
	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:850)
	at java.awt.Component.processMouseEvent(Component.java:6289)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
	at java.awt.Component.processEvent(Component.java:6054)
	at java.awt.Container.processEvent(Container.java:2041)
	at java.awt.Component.dispatchEventImpl(Component.java:4652)
	at java.awt.Container.dispatchEventImpl(Container.java:2099)
	at java.awt.Component.dispatchEvent(Component.java:4482)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
	at java.awt.Container.dispatchEventImpl(Container.java:2085)
	at java.awt.Window.dispatchEventImpl(Window.java:2478)
	at java.awt.Component.dispatchEvent(Component.java:4482)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:644)
	at java.awt.EventQueue.access$000(EventQueue.java:85)
	at java.awt.EventQueue$1.run(EventQueue.java:603)
	at java.awt.EventQueue$1.run(EventQueue.java:601)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
	at java.awt.EventQueue$2.run(EventQueue.java:617)
	at java.awt.EventQueue$2.run(EventQueue.java:615)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:614)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.String.substring(String.java:1937)
	at java.lang.String.substring(String.java:1904)
	at net.sourceforge.kolmafia.swingui.panel.GenericPanel$FileSelectPanel.getRelativePath(GenericPanel.java:480)
	at net.sourceforge.kolmafia.swingui.panel.GenericPanel$FileSelectPanel.setText(GenericPanel.java:419)
	at net.sourceforge.kolmafia.swingui.OptionsFrame$EditorPanel.actionCancelled(OptionsFrame.java:1406)
	at net.sourceforge.kolmafia.swingui.OptionsFrame$EditorPanel.<init>(OptionsFrame.java:1396)
	at net.sourceforge.kolmafia.swingui.OptionsFrame.<init>(OptionsFrame.java:94)
	... 70 more
net.sourceforge.kolmafia.swingui.OptionsFrame could not be loaded
class java.lang.StringIndexOutOfBoundsException: String index out of range: -1
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.String.substring(String.java:1937)
	at java.lang.String.substring(String.java:1904)
	at net.sourceforge.kolmafia.swingui.panel.GenericPanel$FileSelectPanel.getRelativePath(GenericPanel.java:480)
	at net.sourceforge.kolmafia.swingui.panel.GenericPanel$FileSelectPanel.setText(GenericPanel.java:419)
	at net.sourceforge.kolmafia.swingui.OptionsFrame$EditorPanel.actionCancelled(OptionsFrame.java:1406)
	at net.sourceforge.kolmafia.swingui.OptionsFrame$EditorPanel.<init>(OptionsFrame.java:1396)
	at net.sourceforge.kolmafia.swingui.OptionsFrame.<init>(OptionsFrame.java:94)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at net.sourceforge.kolmafia.CreateFrameRunnable.runConstruction(CreateFrameRunnable.java:256)
	at net.sourceforge.kolmafia.CreateFrameRunnable.createFrame(CreateFrameRunnable.java:161)
	at net.sourceforge.kolmafia.CreateFrameRunnable.run(CreateFrameRunnable.java:132)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642)
	at java.awt.EventQueue.access$000(EventQueue.java:85)
	at java.awt.EventQueue$1.run(EventQueue.java:603)
	at java.awt.EventQueue$1.run(EventQueue.java:601)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:612)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at net.sourceforge.foxtrot.pumps.ConditionalEventPump.pumpEvents(ConditionalEventPump.java:99)
	at net.sourceforge.foxtrot.AbstractSyncWorker.post(AbstractSyncWorker.java:106)
	at net.sourceforge.foxtrot.AbstractSyncWorker.post(AbstractSyncWorker.java:132)
	at net.sourceforge.foxtrot.ConcurrentWorker.post(ConcurrentWorker.java:113)
	at net.sourceforge.kolmafia.KoLmafiaGUI.constructFrame(KoLmafiaGUI.java:302)
	at net.sourceforge.kolmafia.KoLmafiaGUI.constructFrame(KoLmafiaGUI.java:275)
	at net.sourceforge.kolmafia.swingui.menu.DisplayFrameMenuItem.run(DisplayFrameMenuItem.java:86)
	at net.sourceforge.kolmafia.swingui.menu.ThreadedMenuItem$ThreadedMenuItemListener.actionPerformed(ThreadedMenuItem.java:71)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
	at javax.swing.AbstractButton.doClick(AbstractButton.java:357)
	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:809)
	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:850)
	at java.awt.Component.processMouseEvent(Component.java:6289)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
	at java.awt.Component.processEvent(Component.java:6054)
	at java.awt.Container.processEvent(Container.java:2041)
	at java.awt.Component.dispatchEventImpl(Component.java:4652)
	at java.awt.Container.dispatchEventImpl(Container.java:2099)
	at java.awt.Component.dispatchEvent(Component.java:4482)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
	at java.awt.Container.dispatchEventImpl(Container.java:2085)
	at java.awt.Window.dispatchEventImpl(Window.java:2478)
	at java.awt.Component.dispatchEvent(Component.java:4482)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:644)
	at java.awt.EventQueue.access$000(EventQueue.java:85)
	at java.awt.EventQueue$1.run(EventQueue.java:603)
	at java.awt.EventQueue$1.run(EventQueue.java:601)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
	at java.awt.EventQueue$2.run(EventQueue.java:617)
	at java.awt.EventQueue$2.run(EventQueue.java:615)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:614)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
net.sourceforge.kolmafia.swingui.OptionsFrame could not be loaded

Even more interestingly, if I login as the root user rather than just use sudo, KoLmafia/java will work perfectly. I suspect this is some problem with permissions rather than the JRE or mafia. I realise I might be better posting this to Ubuntu forums, but has anyone else had similar problems, or a clue where to go next?
 

xKiv

Active member
Even more interestingly, if I login as the root user rather than just use sudo

If you just sudo java -jar KolMafia.jar, you will still run in the environment ($HOME, ....) of the original user. I am not entirely sure whether that matters, but it's a difference.

Code:
net.sourceforge.kolmafia.swingui.OptionsFrame could not be loaded
class java.lang.StringIndexOutOfBoundsException: String index out of range: -1
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.String.substring(String.java:1937)
	at java.lang.String.substring(String.java:1904)
	at net.sourceforge.kolmafia.swingui.panel.GenericPanel$FileSelectPanel.getRelativePath(GenericPanel.java:480)
	at net.sourceforge.kolmafia.swingui.panel.GenericPanel$FileSelectPanel.setText(GenericPanel.java:419)
	at net.sourceforge.kolmafia.swingui.OptionsFrame$EditorPanel.actionCancelled(OptionsFrame.java:1406)
This looks like the value you have set for "preferred editor" is somehow invalid.
This happened to me when I set my login/logout scripts as relative path (using the provided file picker), which then got mangled somewhere.

Also
Code:
Caused by: java.lang.NumberFormatException: For input string: "802"

How is 802 not an integer?!
What are your locale settings? Is your system expecting non-arabic numerals? Or a "thousands" separator every two decimal places? Or something else that would mean 802 is not a correctly written number?
 

neffoff

New member
I eventually got this under control. While I was logged in as root and installing a bunch of other Ubuntu updates, I decided to try stripping out all the java packages again and reinstalling. There were various remnants of OpenJDK (eg openjdk-6-jre-headless) still present, which didn't show up when I tried this under a non-root account. Anyway, having removed these and reinstalled Sun Java as root user, everything seems to work fine in non-root accounts.

The problem may have stemmed from having installed the various java packages (both OpenJDK and Sun) from a non-root account using sudo. Along the way I'm guessing some permissions for the various files relating to OpenJDK got screwed up, and paths, environment variables etc persisted when Sun Java was installed. It doesn't help that OpenJDK is pretty hard to trace as it extends it's tentacles all over the place - there's config files squirreled away in /etc, /usr/lib, /usr/bin, etc.

TL;DR - My suggestion to anyone else with this problem is to uninstall everything java-related while logged in as root (not via sudo), then reinstall Sun Java on it's own.
 
Last edited:
Top