JBoss 6.1 上的 Jersey - 如果我提供 web.xml,则非常简单的应用程序部署将失败

发布于 2025-01-04 03:28:45 字数 2551 浏览 1 评论 0原文

我使用 Jersey (最新版本)准备了一个简单的应用程序,并尝试将其部署在 JBoss 6.1 Final 服务器上,而不使用 web.xml 文件(使用 @ApplicationPath在我的应用程序类上)并且它工作得很好。 (尽管我必须从 server/default/deployers 中删除resteasy.deployer)。但是当我添加以下 web.xml(并删除@ApplicationPath)时,

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0">
    <servlet>
        <servlet-name>org.daud.InformationApplication</servlet-name>
    </servlet>
    <servlet-mapping>
        <servlet-name>org.daud.InformationApplication</servlet-name>
        <url-pattern>/information/*</url-pattern>
    </servlet-mapping>

</web-app>

它给了我“为 servlet 容器初始值设定项调用 onStartup 时出错”。完整的错误是:

06:42:01,649 INFO  [org.jboss.web.tomcat.service.deployers.TomcatDeployment] deploy, ctxPath=/jersey
06:42:01,649 ERROR [org.jboss.web.tomcat.service.deployers.JBossContextConfig] Error calling onStartup for servlet container initializer: com.sun.jersey.server.impl.container.servlet.JerseyServletContainerInitializer: java.lang.NullPointerException
    at com.sun.jersey.server.impl.container.servlet.JerseyServletContainerInitializer.addServletWithExistingRegistration(JerseyServletContainerInitializer.java:239) [:1.11]
    at com.sun.jersey.server.impl.container.servlet.JerseyServletContainerInitializer.onStartup(JerseyServletContainerInitializer.java:129) [:1.11]
    at org.jboss.web.tomcat.service.deployers.JBossContextConfig.lifecycleEvent(JBossContextConfig.java:189) [:6.1.0.Final]
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:115) [:6.1.0.Final]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3823) [:6.1.0.Final]
    at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:294) [:6.1.0.Final]
    at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:146) [:6.1.0.Final

我的 Application 文件 (InformationApplication.java) 是:

public class InformationApplication extends PackagesResourceConfig {
    public InformationApplication() {
        super("org.daud.resources");
    }
}

I prepared a simple application using Jersey (latest version) and tried to deploy it on JBoss 6.1 Final server without the web.xml file (using @ApplicationPath over my Application class) and it worked fine. (though I had to remove resteasy.deployer from server/default/deployers). But when I added the following web.xml (and removed @ApplicationPath),

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0">
    <servlet>
        <servlet-name>org.daud.InformationApplication</servlet-name>
    </servlet>
    <servlet-mapping>
        <servlet-name>org.daud.InformationApplication</servlet-name>
        <url-pattern>/information/*</url-pattern>
    </servlet-mapping>

</web-app>

it gave me "Error calling onStartup for servlet container initializer". The full error was :

06:42:01,649 INFO  [org.jboss.web.tomcat.service.deployers.TomcatDeployment] deploy, ctxPath=/jersey
06:42:01,649 ERROR [org.jboss.web.tomcat.service.deployers.JBossContextConfig] Error calling onStartup for servlet container initializer: com.sun.jersey.server.impl.container.servlet.JerseyServletContainerInitializer: java.lang.NullPointerException
    at com.sun.jersey.server.impl.container.servlet.JerseyServletContainerInitializer.addServletWithExistingRegistration(JerseyServletContainerInitializer.java:239) [:1.11]
    at com.sun.jersey.server.impl.container.servlet.JerseyServletContainerInitializer.onStartup(JerseyServletContainerInitializer.java:129) [:1.11]
    at org.jboss.web.tomcat.service.deployers.JBossContextConfig.lifecycleEvent(JBossContextConfig.java:189) [:6.1.0.Final]
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:115) [:6.1.0.Final]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3823) [:6.1.0.Final]
    at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:294) [:6.1.0.Final]
    at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:146) [:6.1.0.Final

My Application file (InformationApplication.java) is :

public class InformationApplication extends PackagesResourceConfig {
    public InformationApplication() {
        super("org.daud.resources");
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文