Java Web Start - ClassNotFoundException when running

情到浓时终转凉″ 提交于 2019-12-21 21:17:50

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/6612556/java-web-start-classnotfoundexception-when-running

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!