Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 泽西在战争档案中休息_Java_Web Services_Rest_Jboss_Jersey 1.0 - Fatal编程技术网

Java 泽西在战争档案中休息

Java 泽西在战争档案中休息,java,web-services,rest,jboss,jersey-1.0,Java,Web Services,Rest,Jboss,Jersey 1.0,为了公开一些RESTWeb服务,我使用Jersey 1.19开发了一个服务器应用程序。该应用程序作为WAR文件部署在JBoss 7.1.1中。在部署期间,我遇到以下异常: 12:23:37,497 INFO [com.sun.jersey.api.core.PackagesResourceConfig] (MSC service thread 1-6) Scanning for root resource and provider classes in the packages: com.

为了公开一些RESTWeb服务,我使用Jersey 1.19开发了一个服务器应用程序。该应用程序作为WAR文件部署在JBoss 7.1.1中。在部署期间,我遇到以下异常:

12:23:37,497 INFO  [com.sun.jersey.api.core.PackagesResourceConfig] (MSC service thread 1-6) Scanning for root resource and provider classes in the packages:
  com.link.frontend.webservices.v2
12:23:37,507 INFO  [com.sun.jersey.server.impl.application.WebApplicationImpl] (MSC service thread 1-6) Initiating Jersey application, version 'Jersey: 1.19 02/11/2015 03:25 AM'
12:23:37,609 SEVERE [com.sun.jersey.server.impl.application.RootResourceUriRules] (MSC service thread 1-6) The ResourceConfig instance does not contain any root resource classes.
12:23:37,612 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/Link]] (MSC service thread 1-6) StandardWrapper.Throwable: com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.
        at com.sun.jersey.server.impl.application.RootResourceUriRules.<init>(RootResourceUriRules.java:99) [jersey-server-1.19.jar:1.19]
        at com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1359) [jersey-server-1.19.jar:1.19]
        at com.sun.jersey.server.impl.application.WebApplicationImpl.access$700(WebApplicationImpl.java:180) [jersey-server-1.19.jar:1.19]
        at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:799) [jersey-server-1.19.jar:1.19]
        at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:795) [jersey-server-1.19.jar:1.19]
        at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193) [jersey-core-1.19.jar:1.19]
        at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:795) [jersey-server-1.19.jar:1.19]
        at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:790) [jersey-server-1.19.jar:1.19]
        at com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:509) [jersey-servlet-1.19.jar:1.19]
        at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:339) [jersey-servlet-1.19.jar:1.19]
        at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:605) [jersey-servlet-1.19.jar:1.19]
        at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:207) [jersey-servlet-1.19.jar:1.19]
        at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:394) [jersey-servlet-1.19.jar:1.19]
        at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:577) [jersey-servlet-1.19.jar:1.19]
        at javax.servlet.GenericServlet.init(GenericServlet.java:242) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202) [jbossweb-7.0.13.Final.jar:]
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1102) [jbossweb-7.0.13.Final.jar:]
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3655) [jbossweb-7.0.13.Final.jar:]
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:3873) [jbossweb-7.0.13.Final.jar:]
        at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_79]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_79]
        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_79]

12:23:37,647 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/Link]] (MSC service thread 1-6) Servlet /Link threw load() exception: com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.
        at com.sun.jersey.server.impl.application.RootResourceUriRules.<init>(RootResourceUriRules.java:99) [jersey-server-1.19.jar:1.19]
        at com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1359) [jersey-server-1.19.jar:1.19]
        at com.sun.jersey.server.impl.application.WebApplicationImpl.access$700(WebApplicationImpl.java:180) [jersey-server-1.19.jar:1.19]
        at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:799) [jersey-server-1.19.jar:1.19]
        at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:795) [jersey-server-1.19.jar:1.19]
        at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193) [jersey-core-1.19.jar:1.19]
        at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:795) [jersey-server-1.19.jar:1.19]
        at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:790) [jersey-server-1.19.jar:1.19]
        at com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:509) [jersey-servlet-1.19.jar:1.19]
        at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:339) [jersey-servlet-1.19.jar:1.19]
        at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:605) [jersey-servlet-1.19.jar:1.19]
        at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:207) [jersey-servlet-1.19.jar:1.19]
        at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:394) [jersey-servlet-1.19.jar:1.19]
        at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:577) [jersey-servlet-1.19.jar:1.19]
        at javax.servlet.GenericServlet.init(GenericServlet.java:242) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202) [jbossweb-7.0.13.Final.jar:]
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1102) [jbossweb-7.0.13.Final.jar:]
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3655) [jbossweb-7.0.13.Final.jar:]
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:3873) [jbossweb-7.0.13.Final.jar:]
        at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_79]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_79]
我的web.xml文件如下所示:

package com.link.frontend.webservices.v2;

import java.sql.Connection;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;

import org.apache.log4j.MDC;

import com.sun.jersey.api.core.HttpContext;
import com.sun.jersey.oauth.server.OAuthServerRequest;
import com.sun.jersey.oauth.signature.OAuthParameters;
import com.link.frontend.controllers.DBManager;
import com.link.frontend.controllers.DeviceManager;
import com.link.frontend.controllers.OAuthenticationManager;
import com.link.frontend.exceptions.DeviceAuthenticationException;
import com.link.frontend.exceptions.ExcessiveCallsException;
import com.link.frontend.exceptions.InactiveDeviceException;
import com.link.frontend.exceptions.InvalidInputException;
import com.link.frontend.model.ExposedErrorCodes;
import com.link.frontend.model.exposed.DeviceList;

@Path("/devices")
public class DeviceWS
{

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public Response getAllDevices(@Context HttpContext httpContext)
    {
      //Business logic here
    }

}
<?xml version="1.0" encoding="ISO-8859-1"?>

<!-- ~ Licensed to the Apache Software Foundation (ASF) under one ~ or more 
    contributor license agreements. See the NOTICE file ~ distributed with this 
    work for additional information ~ regarding copyright ownership. The ASF 
    licenses this file ~ to you under the Apache License, Version 2.0 (the ~ 
    "License"); you may not use this file except in compliance ~ with the License. 
    You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 
    ~ ~ Unless required by applicable law or agreed to in writing, ~ software 
    distributed under the License is distributed on an ~ "AS IS" BASIS, WITHOUT 
    WARRANTIES OR CONDITIONS OF ANY ~ KIND, either express or implied. See the 
    License for the ~ specific language governing permissions and limitations 
    ~ under the License. -->

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
    <display-name>Link</display-name>
    <servlet>
        <servlet-name>V2</servlet-name>
        <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>com.sun.jersey.config.property.packages</param-name>
            <param-value>com.link.frontend.webservices.v2</param-value>
        </init-param>
        <init-param>
            <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
            <param-value>true</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>V2</servlet-name>
        <url-pattern>/api/v2/*</url-pattern>
    </servlet-mapping>

</web-app>

链接
V2
com.sun.jersey.spi.container.servlet.ServletContainer
com.sun.jersey.config.property.packages
com.link.frontend.webservices.v2
com.sun.jersey.api.json.POJOMappingFeature
真的
1.
V2
/api/v2/*
因为我使用的是JBoss 7.1.1,所以我不能在JBoss-deployment-structure.xml中排除使用以下内容的子系统:

  <exclude-subsystems>  
      <subsystem name="jaxrs" />  
      <subsystem name="webservices" />  
    </exclude-subsystems>  

因此,我从standalone.xml中删除了对“jaxrs”的引用

上述例外情况的一个转折点是,如果我使用同一WAR文件的分解版本(作为位于deployments目录中的文件夹),那么一切都可以完美地工作


您认为问题出在哪里?

getAllDevices()没有路径注释。这使它成为一个子资源定位器。但为什么我的项目会以爆炸式的形式工作,而当一切都在压缩的战争中时却不工作呢?不知道。我只会说出我能看到的,这是一个记录在案的原因,得到那个例外。请注意,您的web.xml绝对不正确,它定义了Servlet2.3规范遵从性,而您至少需要Servlet2.5规范或更高版本。这个问题显示了一个更好的web.xml根节点:这似乎是不相关的。JBoss7完全理解我的web.xml,当我的归档文件在“分解”模式下工作时,它很好地收集了Jersey资源。