Deployment ArrayIndexOutOfBoundsException部署到GlassFish 4.1.1,但没有web.xml

Deployment ArrayIndexOutOfBoundsException部署到GlassFish 4.1.1,但没有web.xml,deployment,jersey,glassfish,Deployment,Jersey,Glassfish,我在使用Maven GlassFish插件将Jersey服务器(没有web.xml)部署到GlassFish 4.1.1时遇到了一个奇怪的错误(事实上,我已经将我的(Maven)构建从嵌入式Grizzly切换到GlassFish,将标准Jersey依赖项从compile更新为provided): [错误]远程故障:部署期间发生错误:异常 加载应用程序时:java.lang.IllegalStateException: ContainerBase.addChild:start:org.apache

我在使用Maven GlassFish插件将Jersey服务器(没有web.xml)部署到GlassFish 4.1.1时遇到了一个奇怪的错误(事实上,我已经将我的(Maven)构建从嵌入式Grizzly切换到GlassFish,将标准Jersey依赖项从compile更新为provided):

[错误]远程故障:部署期间发生错误:异常 加载应用程序时:java.lang.IllegalStateException: ContainerBase.addChild:start:org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.lang.ArrayIndexOutOfBoundsException:0。有关详细信息,请参阅server.log 更多细节

当我没有在ResourceConfig实现中声明@ApplicationPath时,部署成功。但是,我在尝试使用该服务时遇到了404错误。根据Jersey文档,web.xml部署()不需要@ApplicationPath

部署错误日志提取如下:

[2015-12-28009:33:40.826+0800][glassfish 4.1][Severy][ [javax.enterprise.web][tid:_ThreadID=123 _ThreadName=admin listener(6)][timeMillis:1451266420826][levelValue:1000][[
WebModule[/BBQuay-Entertainment-1.0-SNAPSHOT]StandardWrapper.Throwable java.lang.ArrayIndexOutOfBoundsException:0位于 org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:505) 在 org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:182) 在 org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:348) 在 org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:345) 位于org.glassfish.jersey.internal.Errors.process(Errors.java:315) org.glassfish.jersey.internal.Errors.process(Errors.java:297)位于 org.glassfish.jersey.internal.Errors.processWithException(Errors.java:255) 在 org.glassfish.jersey.server.ApplicationHandler.(ApplicationHandler.java:345) 在 org.glassfish.jersey.servlet.WebComponent(WebComponent.java:390) 在 org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170) 在 org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:362) 位于javax.servlet.GenericServlet.init(GenericServlet.java:244) org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1583)


在Glassfish 4.1.1(不含
web.xml
)上,以下内容已足够:

还有一个示例类:

import javax.ws.rs.GET;
import javax.ws.rs.Path;

@Path("info")
public class InfoStub {

    @GET
    public String getInfo() {
        return "hello sir";
    }
}
你可以在下面访问它


确保将
pom.xml
中的标准Jersey依赖项设置为提供的

它原来是一个Maven配置。因为我以前使用Grizzly进行过测试,所以在切换到GlassFish时,我保留了Jersey-weld2-se和Jersey-cdi1x这两个依赖项的默认Maven范围。后者很好,但rst由GlassFish容器提供。更正如下有助于解决此问题(尽管部署错误确实没有帮助..)


org.glassfish.jersey.ext.cdi
泽西-2-se
假如
org.glassfish.jersey.ext.cdi
jersey-cdi1x

…足够…:-)我认为它没有解决这个问题。我已经有了ApplicationPath批注。问题是部署遇到了ArrayIndexOutOfBoundsException,即使使用GlassFish管理面板也是如此。奇怪的是,如果我取出ApplicationPath批注,部署就成功了。好的,但我无法重现问题w使用我上面发布的设置。也许你可以用更多信息更新你的问题。
import javax.ws.rs.GET;
import javax.ws.rs.Path;

@Path("info")
public class InfoStub {

    @GET
    public String getInfo() {
        return "hello sir";
    }
}
<dependency>
    <groupId>org.glassfish.jersey.ext.cdi</groupId>
    <artifactId>jersey-weld2-se</artifactId>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.glassfish.jersey.ext.cdi</groupId>
    <artifactId>jersey-cdi1x</artifactId>
</dependency>