简体   繁体   English

在带有eclipse的Applet中使用GSON的正确配置是什么(Kepler)

[英]What is the correct configuration to use GSON inside a Applet implementing with eclipse (Kepler)

First I want to say I am beginner in Java / Web development (but with great experience in programming and analysis). 首先,我想说我是Java / Web开发的初学者(但是在编程和分析方面有丰富的经验)。 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! 故事:我实现了一个使用javax.smartcardio进行ATR的Applet,它工作正常,没有任何问题! 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!!! 此applet必须将收集到的信息“传输”到使用javascript的网页(在此页面的脚本内),我选择以json格式传递信息,并为此选择了Gson。...在IDE中运行applet即可精细!!! Running inside the browser (local IIS 7.5 server) this not work, showme a error: "Uncaught Error: java.lang.InvocationTargetException". 在浏览器(本地IIS 7.5服务器)中运行无法正常运行,显示错误:“未捕获的错误: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 我第一次看到IIS日志显示以下行: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... 查看JAR文件的内容,我可以看到缺少的gson jar文件...

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). 我发现应该将文件放入项目的WEB-INF \\ lib目录中,该文件不存在,Deployment Assembly也不太好。要解决此问题,我更改了Project Facet(添加了动态Web模块)。

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. 现在有一个文件夹:WebContent \\ WEB-INF \\ lib我从资源管理器窗口Gson复制并粘贴了这三个文件...我在Deplyment Assembly中添加了这些文件,现在它们位于导出的JAR文件中,但相同的错误不断发生。

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. 注意:没有安全问题,小程序已签名,删除gson函数后,我的方法直接返回ATR代码(字符串),小程序运行正常。

Any step by step tutorial to "install" for it??? 任何分步教程来“安装”它???

Thanks in advance! 提前致谢!

Screen images: 屏幕图像:

在此处输入图片说明

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 ; 该applet正常运行,除使用GSON的功能外,所有功能均正常工作。 MyApplet.jar ; MyApplet.jar; \\scrits\\Myscript.js Inside de MyApplet.jar file exists many files .class ; \\ scrits \\ Myscript.js MyApplet.jar文件中存在许多文件.class; .classpath ; .classpath; project and two folders (META-INF and WebContent with WEB-INF\\lib and GSON jar files, three). 项目和两个文件夹(META-INF和WebContent以及WEB-INF \\ lib和GSON jar文件,三个)。 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 问题是:在使用GSON执行功能时,它会引发错误,在IIS日志中,我看到404 for /com/google/gson/Gson.class

Applet Jar Content Applet Jar内容

>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"

WebContent \\ WEB-INF \\ lib Web内容\\ 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). 尝试使用浏览器地址栏中的直接访存从那里取回applet,以发现“不允许”错误(我认为它们是500范围内的响应代码)。

If you cannot retrieve it by direct fetch, the Java Plug-In also cannot access it. 如果您无法通过直接提取来检索它,则Java插件也将无法访问它。

The applet needs to be moved to a place outside the WEB-INF directory structure that is accessible to the browser/plug-in. 该小程序需要移动到浏览器/插件可以访问的WEB-INF目录结构之外的位置。

Output of Jar command Jar命令的输出

..
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. 提取Jar,然后将内容添加到主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 ). applet元素的archive属性中单独列出gson-2.2.4.jar Jar(并且不要 将其放在另一个Jar中 )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM