Java Webstart ClassNotFoundException WebSockets



我正试图将一个使用多个模块的相当复杂的应用程序转换为使用webstart,而不是等效的C#。(我知道webstart已经被弃用,并且正在消失。这是一个临时解决方案(我正在使用maven webstart插件,当它试图加载Java Websockets库时,我似乎遇到了一个问题,即ClassNotFoundException。问题是其中一个应用程序模块的POM文件中包含了websocket(我甚至试图将其作为显式依赖项添加到主应用程序中(。它确实在JNLP文件中,而且肯定在webstart插件生成的lib文件夹中,所以我很困惑它为什么找不到它。如果有任何帮助,我将不胜感激。我已经尝试了我能想到的一切(在主项目中显式依赖,将对websocket的调用移动到主应用程序中——它只是将异常移动到了那里(。我还启用了Java调试器,这样当网页JNLP加载时控制台就会出现,并且我确实看到它加载了WebSocket JAR:

例外:

java.lang.ClassNotFoundException: org.java_websocket.client.WebSocketClient
at java.net.URLClassLoader.findClass(Unknown Source)
at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.sun.jnlp.JNLPClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.sun.jnlp.JNLPClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.joy.system.SystemAppLaunch.main(SystemAppLaunch.java:329)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

控制台输出:

Java Web Start 11.181.2.13 x86
Using JRE version 1.8.0_181-b13 Java HotSpot(TM) Client VM
User home directory = C:Usersuser
----------------------------------------------------
c:   clear console window
f:   finalize objects on finalization queue
g:   garbage collect
h:   display this help message
m:   print memory usage
o:   trigger logging
p:   reload proxy configuration
q:   hide console
r:   reload policy configuration
s:   dump system and deployment properties
t:   dump thread list
v:   dump thread stack
0-5: set trace level to <n>
----------------------------------------------------
CacheEntry[file:/C:/Users/user/Desktop/Alpha/apache-tomcat-9.0.0.M26/webapps/FB2HMI/lib/Java-WebSocket-1.3.0.jar]: updateAvailable=false,lastModified=Mon Nov 26 11:39:44 EST 2018,length=113538
Sep 11 15:24:07 EDT 2018,length=12913
System Application is started. Please wait......
#### Java Web Start Error:
#### org.java_websocket.client.WebSocketClient

JNLP文件:

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="" href="launch.jnlp">
<information>
<title>SystemApp</title>
<vendor></vendor>
<homepage href=""/>
<description>System Application</description>
<icon kind="splash" href="kom.jpeg"/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.7+"/>
<jar href="lib/DaExecutive.jar"/>

<jar href="lib/SystemApp-10.0.60.jar" main="true"/>
<jar href="lib/DDS-10.0.60.jar"/>
<jar href="lib/jackson-core-2.2.3.jar"/>
<jar href="lib/jackson-coreutils-1.8.jar"/>
<jar href="lib/msg-simple-1.1.jar"/>
<jar href="lib/btf-1.2.jar"/>
<jar href="lib/jackson-databind-2.2.3.jar"/>
<jar href="lib/guava-16.0.1.jar"/>
<jar href="lib/jsr305-2.0.1.jar"/>
<jar href="lib/json-schema-core-1.2.5.jar"/>
<jar href="lib/uri-template-0.9.jar"/>
<jar href="lib/rhino-1.7R4.jar"/>
<jar href="lib/json-schema-validator-2.2.6.jar"/>
<jar href="lib/joda-time-2.3.jar"/>
<jar href="lib/libphonenumber-6.2.jar"/>
<jar href="lib/mailapi-1.4.3.jar"/>
<jar href="lib/activation-1.1.jar"/>
<jar href="lib/jopt-simple-4.6.jar"/>
<jar href="lib/Utilities-10.0.60.jar"/>
<jar href="lib/zip4j-1.2.3.jar"/>
<jar href="lib/jackson-dataformat-xml-2.9.5.jar"/>
<jar href="lib/jackson-annotations-2.9.0.jar"/>
<jar href="lib/jackson-module-jaxb-annotations-2.9.5.jar"/>
<jar href="lib/stax2-api-3.1.4.jar"/>
<jar href="lib/woodstox-core-5.0.3.jar"/>
<jar href="lib/Carousel-10.0.60.jar"/>
<jar href="lib/CoreControls-10.0.60.jar"/>
<jar href="lib/CommonInterface-1.0.0.jar"/>
<jar href="lib/log4j-1.2.17.jar"/>
<jar href="lib/json-20090211.jar"/>
<jar href="lib/gson-1.4.jar"/>
<jar href="lib/commons-io-2.4.jar"/>
<jar href="lib/jna-4.1.0.jar"/>
<jar href="lib/platform-3.4.0.jar"/>
<jar href="lib/TableLayout-20050920.jar"/>
<jar href="lib/CoreHMIAppBuilder-10.0.60.jar"/>
<jar href="lib/Fb2HmiCm-10.0.64.jar"/>
<jar href="lib/commons-collections4-4.0.jar"/>
<jar href="lib/CoreStandardFeatures-10.0.60.jar"/>
<jar href="lib/commons-net-3.6.jar"/>
<jar href="lib/Java-WebSocket-1.3.0.jar"/>
<jar href="lib/commons-configuration-1.6.jar"/>
<jar href="lib/commons-collections-3.2.1.jar"/>
<jar href="lib/commons-lang-2.4.jar"/>
<jar href="lib/commons-logging-1.1.1.jar"/>
<jar href="lib/commons-digester-1.8.jar"/>
<jar href="lib/commons-beanutils-1.7.0.jar"/>
<jar href="lib/commons-beanutils-core-1.8.0.jar"/>

<property name="jnlp.serverip" value="192.168.0.50"/>
<property name="jnlp.serverport" value="8080"/>
</resources>
<application-desc main-class="com.joy.system.SystemAppLaunch" name="SystemApp">
<argument>8887</argument>
<argument>192.168.0.50</argument>
</application-desc>
</jnlp>

我的POM文件如下(针对主要应用程序模块(:

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>ParentProject</groupId>
<artifactId>ParentProject</artifactId>
<version>10.0.60</version>
<relativePath>../ParentProject/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>SystemApp</groupId>
<artifactId>SystemApp</artifactId>
<name>SystemApp</name>
<description>System Application</description>
<dependencies>
<dependency>
<groupId>DDS</groupId>
<artifactId>DDS</artifactId>
<version>${dds-version}</version>
</dependency>
<dependency>
<groupId>utility</groupId>
<artifactId>Utilities</artifactId>
<version>${utilities-version}</version>
</dependency>
<dependency>
<groupId>Carousel</groupId>
<artifactId>Carousel</artifactId>
<version>${carousel-version}</version>
</dependency>
<dependency>
<groupId>CoreControls</groupId>
<artifactId>CoreControls</artifactId>
<version>${coreControls-version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>platform</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>tablelayout</groupId>
<artifactId>TableLayout</artifactId>
<version>20050920</version>
</dependency>
<dependency>
<groupId>CoreHMIAppBuilder</groupId>
<artifactId>CoreHMIAppBuilder</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Tell maven to compile using Java 1.8 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<fork>true</fork>
<executable>${JAVA_1_8_HOME}</executable>
</configuration>
</plugin>       
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>webstart-maven-plugin</artifactId>
<version>1.0-beta-6</version>
<dependencies>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-api-1.7</artifactId>
<version>1.5</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jnlp-inline</goal>
</goals>
</execution>
</executions>
<configuration>
<excludeTransitive>false</excludeTransitive>
<makeArchive>false</makeArchive>
<filenameMapping>simple</filenameMapping>
<versionEnabled>false</versionEnabled>
<jnlpFiles>
<jnlpFile>
<templateFilename>template.vm</templateFilename>
<outputFilename>launch.jnlp</outputFilename>
<jarResources>
<jarResource>
<groupId>SystemApp</groupId>
<artifactId>SystemApp</artifactId>
<name>SystemApp</name>
<version>${project.version}</version>
<mainClass>com.joy.system.SystemAppLaunch</mainClass>                                                       
</jarResource>
</jarResources>
</jnlpFile>
</jnlpFiles>
<unsignAlreadySignedJars>true</unsignAlreadySignedJars>
<canUnsign>true</canUnsign>
<libPath>lib</libPath>
<codebase></codebase>
<updateManifestEntries>
<Application-Name>SystemApp</Application-Name>
<Class-Path>resources/ resources/images/ resources/properties/ resources/config/</Class-Path>
<Trusted-Library>true</Trusted-Library>
<Permissions>all-permissions</Permissions>
<Codebase>*</Codebase>
<Trusted-Only>true</Trusted-Only>
</updateManifestEntries>
<jnlp>
<j2seVersion>1.7+</j2seVersion>
<outputFile>launch.jnlp</outputFile>
<mainClass>com.joy.system.SystemAppLaunch</mainClass>
</jnlp>
<sign>
<keystore>${project.basedir}/myKeystore.jks</keystore>
<storepass>password</storepass>
<alias>key_2017</alias>
<verify>false</verify>
</sign>
<verbose>true</verbose>
</configuration>
</plugin>
</plugins>
</build>
</project>

如果有人遇到这种情况,我所做的就是手动将应用程序中需要的一个单独的JAR添加到JAR模板列表的顶部。你可以在我上面的JNLP文件DaExecutive.jar中看到它。有一个问题,我还没有解决,但它阻止了加载列表中它下面的所有.jar依赖项。删除允许它们加载的。

相关内容

  • 没有找到相关文章

最新更新