简体   繁体   English

Java Web 开始 - 运行时出现 ClassNotFoundException

[英]Java Web Start - ClassNotFoundException when running

I am now trying to deploy a Java application with Java Web Start.我现在正在尝试使用 Java Web 开始部署 Java 应用程序。 The application works fine when running standalone.该应用程序在独立运行时工作正常。 I exported the project as a runnable.jar file, and then wrote the corresponding jnlp file.我把工程导出为一个runnable.jar文件,然后写了对应的jnlp文件。

However, when running from the jnlp file, the application returns the following error when starting up:但是,从 jnlp 文件运行时,应用程序在启动时返回以下错误:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: someClass
........
Caused by: java.lang.ClassNotFoundException: someClass
.........

I exported the.jar file using Eclipse Helios with the option "Package required libraries into generated JAR".我使用 Eclipse Helios 导出了 .jar 文件,并带有“将所需的库打包到生成的 JAR”选项。

Here's what my jnlp file looks like (I substituted some information):这是我的 jnlp 文件的样子(我替换了一些信息):

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" 
    codebase="................" 
    href="thisJNLP.jnlp">
    <information>
        <title>Whatever</title>
        <vendor>Whatever</vendor>
    </information>
    <security>
        <all-permissions/>
    </security>

    <resources>
        <!-- Application Resources -->
        <j2se version="1.6+"
              href="http://java.sun.com/products/autodl/j2se"/>
        <jar href="signed.jar" main="true" />

    </resources>
    <application-desc
         name="Whatever"
         main-class="thisProject.main"
         width="300"
         height="300">
     </application-desc>
     <update check="background"/>
</jnlp>

In addition, I am using WebLogic 10 to host the files, but I doubt that will make any difference.此外,我正在使用 WebLogic 10 来托管文件,但我怀疑这会产生什么不同。

Could someone help me out?有人可以帮我吗?

Thanks for any inputs!感谢您的任何投入!

From the WebStart Developer's Guide :WebStart 开发人员指南

All application resources must be retrieved from the JAR files specified in the resources section of the JNLP file, or retrieved explicitly using an HTTP request to the Web server.所有应用程序资源都必须从 JNLP 文件的资源部分中指定的 JAR 文件中检索,或者使用对 Web 服务器的 HTTP 请求显式检索。 Storing resources in JAR files is recommended, since they will be cached on the local machine by Java Web Start.建议将资源存储在 JAR 文件中,因为它们会被缓存在本地机器上,由 Java Web 启动。

So the class loader mechanism is different for WebStart applications.所以 class 加载器机制对于 WebStart 应用程序是不同的。 I assume it's the packaging option "Package required libraries into generated JAR" that causes problems in your case.我认为是打包选项“将所需的库打包到生成的 JAR 中”会导致您的情况出现问题。

Is the class someClass contained in a jar that is contained within your signed.jar file? class someClass是否包含在您的signed.jar文件中的 jar 中? If so, this would back this theory - try generating separate jar files (don't forget to sign them all!) and reference each of them in the <resources> section as a separate <jar> entry.如果是这样,这将支持这个理论 - 尝试生成单独的 jar 文件(不要忘记全部签名!)并在<resources>部分中将它们中的每一个作为单独的<jar>条目引用。

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

相关问题 使用 Gradle 运行 Java 时出现 ClassNotFoundException - ClassNotFoundException when running Java with Gradle Java:使用netty运行程序时出现ClassNotFoundException [Gradle] - Java : ClassNotFoundException when running program with netty [Gradle] 在 Windows 上运行 mvn exec:java 时出现 ClassNotFoundException - ClassNotFoundException when running mvn exec:java on Windows 在Java Web应用程序中加载Applet时发生ClassNotFoundException - ClassNotFoundException when loading Applet in Java Web Application 在Java Web Start中运行JNLP时发生NullPointerException(jar用作stardardlone) - NullPointerException when running JNLP in Java Web Start (jar works as stardardlone) 运行Spring MVC Web应用程序时出现Java ClassNotFoundException - Java ClassNotFoundException while running spring mvc web-app 运行 Java Web 在没有 Java ZC6E190B2846334348E39E5CCE8Z 的情况下启动应用程序 - Running a Java Web Start application without Java Web Start 运行java -jar时的java.lang.ClassNotFoundException - java.lang.ClassNotFoundException when running java -jar 在Eclipse下作为Web应用程序运行时,出现NoClassDefFoundError和ClassNotFoundException - NoClassDefFoundError and ClassNotFoundException when running as Web Application under Eclipse 在CMD中运行时发生ClassNotFoundException - ClassNotFoundException when running in CMD
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM