Java applet fails to reload on Internet Explorer - java

I have an applet that has a logout"button. The button ends the session by calling a CGI script and then kills Java VM by calling System.exit(). The problem is when a user tries to log in again in the same browser window - the applet fails to load with ClassNotFoundException:
load: class lucent/fm/parts/BlankPage.class not found.
java.lang.ClassNotFoundException: lucent.fm.parts.BlankPage.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed:http://example.com/html/lucent/fm/parts/BlankPage/class.class
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 7 more
Exception: java.lang.ClassNotFoundException: lucent.fm.parts.BlankPage.class
It appears only on Internet Explorer, not in Firefox. Java Plugin is:
Java Plug-in 1.6.0_20
Using JRE version 1.6.0_20-b02 Java HotSpot(TM) Client VM
The direct scenario is the following:
1. Log in to the system (load the applet).
2. Log out (it closes the applet, but the browser window persists).
3. Click on the address bar and press Enter.
4. The applet fails to load and the ClassNotFoundException can be seen in Java Console.
5. Refresh the page - the server redirects to the login page; after logging in, the applet again does not load and throws the exception.
Looking at the Apache access log proved that in the step 4 that the browser (or plugin) tries to load jar files and gets a HTTP error. It is OK because the session has expired. The strange thing happens in the 5th point - there is no request for jars! It seems that the browser or plugin remembers failed attempts and does not even try to load jar files. It only tries to load a raw .class file, which is not present on the server.
Is my conclusion correct? How can I deal with such an error? Is it possible to force Java plugin to load jar files?
I checked that enabling caching in Java Control Panel does not help. Setting the codebase_lookup parameter to "false" is not helpful, too. It only prevents from trying to load the "class" file directly.
Thanks in advance for any suggestions.

I have an applet that has a "logout" button. The button ends the session by calling a CGI script and then kills Java VM by calling System.exit().
An applet calling System.exit(anyNumber) is crudely equivalent to a guest burning down the house of their host. Applets (even trusted applets) should never try to end the VM. The VM will be ended by the browser when all applets in a page that share the VM have finished their destroy() methods and a subsequent period of time as chosen by the browser.
BTW - I recall one version of Mozilla/FF where calling System.exit(int) not just ended the VM, but also crashed the browser!

If your html with applets is not static (cgi, php, etc), then after logging out, you can try to force different URL pointing to the jar file (i.e. instead of "my.jar" use "my.jar?random=1235232").
Also, you can try to play with cache HTTP headers.
Another potential workaround will be to reconfigure apache to serve the jars always - even when session has been closed (if that's acceptable).

Related

Java-FX failed to load resource exception

I am running my Java-FX application via webstart by tomcat server.
After signing and versioning of jars I having this problem when am accessing it through web browser.
I am using jnlp and version protocol to start the application through tomcat server.
ExitException[ 3]com.sun.deploy.net.FailedDownloadException: Unable to load resource:
(httP://127.0.0.1:8080/gyms/lib/commons-collections-3.2.1.jar?version-id=1.0.1, 1.0.1)
at sun.plugin2.applet.JNLP2Manager.downloadResources(Unknown Source)
at sun.plugin2.applet.JNLP2Manager.prepareLaunchFile(Unknown Source)
at sun.plugin2.applet.JNLP2Manager.loadJarFiles(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
It seems you are using a jnlp-file with a line like this:
<jar href="commons-collections-3.2.1.jar" version="1.0.1" />
So you are using the version-based download protocol. This will result in the server looking for a file called commons-collections-3.2.1__V1.0.1.jar which apparently is not there.
Bottom line: do not specify two conflicting version-numbers in your jnlp. Decide wether you want to use versioned download and omit the version-number in the href-attribute or use simple download and omit the version-attribute.
Problem is solved because I am using Java 1.7.51 update and also i am usin third api which is not supported in java 8 which is also installed in my desktop.
The program(x86) should not have any version of java greater than java 7 as the application is taking java/bin from x86 only.
that is why that failed download exception is coming at run time.

Conditional java.lang.NoClassDefFoundError in Webstart application

We have a webstart swing application running on our multiple remote desktop servers for a lot of customers. Suddenly, on one of our servers the customers started getting a java.lang.NoClassDefFoundError. Not on startup, the applications starts up fine, but when doing specific tasks, eg sending a mail through our software, it popups up in the console like this:
java.lang.NoClassDefFoundError: pos/MailSenderInterface
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
......
Caused by: java.lang.ClassNotFoundException: pos.MailSenderInterface
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 56 more
The problem is, this only happens on ONE of our servers. On all the other servers the webstart application runs just fine! But on this single terminal server, I get the error, even though the java version is the same, and the link to the jnlp-file is the same.
I have of course tried deleting temporary internet files in the java control panel, to no avail.
I then started toying around a bit, and found out something very strange.
Our customers start the application from an icon pointing to a batch-file in c:\drift
This batchfile only contains the following:
#start javaws http://ourserver/ourapplication.jnlp
Typing the link outside the batch-file gives the same error. Then I typed cd .. so that my current path was c:\ instead of c:\drift and started javaws from there. And surprise, no errors! I then tried cd drift again and the error occured again. I have tried this many times now, with the same result. So somehow the path from WHERE I start javaws have something to say for if I get the NoClassDefFoundError or not. But neither c:\ or c:\drift contains any .jar-files (although subdirectories may). I am very perplexed by this. What on earth is wrong? Our java version is 1.7.0_67
Aha! The path c:\drift\ actually had a directory "pos" from a couple of years back, with an old version of MailSender.class but with no MailSenderInterface.class Deleting this directory solved the problem. :-)
(Remember that the error was about a missing pos/MailSenderInterface)
Apparently the newest javaws in java 1.7.0_67 tries to load classes from a subdirectory of the place where you started javaws if such a directory is found, instead of loading the files from the correctly downloaded jar-files.

error with JSP/ Servlets progam when executing on port 8080:

I have moved my project into my webapps directory under the tomcat 6.0 directory and am running this under the updated url using port 8080.
Has anyone ever seen this error?
**java.lang.UnsatisfiedLinkError: Native Library D:\oracle\product\10.2.0\client_1\BIN\ocijdbc10.dll already loaded in another classloader**
java.lang.ClassLoader.loadLibrary0(Unknown Source)
java.lang.ClassLoader.loadLibrary(Unknown Source)
java.lang.Runtime.loadLibrary0(Unknown Source)
java.lang.System.loadLibrary(Unknown Source)
oracle.jdbc.driver.T2CConnection$1.run(T2CConnection.java:3147)
java.security.AccessController.doPrivileged(Native Method)
oracle.jdbc.driver.T2CConnection.loadNativeLibrary(T2CConnection.java:3143)
oracle.jdbc.driver.T2CConnection.logon(T2CConnection.java:221)
oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:441)
oracle.jdbc.driver.T2CConnection.<init>(T2CConnection.java:132)
oracle.jdbc.driver.T2CDriverExtension.getConnection(T2CDriverExtension.java:78)
oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
java.sql.DriverManager.getConnection(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source)
I am curious to find out what the first line of this stack trace is.
What does this mean?
Please let me know if more information is required from my program.
Thank you in advance.
Sonny
As error saying - you can not load dll lirary from two separate class loaders. Most likely you have two separate Web Applications using connection to Oracle.
Please try to move oracle library jar to Tomcat shared/lib folder, so library will be loaded only once by Tomcat Common Class Loader.
Hello all I solved my own issue. I had to change the path of the oracle database to a jdbc thin client url as opposed to directly connecting to the oracle database.
originally I was using the statement: intfdb.JDBCOCIDRV=jdbc:oracle:oci:#GPSTRKPD.na.jnj.com
to connect which was causing the error.
I change my statement to: jdbc:oracle:thin:#psgtwp0.na.jnj.com:1531:gpstrkpd and it works fine now. Thanks for all of your input.
Sonny

AMTU (Amazon Transport Utility) crashing and service not running

Having a problem running AMTU on a windows 7 Pro Machine.
It runs fine when it opens but it crashes after running a few days.
Here is the Crash Report.
2013-09-14 09:48:19,482 [pool-3-thread-3] com.amazon.merchants.services.RetrieverService - Unable to retrieve unacknowledged report information - MWS Request ID unknown
2013-09-14 09:48:19,482 [pool-3-thread-3] com.amazon.merchants.services.RetrieverService - MWS responded with an error: Internal Error
com.amazonaws.mws.MarketplaceWebServiceException: Internal Error
at com.amazonaws.mws.MarketplaceWebServiceClient.processErrors(MarketplaceWebServiceClient.java:2342)
at com.amazonaws.mws.MarketplaceWebServiceClient.invoke(MarketplaceWebServiceClient.java:2231)
at com.amazonaws.mws.MarketplaceWebServiceClient.invoke(MarketplaceWebServiceClient.java:2011)
at com.amazonaws.mws.MarketplaceWebServiceClient.getReportList(MarketplaceWebServiceClient.java:1206)
at com.amazon.merchants.services.RetrieverService.processReportCheck(RetrieverService.java:94)
at com.amazon.merchants.services.RetrieverService.run(RetrieverService.java:46)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(Unknown Source)
at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
I also cannot start the Windows Service called AMTU. Get the following Error:
The AMTU service on local computer has started and then stopped
I am suspecting its a Java version issue.
In the AMTU documentation it says "requires Java version 1.6.0 or later (listed as JDK/JRE - 6)" and links to http://www.oracle.com/technetwork/java/archive-139210.html. The link has many download links, but nothing listed "JDK/JRE - 6".
AMTU documentation: https://d28hcfptedr5ia.cloudfront.net/ug/AMTU_2.2_UserGuide.pdf
Any Ideas?
Thanks in advance.
The way I read this crash report, AMTU got an unexpected result from the MWS servers:
MWS responded with an error: Internal Error
It seems the error handling in AMTU is not good enough to gracefully handle a HTTP status 500, and there is not a lot you can do about this. You could put a HTTP proxy in between and catch a HTTP 500 on the line before it gets to the AMTU, replacing it with something that AMTU handles more gracefully (e.g. an empty XML result or a time out). It would be preferrable though that Amazon doesn't send those errors back, after all, a 500 is an error on their side of things.
I seriously doubt the Java version has anything to do with this, but just in case: You can still download JRE6 even though it is end-of-life:
Java 6 downloads
Please note that the true name of JRE6 is "Java SE runtime environment" and JDK6 is called "Java SE development kit". At the time of writing, the most current version is "update 45". You may need to uninstall Java 7 to make sure the AMTU actually uses the version you want it to. Please also note that since AMTU is a 32bit process, you will need the 32bit JRE even if it is run on a 64bit windows.

Applet stopped working with a JNLP MissingFieldException <jnlp>

I have an applet which was running 1/2 year ago. Now i needed to 'reactivate' it however for an unknown reason it is not working anymore. Here are the specs:
JNLP based NG Applet
Tomcat 7
JRE 1.7.0_25
Firefox 22 and Chrome 28
This is the error I get:
MissingFieldException[ The following required field is missing from the launch file: <jnlp>]
at com.sun.javaws.jnl.XMLFormat.parse(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory._buildDescriptor(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at sun.plugin2.applet.JNLP2Manager.initialize(Unknown Source)
at sun.plugin2.main.client.PluginMain.initManager(Unknown Source)
at sun.plugin2.main.client.PluginMain.access$200(Unknown Source)
at sun.plugin2.main.client.PluginMain$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Error while initializing manager: MissingFieldException[ The following required field is missing from the launch file: <jnlp>], bail out
What I tried/suspected so far:
Something oracle introduced with security update 7u17, 7u21 or 7u25. However I tried all JREs from 7u25 down to 7u0 it didn't help. Also tried 6u51 down to 6u22 which I am sure did work before.
Something Mozilla or Google introduced in their effort to increase the security of their browsers in combination with the java plugin. Tried various older browser versions - no success. However then I tried the IE10 and it is working ?!
Analyzed the JNLP file (also with JaNeLa) but since it did work before and works in IE10 it can't be the JNLP. It seems that the plugin doesn't even come to analyzing the JNLP.
Any ideas?
After nearly spending two days on that problem I figured it out, hopefully helping others with that. The explanation:
My applet runs in the context of a protected web application where a user needs to login with a form login first.
After doing so, a session cookie is created and sent back to the client/browser.
Since I switched from tomcat 6 to tomcat 7 the useHttpOnly policy for cookies is enabled by default which was disabled for all tomcat versions prior tomcat 7. The HttpOnly flag instructs browsers to prevent access to those cookies from JavaScript/Plugins (security reasons e.g. cross site scripting etc).
Now since the java plugin couldn't access the cookie it didn't sent it to the server when requesting the JNLP file.
the server returns the loginpage for all unauthorized request.
Last but not least the JNLP parser was looking for the <jnlp> structure and couldn't find any - so the above error was generated.
So how can that be prevented?
Disable the useHttpOnly flag in tomcat globally
Disable the useHttpOnly flag for a webapplication (which I did). To do that add a context.xml file in the META-INF of your webappication which contains the following line
<Context path="/" cookies="true" useHttpOnly="false"/>
Now why the IE10 seems to ignore the httponly flag is a open question i can live with ;-)

Categories