steve.westfall
steve.westfall

Reputation: 159

How do I stop my applet from refreshing my GWT page?

Recently I asked the community a question: Can a Java Web Application access a Smart card reader on a remote work station?

From the answers I received, I decided to write an Applet to try an accomplish this. That being said, I need to be able to run the Applet from within a GWT application so that I can access a card reader on remote workstations and use the info read from an ID card to grant users access to certain parts of the app. Taking the advice that I found in the 4th answer to this question, I wrote the Applet as a completely separate Java project, exported it as a .jar and used jarsigner to sign it with my certificate. I am able to verify the jar and it is signed appropriately. To test that the signed jar/Applet works, I wrote a simple HTML page with just the applet tag and placed it on our Tomcat 7 web server in the htdocs folder. Using this simple page, I am able to access the card readers on the remote work stations and read the info that I need.

Hooray. So, continuing with the advice from the second question I referenced above, I am trying to launch the Applet using jnlp using the following GWT code:

    HTML swipeCard = new HTML();
    String appletHTML = "<applet code=\"main/java/com/prusa/swipeCardApplet/SwipeCardApplet.class\" height=\"200\" width=\"200\">"+
                                "<param name=\"jnlp_href\" value=\"swipeCardApplet.jnlp\">"+
                        "</applet>";
    swipeCard.setHTML(appletHTML);
    this._swipeCardLogin.add(swipeCard);
    this._swipeCardLogin.setVisible(true);

And my jnlp file looks like:

<?xml version="1.0" encoding="UTF-8"?> 
<jnlp href="swipeCardApplet.jnlp">     
    <information>
        <title>Swipe Card Applet</title>
        <vendor>pramericas.com</vendor>
    </information>
    <resources>         
        <j2se version="1.6+" />                
        <jar href="WEB-INF/lib/swipeCardApplet-1.0.0.jar" main="true" />     
    </resources>     
    <applet-desc           
        name="SwipeCardApplet"          
        main-class="main/java/com/prusa/swipeCardApplet/SwipeCardApplet.class"          
        width="200"          
        height="200">      
    </applet-desc>      
    <security>          
        <all-permissions />      
    </security> 
</jnlp> 

Here's my problem: In IE9 when I add the applet tag to my GWT application, and navigate to the page that I included it on, the applet briefly appears as white space, an IE warning flashes at the bottom of the page (too quickly to read) and then the page refreshes back to the app's home screen.

In Chrome, I get a prompt stating that my java version is out of date (it is) with the option to "run this time". When I choose run this time, I get a Java Authentication Required pop-up that asks for a username and password to access the application on the server. I enter my credentials and click OK. This results in the applet showing the "Error. Click for details" message. Which gives me the following:

Java Plug-in 1.6.0_21
Using JRE version 1.6.0_21-b07 Java HotSpot(TM) Client VM
User home directory = C:\Users\SWESTF01
----------------------------------------------------
c:   clear console window
f:   finalize objects on finalization queue
g:   garbage collect
h:   display this help message
l:   dump classloader list
m:   print memory usage
o:   trigger logging
q:   hide console
r:   reload policy configuration
s:   dump system and deployment properties
t:   dump thread list
v:   dump thread stack
x:   clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------


exception: Unable to load resource: https://dev.pramericas.com/hwslqc/WEB-INF/lib/swipeCardApplet-1.0.0.jar.
com.sun.deploy.net.FailedDownloadException: Unable to load resource: https://dev.pramericas.com/hwslqc/WEB-INF/lib/swipeCardApplet-1.0.0.jar
    at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.getResource(Unknown Source)
    at com.sun.javaws.LaunchDownload$DownloadTask.call(Unknown Source)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.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)
Caused by:
java.io.FileNotFoundException: https://dev.pramericas.com/hwslqc/WEB-INF/lib/swipeCardApplet-1.0.0.jar
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
    at com.sun.deploy.net.HttpUtils.followRedirects(Unknown Source)
    at com.sun.deploy.net.BasicHttpRequest.doRequest(Unknown Source)
    at com.sun.deploy.net.BasicHttpRequest.doRequest(Unknown Source)
    at com.sun.deploy.net.BasicHttpRequest.doGetRequest(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.getResource(Unknown Source)
    at com.sun.javaws.LaunchDownload$DownloadTask.call(Unknown Source)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.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)
Exception: com.sun.deploy.net.FailedDownloadException: Unable to load resource: https://dev.pramericas.com/hwslqc/WEB-INF/lib/swipeCardApplet-1.0.0.jar

Is this just an issue with the paths that I'm using, or is it something else that I'm not seeing? Any help or insight into what I am doing wrong would be greatly appreciated.

A few qualifications: I am using Maven with a Nexus repository to bring in my .jar file as a dependency. The proper entry for the dependency has been added to my pom.xml file.

Upvotes: 0

Views: 160

Answers (1)

Andrew Thompson
Andrew Thompson

Reputation: 168825

exception: Unable to load resource: 
    https://dev.pramericas.com/hwslqc/WEB-INF/lib/swipeCardApplet-1.0.0.jar.

Try doing a direct fetch on that URL using your browser. I bet you'll see 'forbidden' or similar. The lib directory is not a 'public' directory, it will be necessary to move the applet Jar to somewhere that is accessible.

Upvotes: 3

Related Questions