NetBeans could not start due to wrong JVM version, incompatible library and missing files

NetBeans could not start on a Xubuntu Linux system.

It displayed a splash screen, wrote the message Initializing for a few seconds and then quit.

 

The original distribution was Xubuntu 16.04 LTS which had been updated to Xubuntu 18.04 LTS.

Tried starting NetBeans from terminal and got these warnings:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.netbeans.ProxyURLStreamHandlerFactory (file:/usr/share/netbeans/platform18/lib/boot.jar) to field java.net.URL.handler
WARNING: Please consider reporting this to the maintainers of org.netbeans.ProxyURLStreamHandlerFactory
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

 

Decided to check the startup activity with:

strace netbeans 2> netbeans_strace.txt

Noticed that NetBeans was looking for configuration files in 3 locations:

stat("/usr/share/netbeans/8.1/etc/netbeans.conf", {st_mode=S_IFREG|0644, st_size=2958, ...}) = 0
stat("/etc/netbeans.conf", {st_mode=S_IFREG|0644, st_size=2958, ...}) = 0
stat("~/.netbeans/8.1/etc/netbeans.conf", 0x7ffc7aae8df0) = -1 ENOENT (No such file or directory)

 

Decided to look for other files under: ~/.netbeans/8.1/

Found log files under: ~/.netbeans/8.1/var/log/

Part of: ~/.netbeans/8.1/var/log/messages.log

Product Version = NetBeans IDE 8.1 (Build 20180221-debian-8.1)
Java Home = /usr/lib/jvm/java-11-openjdk-amd64
...
-------------------------------------------------------------------------------
java.lang.SecurityException: setContextClassLoader
at java.base/jdk.internal.misc.InnocuousThread.setContextClassLoader(InnocuousThread.java:116)
...

 

Discovered that NetBeans 8.1 requires JDK 8.

Found JDK 8 under:

/usr/lib/jvm/java-8-openjdk-amd64/

Created the folder:

~/.netbeans/8.1/etc/

Then created the configuration file:

~/.netbeans/8.1/etc/netbeans.conf

With a single line:

netbeans_jdkhome="/usr/lib/jvm/java-8-openjdk-amd64"

 

This seemed to help somewhat, because the splash screen continued until:

Turning on modules…

But then it quit again…

 

Found and examined: ~/.netbeans/8.1/var/log/messages.log

Noticed this part:

Product Version = NetBeans IDE 8.1 (Build 20180221-debian-8.1)
Java Home = /usr/lib/jvm/java-8-openjdk-amd64/jre
...
-------------------------------------------------------------------------------
INFO [org.netbeans.modules.netbinox]: Install area set to file:/usr/share/netbeans/8.1/
java.lang.NullPointerException
at org.eclipse.osgi.baseadaptor.BaseAdaptor.initializeStorage(BaseAdaptor.java:123)
at org.eclipse.osgi.framework.internal.core.Framework.<init>(Framework.java:192)
at org.eclipse.osgi.framework.internal.core.EquinoxLauncher.internalInit(EquinoxLauncher.java:67)
at org.eclipse.osgi.framework.internal.core.EquinoxLauncher.init(EquinoxLauncher.java:37)
at org.eclipse.osgi.launch.Equinox.init(Equinox.java:178)
at org.netbeans.modules.netbinox.Netbinox.init(Unknown Source)
at org.netbeans.core.netigso.Netigso.prepare(Unknown Source)
at org.netbeans.NetigsoHandle.turnOn(Unknown Source)
at org.netbeans.ModuleManager.enable(Unknown Source)
INFO [null]: Last record repeated again.
at org.netbeans.core.startup.ModuleList.installNew(Unknown Source)
at org.netbeans.core.startup.ModuleList.trigger(Unknown Source)
at org.netbeans.core.startup.ModuleSystem.restore(Unknown Source)
at org.netbeans.core.startup.Main.getModuleSystem(Unknown Source)
INFO [null]: Last record repeated again.
at org.netbeans.core.startup.Main.start(Unknown Source)
at org.netbeans.core.startup.TopThreadGroup.run(Unknown Source)
at java.lang.Thread.run(Thread.java:748)

 

Found this site, which seemed to describe this part of the problem:

https://bugs.launchpad.net/ubuntu/+source/netbeans/+bug/1776937

 

Checked the installed version of libequinox-osgi-java which was: 3.9.1-1

Downloaded: libequinox-osgi-java_3.8.1-10_all.deb

From: https://packages.ubuntu.com/artful/all/libequinox-osgi-java/download

 

Installed the package with:

sudo dpkg -i libequinox-osgi-java_3.8.1-10_all.deb

Held the package at the old version with:

sudo apt-mark hold libequinox-osgi-java

 

Tried starting NetBeans again, but it still failed to start.

Found errors in: ~/.netbeans/8.1/var/log/messages.log

Like:

!ENTRY org.eclipse.osgi 4 0 2018-10-15 22:49:29.510
!MESSAGE Error reading configuration: Unable to create lock manager.
!STACK 0
java.io.IOException: Unable to create lock manager.
at org.eclipse.osgi.storagemanager.StorageManager.open(StorageManager.java:699)

 

Tried running NetBeans as root with:

sudo netbeans

It started up without crashing…

 

It was still unable to start under the regular user account.

Noticed that it had created some files with root as owner:

!ENTRY org.eclipse.osgi 4 0 2018-10-15 23:05:36.425
!MESSAGE Error reading configuration: Permission denied
!STACK 0
java.io.IOException: Permission denied
at java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.io.File.createTempFile(File.java:2024)
at org.eclipse.osgi.storagemanager.StorageManager.initializeInstanceFile(StorageManager.java:188)

 

Decided to change the file permissions with:

sudo chown $USER:$USER ~/.netbeans/ -R

sudo chown $USER:$USER ~/.cache/netbeans/ -R

 

This was the last step. After this NetBeans could finally start normally again.

Conclusion

If NetBeans fails to start on Ubuntu/Xubuntu 18.4 LTS try these things:

  • Check and change used JDK to version 8.
  • Downgrade libequinox-osgi-java package from 3.9.1-1 to 3.8.1-10 and hold/pin it.
  • Run NetBeans as root once.
  • Change NetBeans file permissions to normal user permissions.

Recovering from Linux boot failure with fsck

A virtual Linux machine used for development was behaving unreliably.

Programs would fail to start and running program would freeze.

I decided to restart the system, however it failed to start up again.

 

It simply displayed this message:

BusyBox v1.22.1 (Ubuntu 1:1.22.0-15ubuntu1) built-in shell (ash)
Enter 'help' for a list of built-in commands.

(initramfs)

 

I tried to exit the shell, which lead to this message:

/dev/sda1 contains a file system with errors, check forced.
/dev/sda1:
Inodes that were part of a corrupted orphan linked list found.

/dev/sda1: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
        (i.e., without -a or -p options)
fsck exited with status code 4
The root filesystem on /dev/sda1 requires a manual fsck

 

File system corruption seemed to explain the reliability problems and the subsequent boot failure.

Followed the suggestion of running fsck with:

fsck /dev/sda1

 

Accepted all file system repairs suggested by fsck.

(Should have used the -y parameter)

 

Then rebooted the system with:

reboot

 

After the file system repairs the system booted and seemed fully functional.

Conclusion

If a Linux system fails to boot and only displays a BusyBox / initramfs prompt, try exiting the shell.

This may provide information about the actual problem.

Linux hang at boot due to authentication problems with Samba mount in /etc/fstab

A Raspberry Pi 3 had a problem after I had performed a number of system changes.

When booting it would hang for around 2 minutes showing:

systemd-hostnamed.service

 

I examined system messages from the boot process with:

dmesg

Part of the result was:

[   98.748722] CIFS VFS: Send error in SessSetup = -13
[   98.749092] CIFS VFS: cifs_mount failed w/return code = -13
[  125.427742] usb 1-1.5.2.3: reset high-speed USB device number 9 using dwc_otg
[  188.946712] Status code returned 0xc000006d NT_STATUS_LOGON_FAILURE

 

I remembered that I had experimented with various ways to mount a Samba share in: /etc/fstab

This didn’t work because of authentication problems and (as a side effect) it delayed startup significantly.

 

I decided to solve the problem by:

1. Removing the non-functional line from /etc/fstab

2. Creating a script to be run on demand:

mount_RPServer_shared.sh

With content similar to this:

#/bin/bash
sudo mount -t cifs -o user=pi //server/shared /mnt/server_shared/

 

The script relies on the mount.cifs command.

For Debian based Linux distributions this is part of the cifs-utils package.

Linux problem: package is in a very bad inconsistent state

While updating a newly installed Raspberry Pi 2 with Raspbian Linux, it seemed to hang while upgrading with:

sudo apt-get upgrade

 

After 10 minutes of inactivity I decided to reset the system.

As expected this caused problems.

 

After running:

sudo apt-get update

I noticed this error:

E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.

 

I tried running the suggested command:

sudo dpkg --configure -a

It fixed some problems, but it left me with:

dpkg: error processing package ntp (--configure):
package is in a very bad inconsistent state; you should
reinstall it before attempting configuration
Errors were encountered while processing:
ntp

 

Various ways to reinstall and remove the ntp package were unsuccessful.

Eventually I found a solution here:

http://askubuntu.com/questions/148715/how-to-fix-package-is-in-a-very-bad-inconsistent-state-error

sudo dpkg --remove --force-remove-reinstreq ntp

sudo apt-get install ntp

 

Conclusion

If a package is broken on a Debian based Linux system it can be a solution to remove it forcefully with the –force-remove-reinstreq option for dpkg.