在selfSigned jar中调用applet时出现ClassNotFoundException

时间:2014-04-21 04:22:25

标签: java applet classnotfoundexception

虽然升级了我11年前开发的代码,但现在我得到了classNotFoundException 在(在jsp文件中)调用已签名jar中的applet时 这是在我升级到JDK7并且必须克服自签名证书问题时开始的 我希望有人可以帮助我。我看了很多网站并实施了一些建议,但无济于事。

我的所有xxxxxApplet.java源文件都有包com.MasterCar.Applets;
并驻留在 C:\ jdev \ com \ MasterCar \ Applets

在我的DEV机器上使用:

WinXP或Win7

jdk1.7.0_51

Ant 1.6.5

ApacheTomcat-6.0.29

浏览器:FireFox12& IE7

问题:

java.lang.ClassNotFoundException: com.MasterCar.Applets.PrintApplet.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.initAppletAdapter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

jsp文件在selfSigned jar中调用applet:

尝试了本网站和其他网站上的建议。

尝试将代码更改为" ./ PrintApplet.class"

尝试添加codebase ="。"

<%=BASEURL%> is set to/MasterCar

model.jspLogger("CarsAddIncludeApplet.jsp - calling PrintApplet ");   
%>
<applet id="printapplet" 
     code="com<%=BASEURL%>/Applets/PrintApplet.class"
     archive="printApplets.jar" 
     width=160 height=35>
<param name="companyCSV" value="<%= companyCSV %>">
<param name="headerCSV" value="<%= headerCSV %>">
<param name="itemCSV" value="<%= itemCSV %>">
<param name="tradeinCSV" value="<%= tradeinCSV %>">
<param name="firstStockno" value="<%= firstStockno %>">
</applet>
<%      model.jspLogger("CarsAddIncludeApplet.jsp - end of applet ");   %>

C:\ Program Files \ apache-tomcat-6.0.29 \ webapps \ MasterCar \ jsp \ printApplet.jar

PrintApplet.class存在于jar文件中 ......

** jar文件中的路径是com \ MasterCar \ Applets **

查看printApplets.jar中的清单文件

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Class-Path: C:\j2sdkee1.3\lib\system\cloudscape.jar;C:\Program Files\J
ava\jdk1.7.0_51\lib\tools.jar;C:\j2sdkee1.3\lib\cloudscape\RmiJdbc.ja
r;C:\j2sdkee1.3\lib\cloudscape\cloudclient.jar;C:\Program Files\Java\
jdk1.7.0_51\jre\lib\rt.jar;C:\Program Files\Java\jdk1.7.0_51\db\lib;C
:\Program Files\Java\jdk1.7.0_51\lib\visualvm\platform\modules\ext\jh
all-2.0_05.jar;C:\Program Files\Java\jdk1.7.0_51\lib\tools.jar;C:\jde
v\Com\MasterCar\Lib\mysql-connector-java-5.1.13-bin.jar;C:\Program Fi
les\apache-tomcat-6.0.29\lib\servlet-api.jar;C:\jdev
Permissions: all-permissions
Created-By: 24.51-b03 (Oracle Corporation)

Name: com/MasterCar/Applets/PrintStockApplet.class
SHA-256-Digest: fuRUI6qCQII+0SRnaVRn24IyuXHx9HO1hYhciag1lI8=

Name: com/MasterCar/Applets/PrintApplet.class
SHA-256-Digest: cKXo//Y5evy/fG59LIAmHXrafk6GA6I1TCteDP/Phkw=

我的applet的源文件位于

  C:\jdev\com\MasterCar\Applets

在构建过程中,构建applet并创建类文件 暂时存储在$ {class}目录中,之后删除 生成包含applet的printApplets.jar。

Applets目录(com \ MasterCar \ Applets)未部署到容器中。

Ant构建脚本

尝试将Main-Class添加到Manifest

basedir="c:\jdev\com\MasterCar"  


<property name="jsp"     value="c:\jdev\com\MasterCar\webapps\MasterCar\jsp"/>
<property name="class"   value="${basedir}\webapps\MasterCar\WEB-INF\classes"/>
<property name="applets" value="c:\jdev\com\MasterCar\Applets"/>
<property name="MasterCarCpath" value="C:\j2sdkee1.3\lib\system\cloudscape.jar;
C:\Program Files\Java\jdk1.7.0_51\lib\tools.jar;
C:\j2sdkee1.3\lib\cloudscape\RmiJdbc.jar;
C:\j2sdkee1.3\lib\cloudscape\cloudclient.jar;
C:\Program Files\Java\jdk1.7.0_51\jre\lib\rt.jar;
C:\Program Files\Java\jdk1.7.0_51\db\lib;
C:\Program Files\Java\jdk1.7.0_51\lib\visualvm\platform\modules\ext\jhall-2.0_05.jar;
C:\Program Files\Java\jdk1.7.0_51\lib\tools.jar;
C:\jdev\Com\MasterCar\Lib\mysql-connector-java-5.1.13-bin.jar;
C:\Program Files\apache-tomcat-6.0.29\lib\servlet-api.jar;C:\jdev" />  




<target name="build_applets" depends="build_model">
<!-- Build all java applet files to class files -->
<javac srcdir="${applets}"
     destdir="${class}"
     debug="on"
     classpath="${MasterCarCpath}"
 />

<jar    jarfile="${jsp}/printApplets.jar" 
        basedir="${class}"
        includes="com/MasterCar/Applets/*.class">           

    <manifest>
        <!-- attribute name="Main-Class" value="./PrintApplet.class"/ -->
        <attribute name="Class-Path" value="${MasterCarCpath}"/>
        <attribute name="Permissions" value="all-permissions"/>

    </manifest>

</jar>


<signjar jar="${jsp}/printApplets.jar" 
         alias="ronmasters"
         signedjar="${jsp}/printApplets.jar" 
         storepass="mastercar" 
         keystore="${build}/mastercarkeystore.jks"
         keypass="mastercar" 
/>


 <delete includeEmptyDirs="true">
  <fileset dir="${class}"
    includes="com/MasterCar/Applets/*.class" />
 </delete>
</target>

0 个答案:

没有答案