首页 > 解决方案 > Java Web Start - 线程“AWT-EventQueue-2”中的异常 java.lang.NullPointerException

问题描述

我有一个 java 应用程序,它在 netbeans 上运行得非常好并且作为一个独立的,但是当我使用 JNLP 运行它时会出错。以下是日志的一部分:

Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException
at texttospeech.MainPopup.buttonPlaySpeechActionPerformed(Unknown Source)
at texttospeech.MainPopup.access$100(Unknown Source)
at texttospeech.MainPopup$2.actionPerformed(Unknown Source)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

这是我的 JNLP:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="http://localhost:8080" href="texttospeech.jnlp" version="1">
    <information>
        <title>Text To Speech</title>
        <vendor>Interact</vendor>
        <description>
            Application to convert text to speech
        </description>
        <offline-allowed/>
    </information>
    <security>
        <all-permissions/>
    </security>
    <resources>
        <j2se version="1.8+" href="http://java.sun.com/products/autodl/j2se"/>
        <jar href="texttospeech.jar" main="true"/>
        <jar href="/lib/freetts.jar"/>
        <jar href="/lib/cmu_time_awb.jar"/>
        <jar href="/lib/cmu_us_kal.jar"/>
        <jar href="/lib/cmulex.jar"/>
        <jar href="/lib/cmutimelex.jar"/>
        <jar href="/lib/en_us.jar"/>
    </resources>
    <application-desc main-class="texttospeech.MainPopup"/>
    <update check="background"/>
</jnlp>

在验证日志时,我发现所有的 JAR 都被下载了,这没有任何问题。我所有的 JAR 都使用相同的证书(自签名)进行了签名。我做了很多谷歌搜索 - 没有任何帮助。

技术细节

预期功能

MainPopup 类加载 - 它显示 GUI。有一个按钮可以播放将输入的文本转换为语音并播放。它使用freeTTS。此功能在没有 JNLP 的情况下完美运行。

实际行为

使用 JNLP 运行时,GUI 会加载,并且 MainPopup 类的所有功能都可以工作。但是当我点击播放按钮(加载 freeTTS VoiceManager)时,我得到了这个异常并且我没有听到任何声音。也许 JNLP 无法在其他 JAR 中找到类?

请帮我解决一下这个。如果您需要更多详细信息,请告诉我。谢谢你。

标签: javatomcatjava-web-startjnlpfreetts

解决方案


推荐阅读