2

First I want to say I am beginner in Java / Web development (but with great experience in programming and analysis). I search several surveys in several locations, not finding a solution to the problem that I think is configuration.

The story: I implemented an Applet that uses javax.smartcardio for the ATR, this works fine without any problems! This applet must "transmit" the collected information to a web page that uses javascript (inside the script of this page), I opted to pass the information in json format and chose Gson for this... Running the applet inside the IDE this works fine!!! Running inside the browser (local IIS 7.5 server) this not work, showme a error: "Uncaught Error: java.lang.InvocationTargetException".

In first time I saw that the IIS log showed the following line: 2014-01-14 02:42:35 127.0.0.1 GET /com/google/gson/Gson.class - 80 - 127.0.0.1 Mozilla/4.0+(Windows+7+6.1)+Java/1.7.0_45 404 0 2 2

Looking at the contents of the JAR file I could see that the missing gson jar files...

I found that should put the files into WEB-INF \ lib directory of the project, it did not exist and Deployment Assembly also not too ... To fix this, I changed Project Facet (add Dynamic Web Module).

Now there is a folder: WebContent \ WEB-INF \ lib I copied and pasted the three files from the explorer windows Gson ... I added the files in deplyment Assembly and now they are in the exported JAR file but the same error keeps happening.

Note: There NOT is a security problem, the applet is signed, after removing gson functions and my method return the ATR code (string) directly the applet works fine.

Any step by step tutorial to "install" for it???

Thanks in advance!

Screen images:

enter image description here

RESUMING

The applet works fine, all functions work, except the function using GSON... In my local server (IIS 7.5) I create a site, and inside this site I put the files: index.html ; MyApplet.jar ; \scrits\Myscript.js Inside de MyApplet.jar file exists many files .class ; .classpath ; project and two folders (META-INF and WebContent with WEB-INF\lib and GSON jar files, three). The problem is: On execute the function using GSON it raise a error, in IIS log I see 404 for /com/google/gson/Gson.class

Applet Jar Content

>C:\inetpub\wwwroot\Sistemas\BryDiscover>"C:\Program Files\Java\jdk1.7.0_45\bin\jar.exe" -
>tvf Bry.Discover.jar
>>"1636 Wed Jan 15 15:33:10 BRST 2014 META-INF/MANIFEST.MF"
>>"1841 Wed Jan 15 15:33:10 BRST 2014 META-INF/PABLOERN.SF"
>>"1207 Wed Jan 15 15:33:10 BRST 2014 META-INF/PABLOERN.DSA"
>>>"415 Tue Jan 14 14:24:56 BRST 2014 .classpath"
>>"1742 Tue Jan 14 00:39:04 BRST 2014 SmartCardInfoList.class"
>>"1418 Tue Jan 14 00:39:04 BRST 2014 SmartCardInfo.class"
>>>"925 Wed Jan 15 15:32:28 BRST 2014 BryDiscover$1.class"
>>>"927 Wed Jan 15 15:32:28 BRST 2014 BryDiscover$2.class"
>>>"921 Wed Jan 15 15:32:28 BRST 2014 BryDiscover$3.class"
>>>"917 Wed Jan 15 15:32:28 BRST 2014 BryDiscover$4.class"
>>>"923 Wed Jan 15 15:32:28 BRST 2014 BryDiscover$5.class"
>>>"917 Wed Jan 15 15:32:28 BRST 2014 BryDiscover$6.class"
>>"1027 Wed Jan 15 15:32:28 BRST 2014 BryDiscover$7.class"
>>"1419 Wed Jan 15 15:32:28 BRST 2014 BryDiscover$8.class"
>>"8905 Wed Jan 15 15:32:28 BRST 2014 BryDiscover.class"
>>"1045 Tue Jan 14 00:35:40 BRST 2014 .project"
>>>>"39 Tue Jan 14 00:35:38 BRST 2014 WebContent/META-INF/MANIFEST.MF"
"249351 Tue Jan 14 00:37:22 BRST 2014 WebContent/WEB-INF/lib/gson-2.2.4-javadoc.jar"
"127564 Tue Jan 14 00:37:22 BRST 2014 WebContent/WEB-INF/lib/gson-2.2.4-sources.jar"
"190418 Tue Jan 14 00:37:22 BRST 2014 WebContent/WEB-INF/lib/gson-2.2.4.jar"
JGrinon
  • 1,453
  • 1
  • 14
  • 36

1 Answers1

0

WebContent \ WEB-INF \ lib

Try fetching your applet back from there, using a direct fetch in the browser address bar, to discover a 'not permitted' error (I think they are response codes in the 500 range).

If you cannot retrieve it by direct fetch, the Java Plug-In also cannot access it.

The applet needs to be moved to a place outside the WEB-INF directory structure that is accessible to the browser/plug-in.

Output of Jar command

..
190418 Tue Jan 14 00:37:22 BRST 2014 WebContent/WEB-INF/lib/gson-2.2.4.jar

The standard class-loaders are not designed to work with a 'Jar within a Jar'. It will be necessary to do either of:

  • Extract the Jar and add the content to the main Jar.
  • Separately list the gson-2.2.4.jar Jar in the archive attribute of the applet element (and not have it inside another Jar).
Community
  • 1
  • 1
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • Hi Andrew, Thanks for de answer! Did not quite understand what you said... But I tried to access the applet via browser and the browser tries to download. I think not explained myself and / or poorly written the situation. The applet works fine, all functions work, except the function using GSON... In my local server (IIS 7.5) I create a site, and inside this site I put the files: – Pablo Ernesto Vigneaux Wilton Jan 16 '14 at 15:01
  • Continuing ...files: index.html ; MyApplet.jar ; \scrits\Myscript.js Inside de MyApplet.jar exist many files .class ; .classpath ; project and two folders (META-INF and WebContent with WEB-INF\lib and GSON jar files, three). – Pablo Ernesto Vigneaux Wilton Jan 16 '14 at 15:10
  • The problem is: On execute the function using GSON it raise a error, in IIS log I see 404 for /com/google/gson/Gson.class – Pablo Ernesto Vigneaux Wilton Jan 16 '14 at 15:14
  • *"But I tried to access the applet via browser and the browser tries to download."* Is that using a `file:` based URL or a local server? Paste the exact URL used, and I can tell.. – Andrew Thompson Jan 16 '14 at 16:12
  • It work in local sever... I change the hosts file inserting local.home.com and access the site using http://local.home.com. For this case I write http://local.home.com/MyApplet.jar and the browser try to download. By my impression I need to informate the applet (jar configuration?) to access the gson jar files inside the main jar (Applet). If possible I will put the files on a Amazon server for test. – Pablo Ernesto Vigneaux Wilton Jan 16 '14 at 22:21
  • *"I write local.home.com/MyApplet.jar"* Wait ..what? I expected to see something like `local.home.com/WEB-INF/lib/MyApplet.jar`! – Andrew Thompson Jan 17 '14 at 05:25
  • Hi Andrew! The Applet jar is located in the root (page root), inside (packed inside) exists the folder WEB-INF/lib with the gsonxxxx.jar files. This is not a correct usage??? I read in artcles to put the Applet inside the some folder of index.html... Remember that I have little experience in web. – Pablo Ernesto Vigneaux Wilton Jan 20 '14 at 18:38
  • Go to the command line and do a `jar -tvf the.jar` for each of the Jars, add it as an [edit to the question](http://stackoverflow.com/posts/21127164/edit). – Andrew Thompson Jan 20 '14 at 22:52
  • Posted the Applet jar content. I not run the command for the internals jar files (gson). – Pablo Ernesto Vigneaux Wilton Jan 21 '14 at 00:58
  • Thanks! Andrew, Extracting the content and add it to applet jar work! Is possible to explain more about it problem? – Pablo Ernesto Vigneaux Wilton Jan 21 '14 at 17:06
  • Yes, but I don't intend writing a novel on it, so can you be more specific about what you wish to know? – Andrew Thompson Jan 21 '14 at 17:08
  • In my case I unpack the gson jar files, but is it the best solution (correct)? Or the recommended is using the jar files (inside or outside the applet jar) with reference in applet html tag? – Pablo Ernesto Vigneaux Wilton Jan 22 '14 at 16:03
  • I would have them in a Jar file to drop the size of the download for the client, and to make it faster. But a separate Jar file to the main Jar. That way, if the data is updated, the client who has already loaded the app. only needs to download that one Jar. List the class Jar and the JSON data jar in the `archive` attribute of the applet, comma separated. – Andrew Thompson Jan 22 '14 at 16:35