Monday Aug 06, 2012

Got Java (configured correctly)?

Have you ever had firefox crash with the following error when trying to access a Java-based application?

Didn't find JVM under /<path to>/firefox/plugins
Assertion failed: foundJVM, file ../../../../src/plugin/solaris/plugin2/common/JavaVM.c, line 104
Abort (core dumped )

I'm not talking about a sophisticated Java app here.  Just hitting the "Do I have Java?" test page on Java.com will crash Firefox and pretty much any Mozilla-based browser left with the default Java configuration.

Here's what the default (and incorrect) Java configuration looks like on pretty much every version of Firefox since 3.5.  You can see it by typing about:config in the URL bar, acknowledge the warning, and filter on "java" (click for larger view):


Stating that the default Java configuration is incorrect, really means that it's set to use the old Java plugin and (in most cases) a rather old version of Java.  This plugin that is configured by default is incompatible with Firefox 3.5 and beyond.   The first generation Java plugin is called javaplugin_oji and cannot be used with any modern version of Firefox. 

Unfortunately, even the latest Firefox (14 at the time of this post) comes configured to use the old Java plugin by default. 

This means that if you're trying to run a Java-based app on anything greater than Firefox 3.5, you'll wind up with a crashed app and a core file a few seconds after the browser tries to start Java. 

If you've been frustrated by not being able to run Oracle Forms-based apps, WebEx, or any other Java-based browser app on Solaris or Oracle Linux, follow the instructions below.  If you're an Oracle Forms user, get ready for smoking fast response time sans MS Windows and IE. 

Disclaimer: I know neither Solaris or Oracle Linux are supported clients for Oracle Forms-based apps.  Doesn't mean it doesn't work.  It, in fact, works great!  :)

First things first, learn the name and location of the "second generation" Java plugin.  The second generation Java plugin is called libnpjp2.so and is located in:

<path to java>/jre/lib/i386/ for x86 based machines

<path to java>/jre/lib/sparc/  for SPARC based machines.

NOTE:  The second generation Java plugin was introduced in Java 1.6 update 10.  Ensure that you aren't running an older version of Java, if you are upgrade.  Solaris 10 U9 ships with 1.4.2_26, so that will need to be updated in order to access Java-based apps with Firefox 3.5 or greater.

TIP:  Sun Ray Software and Oracle VDI always ships with a relatively recent Java release.  An administrator can symlink these installations to /usr/java.  This will ensure that the browser's Java configuration will always be as current as the JRE used with Sun Ray Software or Oracle VDI, even across upgrades of those products.

For a Sun Ray Server:

rm -rf /usr/java
ln -s /etc/opt/SUNWut/jre /usr/java

For a Oracle VDI server:

rm -rf /usr/java
ln -s /opt/SUNWvda/java /usr/java

Note: The remainder of these instructions assume the following three things:

1) Java, greater that 1.6 U10, is installed (or linked to) /usr/java
2) Firefox, greater than 3.5 is installed in /opt/firefox.
3) The platform is x86

If any of those assumptions do not match your environment, just substitute the correct paths to Java, Firefox, and the correct platform (i386 or SPARC) for your environment


Step 1) Configure Firefox plugins directory

1.1) Create plugins sub-directory under /opt/firefox.  

The plugins directory doesn't exist by default since about Firefox 6, so you'll have create it.  Just create /opt/firefox/plugins and change the permissions so everyone can read/execute the contents:

mkdir /opt/firefox/plugins
chmod -R 755 /opt/firefox/plugins


1.2) Create symlink the new plugin in /opt/firefox/plugins/

Given the location and platform assumptions above, create a symbolic link in /opt/firefox/plugins that points to /usr/java/lib/i386/libnpjp2:

ln -s /usr/java/lib/i386/libnpjp2.so /<path to>/firefox/plugins/libnpjp2.so

Note:  Do not "copy" the library to the plugins directory, this will not work.  The plugin is dependent on the relative path of where it resides.  This is different than other plugins that you may be used to installing such as Acrobat Reader or Flash.

1.3) Remove any symlinks that point to the old java plugin.

rm /opt/firefox/plugins/libjavaplugin_oji.so

Note: Some sites may use a personal plugins directory.  If so, be sure to remove any symlinks for libjavaplugin_oji.so from $HOME/.mozilla/firefox/*.default/plugins

1.4)  Test.  At this point, accessing the "Do I have Java" test page from java.com will now succeed and tell you are using the second generation plugin, but certain apps, such as Oracle Forms and WebEx, will still fail. 

Now that the correct second generation plugin correctly linked to the Firefox plugins directory, it's time to tell Firefox the name of the plugin and the location of Java.


Step 2) Configure Firefox with the location of Java and the name of plugin

Note: This step needs to be done by each user who has ever ran Firefox with the old Java configuration. 

2.1) Open Firefox
2.2) Type "about:config" in the URL bar and acknowledge the "I'll be careful" warning
2.3 ) In the Filter Box, type java and hit return
2.4) Set both java.default_java_location_others and java.default_java_location_solaris to: /usr/java
2.5) Remove/blank out the existing entry under java.global_java_version_file (as the file referenced there does not exist)
2.6) Set the java.java_plugin_library_name to libnpjp2 (or libnpjp2.so, either will work)
2.7) Remove/blank out the existing entry under java.private_java_version_file (as the file referenced there does not exist)
2.8) Close and re-open firefox.  Enter about:config in the url and ensure the settings took place.

The about config screen should now resemble this picture (click for larger image):


2.9) Test out a Java based app, such as WebEx or Oracle E*Business Suite (EBS uses Oracle Forms).  The applications should work correctly, and more importantly, firefox should not crash anymore. At least not due to an incorrect Java plugin configuration!

Step 3) Create default Firefox preferences file for new users

This will prevent first time users of Firefox (or those who wanted to create a new profile) from having to perform the actions in Step 2.  To do this, the administrator creates (or appends to the contents of) a file called prefs.js under the firefox default profiles directory and fills out these values for all new users.

3.1) Create the default profile directory, if one does not exist under /opt/firefox/defaults/

mkdir /opt/firefox/defaults/profile
chmod -R 755 /opt/firefox/defaults/profile

3.2) Edit /opt/firefox/defaults/profile/prefs.js

The contents of prefs.js for a proper Java plugin configuration would be:

# Mozilla User Preferences
user_pref("java.default_java_location_others", "/usr/java");
user_pref("java.default_java_location_solaris", "/usr/java");
user_pref("java.global_java_version_file", "");
user_pref("java.private_java_version_file", "");
user_pref("java.java_plugin_library_name", "libnpjp2");



That's it.  All users should be good to go for running Java-based apps on a modern release of Firefox.

About

Think Thin is a collection of bloggers that work with Oracle's Virtual Desktop portfolio of products.

Search

Archives
« August 2012
SunMonTueWedThuFriSat
   
1
2
3
4
5
7
9
10
12
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
       
Today