Java Web Start - ClassNotFoundException运行时 [英] Java Web Start - ClassNotFoundException when running

查看:163
本文介绍了Java Web Start - ClassNotFoundException运行时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Java Web Start部署Java应用程序。该应用程序运行时独立运行。我将该项目导出为一个可运行的.jar文件,然后写入相应的jnlp文件。



但是,当从jnlp文件运行时,应用程序返回以下错误启动:

 线程中的异常AWT-EventQueue-0java.lang.NoClassDefFoundError:someClass 
.. ......
引起的:java.lang.ClassNotFoundException:someClass
.........

我使用Eclipse Helios导出了.jar文件,其中包含将需要的库转换为生成的JAR。



这是什么我的jnlp文件看起来像(我替换了一些信息):

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

< resources>
<! - 应用程序资源 - >
< j2se version =1.6+
href =http://java.sun.com/products/autodl/j2se//>
< jar href =signed.jarmain =true/>

< / resources>
< application-desc
name =无论如何
main-class =thisProject.main
width =300
height =300> ;
< / application-desc>
< update check =background/>
< / jnlp>

此外,我使用WebLogic 10托管文件,但我怀疑会有什么区别



有人可以帮助我吗?



感谢任何投入!

解决方案

WebStart开发人员指南


所有应用程序资源都必须从JAR文件中检索在JNLP文件的资源部分中指定,或者使用HTTP请求显式检索到Web服务器。建议在JAR文件中存储资源,因为它们将通过Java Web Start在本地机器上缓存。


所以类加载器机制对于WebStart应用程序是不同的。我假设它是包装选项包需要的库到生成的JAR,导致你的情况出现问题。



someClass 包含在您的 signed.jar 文件中的jar中?如果是这样,这将返回这个理论 - 尝试生成单独的jar文件(不要忘记签名全部!),并在< resources> 部分中引用它们作为单独的< jar> 条目。


I am now trying to deploy a Java application with Java Web Start. The application works fine when running standalone. I exported the project as a runnable .jar file, and then wrote the corresponding jnlp file.

However, when running from the jnlp file, the application returns the following error when starting up:

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

Here's what my jnlp file looks like (I substituted some information):

<?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.

Could someone help me out?

Thanks for any inputs!

解决方案

From the WebStart Developer's Guide:

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. Storing resources in JAR files is recommended, since they will be cached on the local machine by Java Web Start.

So the class loader mechanism is different for WebStart applications. I assume it's the packaging option "Package required libraries into generated JAR" that causes problems in your case.

Is the class someClasscontained in a jar that is contained within your signed.jar file? 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.

这篇关于Java Web Start - ClassNotFoundException运行时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆