Open Shift上的Java Applet

时间:2014-06-13 19:53:43

标签: java maven applet openshift

尝试在浏览器中运行applet时遇到问题。我得到一个NullPointerException,我无法弄清楚它出了什么问题。

这是堆栈跟踪:

Java Plug-in 10.60.2.19
Using JRE version 1.7.0_60-b19 Java HotSpot(TM) Client VM
User home directory = C:\Users\Alexandru
----------------------------------------------------
c:   clear console window
f:   finalize objects on finalization queue
g:   garbage collect
h:   display this help message
l:   dump classloader list
m:   print memory usage
o:   trigger logging
q:   hide console
r:   reload policy configuration
s:   dump system and deployment properties
t:   dump thread list
v:   dump thread stack
x:   clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------
java.lang.NullPointerException
    at sun.awt.SunToolkit.getSystemEventQueueImplPP(Unknown Source)
    at sun.awt.SunToolkit.getSystemEventQueueImplPP(Unknown Source)
    at sun.awt.SunToolkit.getSystemEventQueueImpl(Unknown Source)
    at java.awt.Toolkit.getEventQueue(Unknown Source)
    at java.awt.EventQueue.invokeLater(Unknown Source)
    at sun.awt.windows.WToolkit.windowsSettingChange(Unknown Source)
    at sun.awt.windows.WToolkit.eventLoop(Native Method)
    at sun.awt.windows.WToolkit.run(Unknown Source)

我在获得Quiz.class的ClassNotFound之后得到了这个。

这是我的代码:

<jsp:plugin type="applet" code="Quiz.class" codebase="../target/classes" width="500" height="280">
    <jsp:fallback> 
    <p> Unable to load applet </p> 
    </jsp:fallback>
</jsp:plugin>

我正在尝试在OpenShift云服务上运行该应用。我的服务器使用JBoss运行,它应该创建一个测验并在applet中显示它。我已经创建了测验,我可以通过jsp在浏览器中显示它,但是由于安全问题,我现在正试图在applet中显示它。

这是applet的代码(此applet仅用于测试,我应该设法在解决此问题后在其中显示测验):

package models;

import java.applet.Applet;
import java.awt.Graphics;

public class Quiz extends Applet{

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    public void paint(Graphics g)
    {
          g.drawString("My applet",400,200);
    }
}

我的项目以Maven为基础,我认为这很重要。我尝试将编译的类从我的applet添加到jar并使用Maven插件在运行时使用此示例Maven - Copy Some Dependency JARs into warSourceDirectory将其添加到webapp文件夹,但它没有帮助。我还尝试使用这个插件将类直接编译到webapp文件夹:

<pluginRepositories>
        <pluginRepository>
            <id>eap</id>
            <url>http://maven.repository.redhat.com/techpreview/all</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>

和此个人资料:

<profile>
            <id>copy</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.goldin</groupId>
                        <artifactId>copy-maven-plugin</artifactId>
                        <version>0.2.5</version>
                        <executions>
                            <execution>
                                <id>create-archive</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>copy</goal>
                                </goals>
                                <configuration>
                                    <resources>
                                        <resource>
                                            <targetPath>${project.build.outputDirectory}/work/webapp/WEB-INF/classes/</targetPath>
                                            <directory>${project.basedir}/src/main/webapp</directory>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

但它也没有用。还有其他建议吗?

1 个答案:

答案 0 :(得分:0)

您可能需要将Quiz.class文件放在您的webroot目录中(通过您的jsp文件),以便jsp代码可以找到它,否则我认为../target/classes不会暴露给浏览器网络,因为这似乎是一个安全问题?