tags:

views:

593

answers:

5

We have a legacy program that was ported from Java 1.3 to Java 1.5. This application involves applets which worked fine before. After porting however, the applet would not load. However there are no errors or exceptions. The app would just try to load it forever. We tried to run it with Java 1.6 and poof! No problems whatsoever. Isn't Java 6 backwards compatible? So how come it would run in that version and not in 1.5?

====

Java Console log for Java 1.5.0_19

basic: Registered modality listener
basic: Registered modality listener
basic: Registered modality listener
liveconnect: Invoking JS method: document
liveconnect: Invoking JS method: document
liveconnect: Invoking JS method: document
liveconnect: Invoking JS method: URL
liveconnect: Invoking JS method: URL
liveconnect: Invoking JS method: URL
basic: Referencing classloader: sun.plugin.ClassLoaderInfo@bb7759, refcount=1
basic: Referencing classloader: sun.plugin.ClassLoaderInfo@bb7759, refcount=2
basic: Referencing classloader: sun.plugin.ClassLoaderInfo@bb7759, refcount=3
basic: Added progress listener: sun.plugin.util.GrayBoxPainter@b0bad7
basic: Loading applet ...
basic: Initializing applet ...
basic: Starting applet ...
basic: Added progress listener: sun.plugin.util.GrayBoxPainter@ba9340
basic: Added progress listener: sun.plugin.util.GrayBoxPainter@1198891
basic: Loading applet ...
basic: Initializing applet ...
basic: Starting applet ...
basic: Loading applet ...
basic: Initializing applet ...
basic: Starting applet ...
basic: Referencing classloader: sun.plugin.ClassLoaderInfo@bb7759, refcount=4
basic: Releasing classloader: sun.plugin.ClassLoaderInfo@bb7759, refcount=3
basic: Referencing classloader: sun.plugin.ClassLoaderInfo@bb7759, refcount=4
basic: Releasing classloader: sun.plugin.ClassLoaderInfo@bb7759, refcount=3
basic: Referencing classloader: sun.plugin.ClassLoaderInfo@bb7759, refcount=4
basic: Releasing classloader: sun.plugin.ClassLoaderInfo@bb7759, refcount=3
network: Connecting <something>.jar with proxy=HTTP @ proxy/<ip address>
basic: Loading <something>.jar from cache
basic: No certificate info, this is unsigned JAR file.
Left START init()
Left END init()
Right START init()
Control start() Waiting for Left Panel to load...
Right START start()
network: Connecting socket://<ip address>:14444 with proxy=DIRECT
Control start() Waiting for Left Panel to load...
Control start() Waiting for Left Panel to load...
Control start() Waiting for Left Panel to load...
my HostName : <ip address>
Thread-19 Check : 
Thread-19 Check : Monitor : run : start
Thread-20 Monitor : Monitor: run() start
Control start() Waiting for Left Panel to load...
Control start() Waiting for Left Panel to load...
Control start() Waiting for Left Panel to load...
Control start() Waiting for Left Panel to load...
Control start() Waiting for Left Panel to load...
Control start() Waiting for Left Panel to load...

the last message goes on forever... and now with the working version:

====

Java Console log for Java 1.6.0_15

basic: Added progress listener:   sun.plugin.util.GrayBoxPainter$GrayBoxProgressListener@1b000e7
basic: Added progress listener: sun.plugin.util.GrayBoxPainter$GrayBoxProgressListener@12611a7
basic: Added progress listener: sun.plugin.util.GrayBoxPainter$GrayBoxProgressListener@1807ca8
network: CleanupThread used 6 us
network: CleanupThread used 5 us
network: CleanupThread used 6 us
cache: Skip blacklist check as cached value is ok.
network: Cache entry found [url: <something>.jar, version: null]
network: Connecting <something>.jar with proxy=HTTP @ proxy/<ip address>
network: ResponseCode for <something>.jar : 304
network: Encoding for <something>.jar : null
network: Disconnect connection to <something>.jar
Reading certificates from 11 <something>.jar | <something>.idx
network: No certificate info for unsigned JAR file: <something>.jar
basic: Applet loaded.
basic: Applet loaded.
basic: Applet resized and added to parent container
basic: Applet resized and added to parent container
basic: PERF: AppletExecutionRunnable - applet.init() BEGIN ; jvmLaunch dt 330275 us, pluginInit dt 27768955 us, TotalTime: 28099230 us
Right START init()
basic: PERF: AppletExecutionRunnable - applet.init() BEGIN ; jvmLaunch dt 330275 us, pluginInit dt 27770563 us, TotalTime: 28100838 us
Left START init()
basic: Applet loaded.
basic: Applet resized and added to parent container
basic: PERF: AppletExecutionRunnable - applet.init() BEGIN ; jvmLaunch dt 330275 us, pluginInit dt 27779332 us, TotalTime: 28109607 us
Left END init()
basic: Applet initialized
basic: Removed progress listener: sun.plugin.util.GrayBoxPainter$GrayBoxProgressListener@12611a7
basic: Applet made visible

And that's it. Still haven't figured out why it works with java6 and not java5.

A: 

There probably is an exception somewhere but you don't see it (maybe it's swallowed). Or it's a bug in your version of Java 5 which has been fixed in Java 6.

Aaron Digulla
A: 

One possible problem is if your applet is embedded in a html page using the "applet" tag then it has to be modified to use "object" tag because "applet" tag is deprecated.

valli
See also http://java.sun.com/javase/6/docs/technotes/guides/plugin/developer_guide/using_tags.html#applet
trashgod
A: 

Enable the Java console as well as ALL trace/debug information in the console.

Then try reloading your applet and see what it says.

Thorbjørn Ravn Andersen
A: 

@valli: the object tag was used, not applet

@thorbjorn: i tried that already... it just keeps saying loading applet...

@aaron: how can i know what exception it is, if there really is one? and yes we have considered that its a java bug but i still havent found what that bug is. i have to submit a report tomorrow and i've scoured the net but came up with nothing as of yet...

@all: thank you for your replies

jcp
A: 

Java 6 is backwards compatible with Java 5, but that just means that applets that work under Java 5 also work with Java 6. Your applet works with Java 6, which says nothing about whether it should work with Java 5. There are obviously new features in Java 6 that aren't available when running under Java 5.

If your code is using some class that is only available under Java 6 I would expect to see ClassDefNotFoundError or ClassNotFoundException under Java 5. That said, it's possible that somewhere in your code you are catching and silently swallowing exceptions. Look for any empty catch blocks or overly-broad catch blocks (i.e. catching Exception or Throwable instead of something more specific). If the code is multi-threaded, consider adding uncaught exception handlers to each thread to log any problems.

Other than that, fire the applet up in the (JDK 5) Applet Viewer and attach a debugger to try to pinpoint the location of the problem.

EDIT: Did you build the applet with JDK5? That would highlight any compatibility problems. If you are building with JDK 6, at least set the compiler to generate Java 5 bytecode. But preferably you'd also build against the JDK 5 classes (either by using JDK 5, or by using the -bootclasspath option with JDK 6) so that you can see if you are using anything that is not in it.

Dan Dyer
we used JDK5 to build the applet. i tried running the applet using Java 5 and using Java 6... the logs in the java console are different so maybe it's really a problem in the version? anyway, i'll try your suggestions. thank you :)
jcp