Glassfish和eclipse - 获得意外的Null指针异常

时间:2014-07-15 20:13:48

标签: java eclipse java-ee glassfish glassfish-4

我刚刚在Eclipse的.metadata文件夹中打开了.log文件。我看到我的glassfish服务器抛出了一个空指针异常。 我不知道为什么会这样。有人可以帮我搞清楚并修复它吗?

!ENTRY oracle.eclipse.tools.glassfish 
!MESSAGE GlassFish: Error getting URL for WebResource [module=Module[AffableBean,org.eclipse.jst.jee.server:AffableBean], path=]
!STACK 0
java.lang.NullPointerException
    at java.net.Parts.<init>(Unknown Source)
    at java.net.URL.<init>(Unknown Source)
    at java.net.URL.<init>(Unknown Source)
    at oracle.eclipse.tools.glassfish.GlassfishGenericServer.getModuleRootURL(GlassfishGenericServer.java:127)
    at oracle.eclipse.tools.glassfish.GlassfishLaunchableAdapterDelegate.getLaunchable(GlassfishLaunchableAdapterDelegate.java:55)
    at org.eclipse.wst.server.core.internal.LaunchableAdapter.getLaunchable(LaunchableAdapter.java:76)
    at org.eclipse.wst.server.ui.internal.ServerUIPlugin.getLaunchableAdapter(ServerUIPlugin.java:1095)
    at org.eclipse.wst.server.ui.internal.wizard.fragment.OptionalClientWizardFragment.updateClients(OptionalClientWizardFragment.java:65)
    at org.eclipse.wst.server.ui.internal.wizard.fragment.OptionalClientWizardFragment.getChildFragments(OptionalClientWizardFragment.java:113)
    at org.eclipse.wst.server.ui.internal.wizard.TaskWizard.addSubWizardFragments(TaskWizard.java:329)
    at org.eclipse.wst.server.ui.internal.wizard.TaskWizard.addSubWizardFragments(TaskWizard.java:333)
    at org.eclipse.wst.server.ui.internal.wizard.TaskWizard.getAllWizardFragments(TaskWizard.java:317)
MORE...............

1 个答案:

答案 0 :(得分:0)

我有同样的问题并通过

解决了这个问题

添加WEB-INF / glassfish-web.xml文件,例如:     

<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
    <context-root>/hello2</context-root>
</glassfish-web-app>